2004-11-28 03:35:12 +00:00
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />
2010-08-09 20:07:24 +00:00
< meta name = "generator" content = "Docutils 0.7: http://docutils.sourceforge.net/" />
2004-11-28 03:35:12 +00:00
< title > The MPL Reference Manual: Inserter</ title >
< link rel = "stylesheet" href = "../style.css" type = "text/css" />
</ head >
< body class = "docframe refmanual" >
< table class = "header" >< tr class = "header" >< td class = "header-group navigation-bar" >< span class = "navigation-group" >< a href = "./algorithms-concepts.html" class = "navigation-link" > Prev</ a > < a href = "./reversible-algorithm.html" class = "navigation-link" > Next</ a ></ span >< span class = "navigation-group-separator" > | </ span >< span class = "navigation-group" > Back < a href = "./reversible-algorithm.html" class = "navigation-link" > Along</ a ></ span >< span class = "navigation-group-separator" > | </ span >< span class = "navigation-group" >< a href = "./algorithms-concepts.html" class = "navigation-link" > Up</ a > < a href = "../refmanual.html" class = "navigation-link" > Home</ a ></ span >< span class = "navigation-group-separator" > | </ span >< span class = "navigation-group" >< a href = "./refmanual_toc.html" class = "navigation-link" > Full TOC</ a ></ span ></ td >
< td class = "header-group page-location" >< a href = "../refmanual.html" class = "navigation-link" > Front Page</ a > / < a href = "./algorithms.html" class = "navigation-link" > Algorithms</ a > / < a href = "./algorithms-concepts.html" class = "navigation-link" > Concepts</ a > / < a href = "./inserter.html" class = "navigation-link" > Inserter</ a ></ td >
</ tr ></ table >< div class = "header-separator" ></ div >
< div class = "section" id = "inserter" >
2010-08-09 20:07:24 +00:00
< h1 >< a class = "toc-backref" href = "./algorithms-concepts.html#id1462" > Inserter</ a ></ h1 >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id454" >
2004-11-28 03:35:12 +00:00
< h3 >< a class = "subsection-title" href = "#description" name = "description" > Description</ a ></ h3 >
2019-04-23 21:47:07 +02:00
< p > An < a class = "reference internal" href = "./inserter.html" > Inserter</ a > is a compile-time substitute for STL < a class = "reference external" href = "https://boost.org/sgi/stl/OutputIterator.html" target = "_top" > Output Iterator</ a > .
2009-08-17 11:30:52 +00:00
Under the hood, it's simply a type holding
two entities: a < em > state</ em > and an < em > operation</ em > . When passed to a
2010-08-09 20:07:24 +00:00
< a class = "reference internal" href = "./transformation-algorithms.html" > transformation algorithm</ a > , the inserter's binary operation is
2009-08-17 11:30:52 +00:00
invoked for every element that would normally be written into the
2004-11-28 03:35:12 +00:00
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.</ p >
< p > Technically, instead of taking a single inserter parameter,
2009-08-17 11:30:52 +00:00
< a class = "reference internal" href = "./transformation-algorithms.html" > transformation algorithms</ a > 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
2004-11-28 03:35:12 +00:00
use cases.</ p >
</ div >
< div class = "section" id = "valid-expressions" >
2009-08-17 11:30:52 +00:00
< h3 > Valid expressions</ h3 >
< p > In the following table and subsequent specifications, < tt class = "literal" >< span class = "pre" > in</ span ></ tt > is a model of < a class = "reference internal" href = "./inserter.html" > Inserter</ a > .</ p >
< table border = "1" class = "docutils table" >
2004-11-28 03:35:12 +00:00
< colgroup >
< col width = "43%" />
< col width = "57%" />
</ colgroup >
< thead valign = "bottom" >
2009-08-17 11:30:52 +00:00
< tr >< th class = "head" > Expression</ th >
< th class = "head" > Type</ th >
2004-11-28 03:35:12 +00:00
</ tr >
</ thead >
< tbody valign = "top" >
< tr >< td >< tt class = "literal" >< span class = "pre" > in::state</ span ></ tt ></ td >
< td > Any type</ td >
</ tr >
< tr >< td >< tt class = "literal" >< span class = "pre" > in::operation</ span ></ tt ></ td >
2009-08-17 11:30:52 +00:00
< td > Binary < a class = "reference internal" href = "./lambda-expression.html" > Lambda Expression</ a ></ td >
2004-11-28 03:35:12 +00:00
</ tr >
</ tbody >
</ table >
</ div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id455" >
2004-11-28 03:35:12 +00:00
< h3 >< a class = "subsection-title" href = "#expression-semantics" name = "expression-semantics" > Expression semantics</ a ></ h3 >
2009-08-17 11:30:52 +00:00
< table border = "1" class = "docutils table" >
2004-11-28 03:35:12 +00:00
< colgroup >
< col width = "35%" />
< col width = "65%" />
</ colgroup >
< thead valign = "bottom" >
2009-08-17 11:30:52 +00:00
< tr >< th class = "head" > Expression</ th >
< th class = "head" > Semantics</ th >
2004-11-28 03:35:12 +00:00
</ tr >
</ thead >
< tbody valign = "top" >
< tr >< td >< tt class = "literal" >< span class = "pre" > in::state</ span ></ tt ></ td >
< td > The inserter's initial state.</ td >
</ tr >
< tr >< td >< tt class = "literal" >< span class = "pre" > in::operation</ span ></ tt ></ td >
< td > The inserter's " output" operation.</ td >
</ tr >
</ tbody >
</ table >
</ div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id456" >
2004-11-28 03:35:12 +00:00
< h3 >< a class = "subsection-title" href = "#example" name = "example" > Example</ a ></ h3 >
< pre class = "literal-block" >
typedef < a href = "./transform.html" class = "identifier" > transform</ a > <
< a href = "./range-c.html" class = "identifier" > range_c</ a > < int,0,10>
2009-08-17 11:30:52 +00:00
, < a href = "./plus.html" class = "identifier" > plus</ a > < < a href = "./placeholders.html" class = "identifier" > _1</ a > ,< a href = "./placeholders.html" class = "identifier" > _1</ a > >
2004-11-28 03:35:12 +00:00
, < a href = "./back-inserter.html" class = "identifier" > back_inserter</ a > < vector0<> >
> ::type result;
</ pre >
</ div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id457" >
2004-11-28 03:35:12 +00:00
< h3 >< a class = "subsection-title" href = "#models" name = "models" > Models</ a ></ h3 >
< ul class = "simple" >
2009-08-17 11:30:52 +00:00
< li >< a class = "reference internal" href = "./inserter-class.html" > inserter (class)</ a ></ li >
< li >< a class = "reference internal" href = "./front-inserter.html" > front_inserter</ a ></ li >
< li >< a class = "reference internal" href = "./back-inserter.html" > back_inserter</ a ></ li >
2004-11-28 03:35:12 +00:00
</ ul >
</ div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id458" >
2004-11-28 03:35:12 +00:00
< h3 >< a class = "subsection-title" href = "#see-also" name = "see-also" > See also</ a ></ h3 >
2009-08-17 11:30:52 +00:00
< p >< a class = "reference internal" href = "./algorithms.html" > Algorithms</ a > , < a class = "reference internal" href = "./transformation-algorithms.html" > Transformation Algorithms</ a > , < a class = "reference internal" href = "./inserter-class.html" > inserter (class)</ a > , < a class = "reference internal" href = "./front-inserter.html" > front_inserter</ a > , < a class = "reference internal" href = "./back-inserter.html" > back_inserter</ a ></ p >
2004-11-28 03:35:12 +00:00
<!-- Algorithms/Concepts//Reversible Algorithm -->
</ div >
</ div >
< div class = "footer-separator" ></ div >
< table class = "footer" >< tr class = "footer" >< td class = "header-group navigation-bar" >< span class = "navigation-group" >< a href = "./algorithms-concepts.html" class = "navigation-link" > Prev</ a > < a href = "./reversible-algorithm.html" class = "navigation-link" > Next</ a ></ span >< span class = "navigation-group-separator" > | </ span >< span class = "navigation-group" > Back < a href = "./reversible-algorithm.html" class = "navigation-link" > Along</ a ></ span >< span class = "navigation-group-separator" > | </ span >< span class = "navigation-group" >< a href = "./algorithms-concepts.html" class = "navigation-link" > Up</ a > < a href = "../refmanual.html" class = "navigation-link" > Home</ a ></ span >< span class = "navigation-group-separator" > | </ span >< span class = "navigation-group" >< a href = "./refmanual_toc.html" class = "navigation-link" > Full TOC</ a ></ span ></ td >
2009-08-17 11:30:52 +00:00
< td >< div class = "copyright-footer" >< div class = "copyright" > Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</ div >
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at < a class = "reference external" href = "http://www.boost.org/LICENSE_1_0.txt" target = "_top" > http://www.boost.org/LICENSE_1_0.txt</ a > )</ div ></ td ></ tr ></ table ></ body >
2004-11-28 03:35:12 +00:00
</ html >