Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66520 - sandbox/statistics/support/libs/assign/v2/example
From: erwann.rogard_at_[hidden]
Date: 2010-11-12 08:52:14


Author: e_r
Date: 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
New Revision: 66520
URL: http://svn.boost.org/trac/boost/changeset/66520

Log:
adding examples to libs/assign/v2
Added:
   sandbox/statistics/support/libs/assign/v2/example/anon.cpp (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/anon.h (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/chain.cpp (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/chain.h (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/conversion.cpp (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/conversion.h (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/foo.cpp (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/foo.h (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/fusion.cpp (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/fusion.h (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/include.h (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/put_adaptor.cpp (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/put_adaptor.h (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/put_range.cpp (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/put_range.h (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/ref_anon.cpp (contents, props changed)
   sandbox/statistics/support/libs/assign/v2/example/ref_anon.h (contents, props changed)

Added: sandbox/statistics/support/libs/assign/v2/example/anon.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/anon.cpp 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <libs/assign/v2/example/include.h>
+#include <libs/assign/v2/example/foo.h>
+#include <libs/assign/v2/example/anon.h>
+
+namespace example_assign_v2{
+namespace xxx_anon{
+
+ void run()
+ {
+ using namespace boost::assign::v2;
+ std::cout << "---xxx_anon " << std::endl;
+ {
+ std::cout << "csv_anon" << ' ';
+ //[csv_anon
+ boost::for_each( csv_anon<T>( x, y ,z ), printer(std::cout) );
+ // outputs (1,0)(NULL,0)(1,5)
+ //]
+ std::cout << std::endl;
+ std::cout << "anon" << ' ';
+ //[anon
+ boost::for_each(
+ (anon<T>( _nil ) % _push_front)( a )()( a, b ),
+ printer(std::cout)
+ );
+ // outputs (1,5)(NULL,0)(1,0)
+ //]
+ }
+ std::cout << std::endl;
+ }
+
+}// xxx_anon
+}// example_assign_v2

Added: sandbox/statistics/support/libs/assign/v2/example/anon.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/anon.h 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_EXAMPLE_ANON_ER_2010_H
+#define BOOST_ASSIGN_V2_EXAMPLE_ANON_ER_2010_H
+
+namespace example_assign_v2{
+namespace xxx_anon{
+
+ void run();
+
+}// xxx_anon
+}// example_assign_v2
+
+#endif

Added: sandbox/statistics/support/libs/assign/v2/example/chain.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/chain.cpp 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,59 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <list>
+#include <boost/array.hpp>
+#include <libs/assign/v2/example/include.h>
+#include <libs/assign/v2/example/foo.h>
+#include <libs/assign/v2/example/chain.h>
+
+namespace example_assign_v2{
+namespace xxx_chain{
+
+ void run()
+ {
+ using namespace boost::assign::v2;
+ std::cout << "chain_read" << std::endl;
+ {
+ //[chain_read
+ typedef boost::array<T, 1> cont1_; cont1_ cont1; cont1[0] = x;
+ typedef std::list<T> cont3_; cont3_ cont3; cont3.push_back( z );
+ using namespace adaptor;
+ namespace ns = ref::assign_copy;
+ boost::for_each(
+ cont1 | _chain( ns::csv_anon( y ) ) | _chain( cont3 ),
+ printer( std::cout )
+ );
+ // outputs (1,0)(NULL,0)(1,5)
+ //]
+ //[chain_write
+ T y1;
+ typedef std::vector<T> vec_; vec_ vec( 3, y );
+ boost::copy(
+ vec,
+ boost::begin(
+ cont1 /* lvalue */ | _chain(
+ ns::csv_anon( y1 /* lvalue */ ) /* rvalue */
+ ) | _chain( cont3 /* lvalue */ )
+ )
+ );
+ BOOST_ASSERT( cont1[0] == y );
+ BOOST_ASSERT( y1 == y );
+ BOOST_ASSERT( cont3.front() == y1 );
+ //]
+ }
+ {
+
+ }
+
+ }
+
+}// xxx_chain
+}// example_assign_v2

Added: sandbox/statistics/support/libs/assign/v2/example/chain.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/chain.h 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_EXAMPLE_CHAIN_ER_2010_H
+#define BOOST_ASSIGN_V2_EXAMPLE_CHAIN_ER_2010_H
+
+namespace example_assign_v2{
+namespace xxx_chain{
+
+ void run();
+
+}// xxx_chain
+}// example_assign_v2
+
+#endif

Added: sandbox/statistics/support/libs/assign/v2/example/conversion.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/conversion.cpp 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,75 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <deque>
+#include <queue>
+#include <stack>
+#include <boost/array.hpp>
+#include <libs/assign/v2/example/include.h>
+#include <libs/assign/v2/example/foo.h>
+#include <libs/assign/v2/example/ref_anon.h>
+
+namespace example_assign_v2{
+namespace xxx_conversion{
+
+ void run()
+ {
+ using namespace boost::assign::v2;
+ namespace ns_ref = ref::assign_copy;
+ {
+ {
+ //[convert_anon_explicit
+ typedef std::queue<T> to_;
+ to_ to = ref::assign_copy::csv_anon( x, y, z ).convert<to_>();
+ to.pop();
+ BOOST_ASSERT( to.front() == y ); // because FIFO
+ //]
+ }
+ {
+ //[convert_anon_auto
+ typedef std::deque<T> to_;
+ to_ to; to = ref::assign_copy::csv_anon( x, y, z );
+ to.pop_back(); BOOST_ASSERT( to.back() == y );
+ //]
+ }
+ {
+ //[convert_explicit
+ typedef boost::array<T, 3> from_;
+ typedef std::stack<T> to_;
+ from_ from; from[0] = x; from[1] = y; from[2] = z;
+ using namespace adaptor;
+ BOOST_ASSERT(
+ ( from | convert<to_>() ).top() == z // because LIFO
+ );
+ //]
+ }
+ {
+ //[convert_chain
+ typedef boost::array<T, 2> from_;
+ typedef std::stack<T> to_;
+ from_ from; from[0] = x; from[1] = y;
+ using namespace adaptor;
+ namespace ns = ref::assign_copy;
+ BOOST_ASSERT(
+ (
+ (
+ from | _chain( ns::csv_anon( z ) )
+ ).convert<to_>()
+ ).top() == z // because LIFO
+ );
+ //]
+
+ }
+
+ }
+ }
+
+}// xxx_conversion
+}// example_assign_v2

Added: sandbox/statistics/support/libs/assign/v2/example/conversion.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/conversion.h 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_EXAMPLE_CONVERSION_ER_2010_H
+#define BOOST_ASSIGN_V2_EXAMPLE_CONVERSION_ER_2010_H
+
+namespace example_assign_v2{
+namespace xxx_conversion{
+
+ void run();
+
+}// xxx_conversion
+}// example_assign_v2
+
+#endif

Added: sandbox/statistics/support/libs/assign/v2/example/foo.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/foo.cpp 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,27 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <libs/assign/v2/example/include.h>
+#include <libs/assign/v2/example/foo.h>
+
+namespace example_assign_v2{
+
+std::ostream& operator<<( std::ostream& os, foo const& t)
+{
+ os << '(';
+ if(t.ptr_a){
+ os << *t.ptr_a;
+ }else{
+ os << "NULL";
+ }
+ return os << ',' << t.b << ')';
+}
+
+}// example_assign_v2
+

Added: sandbox/statistics/support/libs/assign/v2/example/foo.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/foo.h 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,87 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_EXAMPLE_FOO_ER_2010_H
+#define BOOST_ASSIGN_V2_EXAMPLE_FOO_ER_2010_H
+#include <libs/assign/v2/example/include.h>
+
+namespace example_assign_v2{
+
+//[foo
+struct foo
+{
+ foo():ptr_a( 0 ), b( 0 ){}
+ foo( int& a) : ptr_a( &a ), b( 0 ){}
+ foo( int& a, int const& b_): ptr_a( &a ), b( b_ ){}
+
+ bool operator==(foo const& other)const
+ {
+ return (this->ptr_a == other.ptr_a) && (this->b == other.b);
+ }
+
+ foo& operator+=(int const& delta){ this->b += delta; return (*this); }
+
+ private:
+ friend std::ostream & operator<<(std::ostream &os, const foo& p);
+ int* ptr_a;
+ int b;
+};
+
+struct make_foo
+{
+ typedef foo result_type;
+ result_type operator()(int& a, int const& b)const
+ {
+ return result_type( a, b );
+ }
+};
+
+std::ostream& operator<<( std::ostream& os, foo const& t);
+
+struct printer
+{
+ typedef void result_type;
+
+ printer(std::ostream& os_) : os( os_ ){}
+
+ result_type operator()( foo const& t)const
+ {
+ this->os << t;
+ }
+
+ private:
+ mutable std::ostream& os;
+};
+//]
+
+//[foo_types
+typedef const char* S; // key
+typedef foo T; // data
+typedef std::pair<S,T> U; //key-data pair
+//]
+
+//[foo_constants
+namespace{
+
+int a = 1, b = 5;
+
+S key_x = "x" ;
+S key_y = "y" ;
+S key_z = "z" ;
+
+const T x( a ); // (1, 0)
+const T y; // (NULL, 0)
+const T z( a, b ); //(1, 5)
+
+}
+//]
+
+}// example_assign_v2
+
+#endif

Added: sandbox/statistics/support/libs/assign/v2/example/fusion.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/fusion.cpp 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,44 @@
+////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+////////////////////////////////////////////////////////////////////////////
+#include <boost/assign/v2/ref/anon/detail/lazy_alloc.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/assign/v2/detail/checking/check_equal.hpp>
+#include <boost/assign/v2/ref/fusion/fusion.hpp>
+
+#include <libs/assign/v2/example/fusion.h>
+
+namespace example_assign_v2{
+namespace xxx_fusion{
+
+ void run()
+ {
+ using namespace boost::assign::v2;
+ typedef int t0_;
+ typedef int const t1_;
+ t0_ a = 1;
+ typedef ref::assign_tag::copy tag1_;
+ typedef ref::alloc_tag::lazy_alloc tag2_;
+
+ typedef ref::nth_result_of::fusion<
+ tag1_, tag2_, t0_ // NOT nil_arg_type
+ > meta_result_;
+ typedef boost::mpl::apply1<
+ meta_result_,
+ boost::mpl::vector<t0_,t1_>
+ >::type result_;
+ result_ result =
+ ref::fusion<tag1_, tag2_, t0_>( _nil )( a )( 2 );
+ BOOST_ASSIGN_V2_CHECK_EQUAL( result[ 0 ] , a );
+ BOOST_ASSIGN_V2_CHECK_EQUAL( result[ 1 ] , 2 );
+ }
+
+}// xxx_fusion
+}// example_assign_v2

Added: sandbox/statistics/support/libs/assign/v2/example/fusion.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/fusion.h 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_EXAMPLE_FUSION_ER_2010_H
+#define BOOST_ASSIGN_V2_EXAMPLE_FUSION_ER_2010_H
+
+namespace example_assign_v2{
+namespace xxx_fusion{
+
+ void run();
+
+}// xxx_fusion
+}// example_assign_v2
+
+#endif

Added: sandbox/statistics/support/libs/assign/v2/example/include.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/include.h 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_EXAMPLE_INCLUDE_ER_2010_H
+#define BOOST_ASSIGN_V2_EXAMPLE_INCLUDE_ER_2010_H
+
+//[include_statements
+#include <iostream>
+#include <utility> // std::pair
+#include <boost/assert.hpp>
+#include <boost/range/algorithm.hpp>
+#include <boost/assign/v2/v2.hpp>
+//]
+
+#endif

Added: sandbox/statistics/support/libs/assign/v2/example/put_adaptor.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/put_adaptor.cpp 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,188 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <list>
+#include <map>
+#include <boost/array.hpp>
+#include <boost/lambda/bind.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <libs/assign/v2/example/include.h>
+#include <libs/assign/v2/example/foo.h>
+#include <libs/assign/v2/example/put_adaptor.h>
+
+namespace example_assign_v2{
+namespace xxx_put_adaptor{
+
+ void run()
+ {
+ using namespace boost::assign::v2;
+ std::cout << "---xxx_put_adaptor " << std::endl;
+ {
+ std::cout << "vector" << ' ';
+ //[vector
+ typedef std::vector<T> cont_;
+ cont_ cont;
+ using namespace adaptor;
+ boost::for_each( cont | _csv_put( x, y, z ), printer(std::cout) );
+ //outputs (1,0)(NULL,0)(1,5)
+ //]
+ std::cout << std::endl;
+ }
+ {
+ std::cout << "map" << ' ';
+ //[map
+ typedef std::map<S,T> cont_;
+ typedef cont_::value_type key_data_;
+ cont_ cont;
+ using namespace adaptor;
+ BOOST_ASSERT(
+ (
+ cont | _csv_put(
+ key_data_(key_z, z),
+ key_data_(key_y, y),
+ key_data_(key_x, x)
+ )
+ )[key_x] == x
+ );
+ //]
+ //[map_proper
+ cont.clear();
+ BOOST_ASSERT(
+ ( cont | _put (key_z, z)(key_y, y)(key_x, x) )[key_x] == x
+ );
+ //]
+ std::cout << std::endl;
+ }
+ {
+ std::cout << "static_array" << ' ';
+ //[static_array
+ typedef boost::array<T,3> cont_;
+ cont_ cont;
+ using namespace adaptor;
+ boost::for_each( cont | _csv_put( x, y, z ), printer(std::cout) );
+ //]
+ std::cout << std::endl;
+ }
+ {
+ std::cout << "ptr_vector" << ' ';
+ //[ptr_vector
+ typedef boost::ptr_vector<T> cont_; cont_ cont;
+ using namespace adaptor;
+ boost::for_each(
+ cont | _csv_put( x, y, z ),
+ printer(std::cout)
+ );
+ //]
+ std::cout << std::endl;
+ }
+ {
+ std::cout << "list" << ' ';
+ //[list
+ typedef std::list<T> cont_;
+ cont_ cont;
+ using namespace adaptor;
+ boost::for_each(
+ cont | (_csv_put % _push_front)( x, y, z ),
+ printer(std::cout)
+ );
+ //outputs (1,5)(NULL,0)(1,0)
+ //]
+ std::cout << std::endl;
+ }
+ {
+ std::cout << "in_place" << ' ';
+ //[in_place
+ typedef std::vector<T> cont_;
+ cont_ cont;
+ using namespace adaptor;
+ boost::for_each(
+ cont | _csv_put( foo( a ), foo(), foo( a, b ) ),
+ printer(std::cout)
+ );
+ //]
+ std::cout << std::endl;
+ }
+ {
+ std::cout << "forward_to_constructor" << ' ';
+ //[forward_to_constructor
+ typedef std::vector<T> cont_;
+ cont_ cont;
+ using namespace adaptor;
+ boost::for_each(
+ cont | _put( a )()( a, b ),
+ printer(std::cout)
+ );
+ //]
+
+ std::cout << std::endl;
+ std::cout << "forward_to_make_foo" << ' ';
+
+ //[forward_to_make_foo
+ int a0 = -1, a1 = 0, a2 = 1;
+ cont.clear();
+ boost::for_each(
+ cont | (
+ _put % ( _fun = make_foo() )
+ )( a0, b )( a1, b )( a2, b ),
+ printer(std::cout)
+ );
+ //outputs (-1,5)(0,5)(1,5)
+ //]
+
+ std::cout << std::endl;
+ std::cout << "forward_to_bind" << ' ';
+
+ //[forward_to_bind
+ cont.clear();
+ using namespace boost::lambda;
+ boost::for_each(
+ cont | (
+ _csv_put % (_fun = bind<T>( make_foo(), _1, b) )
+ )(a0, a1, a2),
+ printer(std::cout)
+ );
+ //]
+
+ std::cout << std::endl;
+ std::cout << "repeat_simpl" << ' ';
+ //[repeat_simple
+ cont.clear();
+ boost::for_each(
+ cont | ( _csv_put % ( _repeat = 2 ) )( x ),
+ printer(std::cout)
+ );
+ // outputs (1,0)(1,0)
+ //]
+ {
+ std::cout << std::endl;
+ std::cout << "complex_ex1" << ' ';
+ //[complex_ex1
+ typedef std::list<T> cont_;
+ cont_ cont;
+ using namespace boost::lambda;
+ boost::for_each(
+ cont | ( _csv_put )( x ) /*(1,0)*/ | (
+ _put % _push_front % ( _repeat = 2 )
+ )()( b, a ) /*(NULL,0)(5,1)*/ | (
+ _csv_put % ( _fun = bind<T>( make_foo(), _1, b) )
+ )( a0, a1, a2 ), /*(-1,5)(0,5)(1,5)*/
+ printer(std::cout)
+ );
+ //]
+ //[complex_ex1_answer
+ // outputs (5,1)(5,1)(NULL,0)(NULL,0)(1,0)(-1,5)(0,5)(1,5)
+ //]
+ }
+ }
+ std::cout << std::endl;
+ }
+
+}// xxx_put_adaptor
+}// example_assign_v2

Added: sandbox/statistics/support/libs/assign/v2/example/put_adaptor.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/put_adaptor.h 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_EXAMPLE_PUT_ADAPTOR_ER_2010_H
+#define BOOST_ASSIGN_V2_EXAMPLE_PUT_ADAPTOR_ER_2010_H
+
+namespace example_assign_v2{
+namespace xxx_put_adaptor{
+
+ void run();
+
+}// xxx_put_adaptor
+}// example_assign_v2
+
+#endif

Added: sandbox/statistics/support/libs/assign/v2/example/put_range.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/put_range.cpp 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <queue>
+#include <vector>
+#include <libs/assign/v2/example/include.h>
+#include <libs/assign/v2/example/foo.h>
+#include <libs/assign/v2/example/put_range.h>
+
+namespace example_assign_v2{
+namespace xxx_put_range{
+
+ void run()
+ {
+ using namespace boost::assign::v2;
+ std::cout << "---xxx_put_range " << std::endl;
+ {
+ //[put_range_queue
+ typedef std::vector<T> from_; from_ from( 3 );
+ from[0] = x; from[1] = y; from[2] = z;
+ typedef std::queue<T> to_; to_ to;
+ using namespace adaptor;
+ BOOST_ASSERT( (to | _put_range( from ) ).front() == x );
+ BOOST_ASSERT( to.back() == z );
+ //]
+ }
+ std::cout << std::endl;
+ }
+
+}// xxx_put_range
+}// example_assign_v2

Added: sandbox/statistics/support/libs/assign/v2/example/put_range.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/put_range.h 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_EXAMPLE_PUT_RANGE_ER_2010_H
+#define BOOST_ASSIGN_V2_EXAMPLE_PUT_RANGE_ER_2010_H
+
+namespace example_assign_v2{
+namespace xxx_put_range{
+
+ void run();
+
+}// xxx_put_range
+}// example_assign_v2
+
+#endif

Added: sandbox/statistics/support/libs/assign/v2/example/ref_anon.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/ref_anon.cpp 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,70 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <libs/assign/v2/example/include.h>
+#include <libs/assign/v2/example/foo.h>
+#include <libs/assign/v2/example/ref_anon.h>
+
+namespace example_assign_v2{
+namespace xxx_ref_anon{
+
+ void run()
+ {
+
+ using namespace boost::assign::v2;
+ std::cout << "---xxx_ref_anon " << std::endl;
+ {
+ std::cout << "ref::assign_copy::csv_anon" << std::endl;
+ //[assign_copy_read
+ namespace ns = ref::assign_copy;
+ boost::for_each( ns::csv_anon( x, y, z ), printer(std::cout) );
+ //outputs (1,0)(NULL,0)(1,5)
+ //]
+ //[assign_copy_write
+ T x1, y1, z1;
+ ns::csv_anon( x1, y1, z1 ).assign( T( b, a ) );
+ BOOST_ASSERT( y1 == T( b, a ) );
+ //]
+ //[csv_anon_empty
+ ns::csv_anon<T const>( _nil );
+ //]
+ }
+ {
+ //[assign_rebind_read
+ namespace ns = ref::assign_rebind;
+ typedef ns::nth_result_of::csv_anon<3, T const>::type result_;
+ result_ result = ns::csv_anon( x, y, z );
+ BOOST_ASSERT( &result[ 1 ] == &y );
+ //]
+ //[assign_rebind_write
+ T w = T( b, a ); result.assign( w );
+ BOOST_ASSERT( &result[ 1 ] == &w );
+ //]
+ }
+ {
+ //[anon_read_empty
+ namespace ns = ref::assign_rebind;
+ typedef ns::nth_result_of::anon<2, T const>::type result1_;
+ result1_ result1 = ns::anon( x )( y );
+ //]
+ //[anon_read_fill
+ typedef ns::nth_result_of::anon<3, T const>::type result2_;
+ result2_ result2 = result1( z );
+ //]
+ //[anon_read_print
+ boost::for_each( result2, printer(std::cout) );
+ //]
+ }
+ std::cout << std::endl;
+ }
+
+}// xxx_ref_anon
+}// example_assign_v2
+

Added: sandbox/statistics/support/libs/assign/v2/example/ref_anon.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/libs/assign/v2/example/ref_anon.h 2010-11-12 08:52:07 EST (Fri, 12 Nov 2010)
@@ -0,0 +1,21 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_EXAMPLE_REF_ANON_ER_2010_H
+#define BOOST_ASSIGN_V2_EXAMPLE_REF_ANON_ER_2010_H
+
+namespace example_assign_v2{
+namespace xxx_ref_anon{
+
+ void run();
+
+}// xxx_ref_anon
+}// example_assign_v2
+
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk