Back to Arangodb

Inserter

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/inserter.html

3.12.9.12.9 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Algorithms / Concepts / Inserter |

Inserter

Description

An Inserter is a compile-time substitute for STL Output Iterator. Under the hood, it's simply a type holding two entities: a state and an operation. When passed to a transformation algorithm, the inserter's binary operation is invoked for every element that would normally be written into the output iterator, with the element itself (as the second argument) and the result of the previous operation's invocation — or, for the very first element, the inserter's initial state.

Technically, instead of taking a single inserter parameter, transformation algorithms could accept the state and the "output" operation separately. Grouping these in a single parameter entity, however, brings the algorithms semantically and syntactically closer to their STL counterparts, significantly simplifying many of the common use cases.

Valid expressions

In the following table and subsequent specifications, in is a model of Inserter.

ExpressionType
in::stateAny type
in::operationBinary Lambda Expression

Expression semantics

ExpressionSemantics
in::stateThe inserter's initial state.
in::operationThe inserter's "output" operation.

Example

typedef[transform](./transform.html)<[range\_c](./range-c.html)<int,0,10>
    ,[plus](./plus.html)<[\_1](./placeholders.html),[\_1](./placeholders.html)>
    ,[back\_inserter](./back-inserter.html)< vector0<> >
    >::type result;

Models

See also

Algorithms, Transformation Algorithms, inserter (class), front_inserter, back_inserter

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |