|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69831 - in sandbox/assign_v2/libs/assign/v2: src test test/put test/put/modifier test/put/pipe test/put/pipe/modifier
From: erwann.rogard_at_[hidden]
Date: 2011-03-10 17:19:33
Author: e_r
Date: 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
New Revision: 69831
URL: http://svn.boost.org/trac/boost/changeset/69831
Log:
upd assign_v2
Text files modified:
sandbox/assign_v2/libs/assign/v2/src/main.cpp | 9 +
sandbox/assign_v2/libs/assign/v2/test/mix.cpp | 41 ++++++++--
sandbox/assign_v2/libs/assign/v2/test/put.cpp | 16 ++--
sandbox/assign_v2/libs/assign/v2/test/put/container.cpp | 139 ++++++++++++++++++---------------------
sandbox/assign_v2/libs/assign/v2/test/put/deque.cpp | 25 +++----
sandbox/assign_v2/libs/assign/v2/test/put/fun.cpp | 57 ++++++++++++----
sandbox/assign_v2/libs/assign/v2/test/put/modifier.h | 30 ++++++--
sandbox/assign_v2/libs/assign/v2/test/put/modifier/iterate.cpp | 43 ++++++-----
sandbox/assign_v2/libs/assign/v2/test/put/modifier/lookup.cpp | 5
sandbox/assign_v2/libs/assign/v2/test/put/modifier/repeat.cpp | 4
sandbox/assign_v2/libs/assign/v2/test/put/pipe.cpp | 4
sandbox/assign_v2/libs/assign/v2/test/put/pipe/fun.cpp | 38 ++++++----
sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/iterate.cpp | 18 ++--
sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/lookup.cpp | 23 ++----
sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/repeat.cpp | 13 +--
sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.cpp | 67 ++++--------------
sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.cpp | 63 -----------------
sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.h | 26 -------
18 files changed, 279 insertions(+), 342 deletions(-)
Modified: sandbox/assign_v2/libs/assign/v2/src/main.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/src/main.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/src/main.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -1,8 +1,9 @@
// Test
-#include <libs/assign/v2/test/detail.h>
-#include <libs/assign/v2/test/ref.h>
-//#include <libs/assign/v2/test/put.h>
+//#include <libs/assign/v2/test/detail.h>
+//#include <libs/assign/v2/test/ref.h>
+#include <libs/assign/v2/test/mix.h>
+#include <libs/assign/v2/test/put.h>
//#include <libs/assign/v2/test/utility.h>
//#include <libs/assign/v2/test/other.h>
@@ -45,6 +46,8 @@
}
{
using namespace test_assign_v2;
+ xxx_put::test();
+ xxx_mix::test();
/*
xxx_put::test();
xxx_ref::test();
Modified: sandbox/assign_v2/libs/assign/v2/test/mix.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/mix.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/mix.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -7,6 +7,9 @@
// 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 <iostream>
+
+
#include <cmath>
#include <list>
#include <vector>
@@ -18,6 +21,9 @@
#include <boost/range/algorithm/stable_partition.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/assign/v2/detail/config/check.hpp>
+#include <boost/assign/v2/put/container.hpp>
+#include <boost/assign/v2/put/modulo/fun.hpp>
+#include <boost/assign/v2/put/modifier/repeat.hpp>
#include <boost/assign/v2/put/pipe/csv_put.hpp>
#include <boost/assign/v2/put/pipe/put.hpp>
#include <boost/assign/v2/put/deque.hpp>
@@ -71,9 +77,9 @@
}
{
//[mix_deque_csv_array
- typedef double elem_; typedef std::list<elem_> r_; typedef std::vector<r_> ragged_array_;
+ typedef double elem_; typedef std::list<elem_> r_; typedef std::vector<r_> ragged_;
- ragged_array_ ragged_array = /*<<Using `converter` is a good practice, bearing in mind it may work without it>>*/converter(
+ ragged_ ragged = /*<<Using `converter` is a good practice, bearing in mind it may work without it>>*/converter(
as2::deque<r_>
( converter( as2::ref::csv_array( 0.71, 0.63, 0.85 ) ).type<r_>() )
( converter( as2::ref::csv_array( 0.61, 0.69, 0.92, 0.55 ) ).type<r_>() )
@@ -81,16 +87,31 @@
( )
);
- BOOST_ASSIGN_V2_CHECK( ragged_array[0].size() == 3 );
- BOOST_ASSIGN_V2_CHECK( ragged_array[1].size() == 4 );
- BOOST_ASSIGN_V2_CHECK( ragged_array[2].size() == 1 );
- BOOST_ASSIGN_V2_CHECK( ragged_array[3].size() == 0 );
+ BOOST_ASSIGN_V2_CHECK( ragged[0].size() == 3 );
+ BOOST_ASSIGN_V2_CHECK( ragged[1].size() == 4 );
+ BOOST_ASSIGN_V2_CHECK( ragged[2].size() == 1 );
+ BOOST_ASSIGN_V2_CHECK( ragged[3].size() == 0 );
//]
elem_ eps = boost::numeric::bounds<elem_>::smallest();
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array.front().front() - 0.71 ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array.front().back() - 0.85 ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array[2].front() + 99.0 ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array[2].back() + 99.0 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( ragged.front().front() - 0.71 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( ragged.front().back() - 0.85 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( ragged[2].front() + 99.0 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( ragged[2].back() + 99.0 ) < eps );
+ }
+ {
+
+ //[iterate
+ typedef int T; boost::array<T, 5> powers; powers[0] = 1; powers[1] = 10;
+ int i = 2, k = powers[ i - 1 ];
+ /*<<Calls `powers[i] = ( k *= 10 )` for [^ i = 2, 3, 4 ] >>*/
+ ( as2::put( powers ) % ( as2::_fun = lambda::var( k ) *= 10 ) % ( as2::_iterate = lambda::var( i )++ ) )()()();
+
+ BOOST_ASSIGN_V2_CHECK( powers[0] == 1 );
+ BOOST_ASSIGN_V2_CHECK( powers[1] == 10 );
+ BOOST_ASSIGN_V2_CHECK( powers[2] == 100 );
+ BOOST_ASSIGN_V2_CHECK( powers[3] == 1000 );
+ BOOST_ASSIGN_V2_CHECK( powers[4] == 10000 );
+ //]
}
{
//[deque_chain_put
Modified: sandbox/assign_v2/libs/assign/v2/test/put.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -9,9 +9,10 @@
//////////////////////////////////////////////////////////////////////////////
#include <libs/assign/v2/test/put/container.h>
#include <libs/assign/v2/test/put/deduce.h>
-#include <libs/assign/v2/test/put/deque.h>
+//#include <libs/assign/v2/test/put/deque.h>
+#include <libs/assign/v2/test/put/modifier.h>
#include <libs/assign/v2/test/put/fun.h>
-#include <libs/assign/v2/test/put/pipe.h>
+//#include <libs/assign/v2/test/put/pipe.h>
#include <libs/assign/v2/test/put/ptr.h>
#include <libs/assign/v2/test/put.h>
@@ -21,11 +22,12 @@
void test()
{
xxx_container::test();
- xxx_deduce::test();
- xxx_deque::test();
- xxx_fun::test();
- xxx_pipe::test();
- xxx_ptr::test();
+ //xxx_deduce::test();
+ //xxx_deque::test();
+ //xxx_fun::test();
+ xxx_modifier::test();
+ //xxx_pipe::test();
+ //xxx_ptr::test();
}
}// xxx_put
Modified: sandbox/assign_v2/libs/assign/v2/test/put/container.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/container.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/container.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -8,6 +8,7 @@
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
//////////////////////////////////////////////////////////////////////////////
#include <boost/array.hpp>
+#include <bitset>
#include <deque>
#include <map>
#include <list>
@@ -15,16 +16,19 @@
#include <stack>
#include <string>
#include <utility>
+#include <boost/assign/v2/detail/config/check.hpp>
+#include <boost/assign/v2/detail/functor/identity.hpp>
+#include <boost/assign/v2/put/container/put.hpp>
#include <boost/tuple/tuple.hpp>
+#include <boost/range/algorithm_ext/iota.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/numeric/conversion/bounds.hpp>
-#include <boost/assign/v2/detail/config/check.hpp>
-#include <boost/assign/v2/detail/functor/identity.hpp>
-#include <boost/assign/v2/put/container/put.hpp>
-#include <boost/assign/v2/put/container/put_range.hpp>
+#include <boost/variant.hpp>
#include <libs/assign/v2/test/put/container.h>
+#include <iostream>
+
namespace test_assign_v2{
namespace xxx_put{
namespace xxx_container{
@@ -32,49 +36,55 @@
void test(){
namespace as2 = boost::assign::v2;
-
- {
- //[put_array
- const int sz = 3;
- typedef boost::array<int, sz> r_;
- boost::array<r_, sz> matrix3x3;
- {
- r_ r0, r1, r2;
- /*<<Calls `r[i] = j` for [^( i, j ) = ( 0, 1 ), ( 1, 2 ), ( 2, 3 )]>>*/as2::put( r0 )( 1 )( 2 )( 3 );
- as2::put( r1 )( 4 )( 5 )( 6 );
- as2::put( r2 )( 7 )( 8 )( 9 );
- /*<<Calls `matrix3x3[i] = r`, for [^( i, r ) = ( 0, r0 ), ( 1, r1 ), ( 2, r2 )]>>*/as2::put( matrix3x3 )( r0 )( r1 )( r2 );
- }
- for(int i = 0; i < 9; i++)
+
+ {
+ //[put_bitset
+ typedef std::string str_; typedef /*<<`data_( "011" )`, for instance, is not valid, but `data_( str_( "011" ) )` is valid (GCC 4.2)>>*/ std::bitset<3> data_;
+ /*<<Neither `consecutive.push_back( "011" )`, nor `consecutive.push_back( str_( "011" ) )`, for instance, are valid, but `consecutive.push_back( data_( str_( "011" ) ) );` is valid (GCC4.2)>>*/ std::vector<data_> consecutive; /*<<Calls `consecutive.push_back( data_( t ) );` for [^t = str_( "000" ), str_( "001" ), str_( "010" ), str_( "011" ), str_( "100" ), str_( "101" ), str_( "110" ), str_( "111" )]`>>*/as2::put( consecutive )( str_( "000" ) )( str_( "001" ) )( str_( "010" ) )( str_( "011" ) )( str_( "100" ) )( str_( "101" ) )( str_( "110" ) )( str_( "111" ) );
+
+ for(int i = 0; i < consecutive.size(); i++)
{
- BOOST_ASSIGN_V2_CHECK( matrix3x3[ i / 3 ][ i % 3 ] == i + 1 );
+ std::cout << consecutive[i].to_ulong() << ' ';
+ BOOST_ASSIGN_V2_CHECK( consecutive[i].to_ulong() == i );
}
- //]
+ //]
+ }
+ {
+ //[put_as_arg_list
+ std::vector<int> numeric( 10 ); boost::iota( numeric, 0 ); typedef std::string str_;
+ typedef boost::variant< int, str_ > data_; boost::array<data_, 10 + 4> numeric_kb;
+ as2::put( numeric_kb )/*<<Calls `numeric_kb.push_back( data_( *( i + boost::begin( numeric ) ) ) )` for [^i = 0,...,9 ]``>>*/( as2::as_arg_list( numeric ) )( "+" )( "-" )( "*" )( "/" );
+
+ using namespace boost;
+ for(int i = 0; i< numeric.size(); i++){ BOOST_ASSIGN_V2_CHECK( get<int>( numeric_kb[i] ) == i ); }
+ BOOST_ASSIGN_V2_CHECK( get<str_>( numeric_kb[ numeric.size() ] ) == "+" );
+ BOOST_ASSIGN_V2_CHECK( get<str_>( numeric_kb[ numeric.size() + 3 ] ) == "/" );
+ //]
}
{
- //[put_seq_var_args
- typedef double elem_; typedef std::list<elem_> r_; typedef std::vector<r_> ragged_array_;
- r_ a; /* Calls `a.push_back( t )` for [^t = 0.71, 0.63, 0.85] */ as2::put( a )( 0.71 )( 0.63 )( 0.85 );
- r_ b; as2::put( b )( 0.61 )( 0.69 )( 0.92 )( 0.55 );
- ragged_array_ ragged_array;
- as2::put( ragged_array )
- /*<<Calls `ragged_array.push_back( r_( boost::begin( a ), boost::end( a ) ) )`>>*/( boost::begin( a ), boost::end( a ) )
- /*<<Calls `ragged_array.push_back( r_( b ) )`>>*/( b )
- /*<<Calls `ragged_array.push_back( r_( 1, -99.99 ) )`>>*/( 1, -99.99 )
- /*<<Calls `ragged_array.push_back( r_( ) )`>>*/( );
-
- BOOST_ASSIGN_V2_CHECK( ragged_array[0].size() == a.size() );
- BOOST_ASSIGN_V2_CHECK( ragged_array[1].size() == b.size() );
- BOOST_ASSIGN_V2_CHECK( ragged_array[2].size() == 1 );
- BOOST_ASSIGN_V2_CHECK( ragged_array[3].size() == 0 );
+ //[put_variable_args_size
+ typedef double data_; typedef std::vector<data_> variable_size_;
+ variable_size_ a( 3 ); a[0] = 0.71; a[1] = 0.63; a[2] = 0.85;
+ variable_size_ b; as2::put( b )( 0.61 )( 0.69 )( 0.92 )( 0.55 );
+ boost::array<variable_size_, 4> ragged;
+ as2::put( ragged )
+ /*<<Calls `ragged.push_back( variable_size_( boost::begin( a ), boost::end( a ) ) )`>>*/( boost::begin( a ), boost::end( a ) )
+ /*<<Calls `ragged.push_back( variable_size_( b ) )`>>*/( b )
+ /*<<Calls `ragged.push_back( variable_size_( 1, -99.99 ) )`>>*/( 1, -99.99 )
+ /*<<Calls `ragged.push_back( variable_size_( ) )`>>*/( );
+
+ BOOST_ASSIGN_V2_CHECK( ragged[0].size() == a.size() );
+ BOOST_ASSIGN_V2_CHECK( ragged[1].size() == b.size() );
+ BOOST_ASSIGN_V2_CHECK( ragged[2].size() == 1 );
+ BOOST_ASSIGN_V2_CHECK( ragged[3].size() == 0 );
//]
- elem_ eps = boost::numeric::bounds<elem_>::smallest();
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array[0].front() - a.front() ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array[0].back() - a.back() ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array[1].front() - b.front() ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array[1].back() - b.back() ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array[2].front() + 99.9 ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( ragged_array[2].back() + 99.9 ) < eps );
+ data_ eps = boost::numeric::bounds<data_>::smallest();
+ BOOST_ASSIGN_V2_CHECK( abs( ragged[0].front() - a.front() ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( ragged[0].back() - a.back() ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( ragged[1].front() - b.front() ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( ragged[1].back() - b.back() ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( ragged[2].front() + 99.9 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( ragged[2].back() + 99.9 ) < eps );
}
{
//[put_adapter
@@ -86,42 +96,19 @@
}
{
using namespace boost;
- //[put_seq_ref_tuple
- typedef const char state_ [3]; state_ ct = "CT", nj = "NJ", ny = "NY";
- typedef int code_; typedef boost::tuple<state_/*<<Notice the reference>>*/&, code_> area_code_;
- std::deque< area_code_ > tri_state; /*Calls `tri_state.push_back( area_code_( s, c ) )` for [^( s, c ) = ( nj, 201 )( ct, 203 )( ny, 212 )( ny, 315 )( ny, 347 )( nj, 551 )]*/as2::put( tri_state )( nj, 201 )( ct, 203 )( ny, 212 )( ny, 315 )( ny, 347 )( nj, 551 );
-
- BOOST_ASSIGN_V2_CHECK( get<0>( tri_state.front() ) == nj );
- BOOST_ASSIGN_V2_CHECK( get<0>( tri_state.back() ) == nj );
- BOOST_ASSIGN_V2_CHECK( get<1>( tri_state.front() ) == 201 );
- BOOST_ASSIGN_V2_CHECK( get<1>( tri_state.back() ) == 551 );
- //]
- }
- {
- //[put_range_assign
- typedef const char state_ [3]; state_ ct = "CT", nj = "NJ", ny = "NY", ca = "CA", /*ore = "OR",*/ wa = "WA";
- typedef int code_; typedef boost::tuple<state_/*<<Notice the reference>>*/&, code_> area_code_;
- std::deque< area_code_ > tri_state; as2::put( tri_state )( nj, 201 )( ct, 203 )( ny, 212 )( ny, 315 )( ny, 347 )( nj, 551 );
- std::deque< area_code_ > pacific ; as2::put( pacific )( wa, 206 )( ca, 209 )( ca, 213 )( wa, 253 );
-
- std::deque< area_code_ > states; as2::put_range( tri_state, states ); as2::put_range( pacific, states );
-
- using namespace boost;
- BOOST_ASSIGN_V2_CHECK( get<0>( states.front() ) == nj );
- BOOST_ASSIGN_V2_CHECK( get<0>( states[tri_state.size()-1] ) == nj );
- BOOST_ASSIGN_V2_CHECK( get<0>( states.front() ) == nj );
- BOOST_ASSIGN_V2_CHECK( get<0>( states[tri_state.size()] ) == wa );
- BOOST_ASSIGN_V2_CHECK( get<0>( states[tri_state.size() + pacific.size() - 1 ] ) == wa );
- //]
- }
- {
- //[put_range_constr
- std::vector<int> r( 3 ); r[0] = 72; r[1] = 31; r[2] = 48;
-
- BOOST_ASSIGN_V2_CHECK( as2::put_range< std:: stack<int> >( r ).top() == 48 );
+ // http://bioinfo.mbb.yale.edu/~mbg/dom/fun3/area-codes/
+ //[put_seq_tuple_ref
+ typedef const char us_state_ [3]; us_state_ ct = "CT", nj = "NJ", ny = "NY";
+ typedef int area_code_; typedef boost::tuple<us_state_/*<<Notice the reference>>*/&, area_code_> data_;
+ std::deque< data_ > tri_state_area; /*Calls `tri_state.push_back( data_( s, c ) )` for [^( s, c ) = ( ny, 212 )( ny, 718 )( ny, 516 )( ny, 914 )( nj, 210 )( nj, 908 )( nj, 609 )( ct, 203 ) ]*/
+ as2::put( tri_state_area )( ny, 212 )( ny, 718 )( ny, 516 )( ny, 914 )( nj, 210 )( nj, 908 )( nj, 609 )( ct, 203 );
+
+ BOOST_ASSIGN_V2_CHECK( get<0>( tri_state_area.front() ) == ny );
+ BOOST_ASSIGN_V2_CHECK( get<1>( tri_state_area.front() ) == 212 );
+ BOOST_ASSIGN_V2_CHECK( get<0>( tri_state_area.back() ) == ct );
+ BOOST_ASSIGN_V2_CHECK( get<1>( tri_state_area.back() ) == 203 );
//]
}
-
}// test()
}// xxx_container
Modified: sandbox/assign_v2/libs/assign/v2/test/put/deque.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/deque.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/deque.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -24,20 +24,17 @@
{
namespace as2 = boost::assign::v2;
{
- //[deque_ref_tuple
- typedef const char state_ [3]; state_ ct = "CT", nj = "NJ", ny = "NY";
- typedef int code_; typedef boost::tuple<state_/*<<Notice the reference>>*/&, code_> area_code_;
- typedef as2::result_of::deque<area_code_>::type states_;
- states_ tri_state = as2::deque<area_code_>( nj, 201 )( ct, 203 )( ny, 212 );
+ using namespace boost;
+ // http://bioinfo.mbb.yale.edu/~mbg/dom/fun3/area-codes/
+ //[deque_tuple_ref
+ typedef const char us_state_ [3]; us_state_ ct = "CT", nj = "NJ", ny = "NY";
+ typedef int area_code_; typedef boost::tuple<us_state_/*<<Notice the reference>>*/&, area_code_> data_;
+ as2::result_of::deque< data_ > tri_state_area = /*Calls `tri_state.push_back( data_( s, c ) )` for [^( s, c ) = ( ny, 212 )( ny, 718 )( ny, 516 )( ny, 914 )( nj, 210 )( nj, 908 )( nj, 609 )( ct, 203 ) ]*/as2::deque<data_>( ny, 212 )( ny, 718 )( ny, 516 )( ny, 914 )( nj, 210 )( nj, 908 )( nj, 609 )( ct, 203 );
- using namespace boost;
- BOOST_ASSIGN_V2_CHECK( get<0>( tri_state.front() ) == nj );
- BOOST_ASSIGN_V2_CHECK( get<1>( tri_state.front() ) == 201 );
-
- states_ tri_state2 = tri_state( ny, 315 )( ny, 347 )( nj, 551 );
-
- BOOST_ASSIGN_V2_CHECK( get<0>( tri_state2.back() ) == nj );
- BOOST_ASSIGN_V2_CHECK( get<1>( tri_state2.back() ) == 551 );
+ BOOST_ASSIGN_V2_CHECK( get<0>( tri_state_area.front() ) == ny );
+ BOOST_ASSIGN_V2_CHECK( get<1>( tri_state_area.front() ) == 212 );
+ BOOST_ASSIGN_V2_CHECK( get<0>( tri_state_area.back() ) == ct );
+ BOOST_ASSIGN_V2_CHECK( get<1>( tri_state_area.back() ) == 203 );
//]
}
{
@@ -58,7 +55,7 @@
BOOST_ASSIGN_V2_CHECK( cont.back() == 48 );
}
{
- C cont = as2::csv_deque( 72, 31 )/* This oddity is possible due to `result_of::csv_deque<int>::type == result_of::deque<int>::type`*/( 48 );
+ C cont = as2::csv_deque( 72, 31 )/* Thanks to `result_of::csv_deque<int>::type == result_of::deque<int>::type`*/( 48 );
BOOST_ASSIGN_V2_CHECK( cont.front() == 72 );
BOOST_ASSIGN_V2_CHECK( cont.back() == 48 );
Modified: sandbox/assign_v2/libs/assign/v2/test/put/fun.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/fun.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/fun.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -7,14 +7,23 @@
// 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 <bitset>
+#include <cmath> // MSVC #include <math.h>
#include <deque>
-#include <boost/typeof/typeof.hpp>
-#include <boost/spirit/home/phoenix.hpp>
+#include <list>
+#include <vector>
+#include <boost/array.hpp>
#include <boost/assign/v2/detail/config/check.hpp>
#include <boost/assign/v2/put/container.hpp>
#include <boost/assign/v2/put/deque.hpp>
#include <boost/assign/v2/put/modulo/fun.hpp>
+#include <boost/function.hpp>
+#include <boost/lambda/bind.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/construct.hpp>
+#include <boost/numeric/conversion/bounds.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/spirit/home/phoenix.hpp>
#include <libs/assign/v2/test/put/fun.h>
namespace test_assign_v2{
@@ -54,30 +63,48 @@
void test()
{
namespace as2 = boost::assign::v2;
- namespace lambda = boost::phoenix;
+ namespace lambda = boost::lambda;
{
- //[modulo_fun
- std::vector<int> incr_fact;
+ //[modulo_fun_math
+ std::vector<double> exponent;
+ typedef boost::function<double(double)> f_;
(
- as2::put( incr_fact ) % ( as2::_fun = lambda::arg_names::arg1 + 1 )
- )/*<<1!, 2!, 3!, 4!, 5!>>*/( 1 )( 2 )( 6 )( 24 )( 120 );
+ as2::put( exponent ) % ( as2::_fun = f_( log10 ) )
+ )( 1000.0 )( 10.0 )( 10000.0 )( 1.0 )( 100.0 );
- BOOST_ASSIGN_V2_CHECK( incr_fact.front() == ( 2 ) );
- BOOST_ASSIGN_V2_CHECK( incr_fact.back() == ( 121 ) );
+
+ double eps = boost::numeric::bounds<double>::smallest();
+ BOOST_ASSIGN_V2_CHECK( abs( exponent.front() - 3.0 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( exponent.back() - 2.0 ) < eps );
+ //]
+ }
+ {
+ //[modulo_fun_bitset
+ typedef std::bitset<3> data_; typedef const char str_lit_ [4]; /*<<`data_( "011" )`, for instance, is not valid, but `data_( str_( "011" ) )` is valid (GCC 4.2)>>*/typedef std::string str_;
+ /*<<Neither `consecutive[i] = ( "011" )`, nor `consecutive[i] = str_( "011" ) )`, for instance, are valid, but `consecutive[i] = ( data_( str_( "011" ) ) );` is valid (GCC4.2)>>*/boost::array<data_, 8> consecutive;
+ typedef lambda::constructor<data_> f_; typedef lambda::constructor<str_> g_; BOOST_AUTO( f_of_g, lambda::bind( f_(), lambda::bind( g_(), lambda::_1 ) ) );
+ ( as2::put( consecutive ) % ( as2::_fun = f_of_g ) )( "000" )( "001" )( "010" )( "011" )( "100" )( "101" )( "110" )( "110" );
+
+ for(int i = 0; i < consecutive.size(); i++)
+ {
+ std::cout << consecutive[i].to_ulong() << ' ';
+ BOOST_ASSIGN_V2_CHECK( consecutive[i].to_ulong() == i );
+ }
//]
}
{
//[modulo_fun_deque
+ int i = 0, k = 1;
BOOST_AUTO(
- incr_fact, (
+ factorials, (
as2::deque<int>( as2::_nil ) % (
- as2::_fun = ( lambda::arg_names::arg1 + 1 )
+ as2::_fun = ( lambda::var(k) *= ( lambda::var(i)++ ) )
)
- )/*<<1!, 2!, 3!, 4!, 5!>>*/( 1 )( 2 )( 6 )( 24 )( 120 )
+ )()()()()()
);
- BOOST_ASSIGN_V2_CHECK( incr_fact.front() == ( 2 ) );
- BOOST_ASSIGN_V2_CHECK( incr_fact.back() == ( 121 ) );
+ BOOST_ASSIGN_V2_CHECK( factorials.front() == ( 2 ) );
+ BOOST_ASSIGN_V2_CHECK( factorials.back() == ( 121 ) );
//]
}
Modified: sandbox/assign_v2/libs/assign/v2/test/put/modifier.h
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/modifier.h (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/modifier.h 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -1,9 +1,23 @@
-/*
- * modifier.h
- * assign_v2
- *
- * Created by erwann on 3/7/11.
- * Copyright 2011 __MyCompanyName__. All rights reserved.
- *
- */
+//////////////////////////////////////////////////////////////////////////////
+// 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 LIBS_ASSIGN_V2_TEST_PUT_MODIFIER_ER_2010_H
+#define LIBS_ASSIGN_V2_TEST_PUT_MODIFIER_ER_2010_H
+namespace test_assign_v2{
+namespace xxx_put{
+namespace xxx_modifier{
+
+ void test();
+
+}// xxx_modifier
+}// xxx_put
+}// xxx_test_assign
+
+#endif
Modified: sandbox/assign_v2/libs/assign/v2/test/put/modifier/iterate.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/modifier/iterate.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/modifier/iterate.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -9,17 +9,22 @@
//////////////////////////////////////////////////////////////////////////////
#include <boost/array.hpp>
#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/bind.hpp>
+#include <boost/lambda/construct.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/typeof/typeof.hpp>
+#include <boost/assign/v2/detail/functor/post_increment.hpp>
#include <boost/assign/v2/detail/config/check.hpp>
#include <boost/assign/v2/put/modifier/iterate.hpp>
#include <boost/assign/v2/put/container/put.hpp>
#include <boost/assign/v2/put/deque.hpp>
#include <libs/assign/v2/test/put/modifier/iterate.h>
+#include <iostream>
+
namespace test_assign_v2{
namespace xxx_put{
namespace xxx_modifier{
@@ -31,8 +36,8 @@
namespace lambda = boost::lambda;
{
//[iterate_meta
- typedef as2::functor_aux::post_increment<> arg_;
typedef as2::put_aux::keyword_iterate keyword_;
+ typedef as2::modifier_tag::iterate_arg arg_;
typedef as2::put_aux::modulo_modifier<keyword_, arg_> modulo_;
typedef boost::array<int, 4> cont_;
typedef as2::result_of::put<cont_>::type put_;
@@ -46,22 +51,20 @@
}
{
- // TODO construct arg_ with phoenix and perhaps skip
//[iterate
- typedef as2::functor_aux::post_increment<> arg_;
- typedef int T; boost::array<T, 4> powers; powers[0] = 1; powers[1] = 10;
- ( as2::put( powers ) % ( as2::_iterate = arg_( 2 ) ) )( 100 )( 1000 );
-
- BOOST_ASSIGN_V2_CHECK( powers[0] == 1 );
- BOOST_ASSIGN_V2_CHECK( powers[1] == 10 );
- BOOST_ASSIGN_V2_CHECK( powers[2] == 100 );
- BOOST_ASSIGN_V2_CHECK( powers[3] == 1000 );
+ typedef int T; boost::array<T, 4> consecutive_powers; consecutive_powers[0] = 1; consecutive_powers[1] = 10;
+ int i = 2; ( as2::put( consecutive_powers ) % ( as2::_iterate = lambda::var( i )++ ) )( 100 )( 1000 );
+
+ BOOST_ASSIGN_V2_CHECK( consecutive_powers[0] == 1 );
+ BOOST_ASSIGN_V2_CHECK( consecutive_powers[1] == 10 );
+ BOOST_ASSIGN_V2_CHECK( consecutive_powers[2] == 100 );
+ BOOST_ASSIGN_V2_CHECK( consecutive_powers[3] == 1000 );
//]
}
{
//[iterate_meta_deque
- typedef as2::functor_aux::post_increment<> arg_;
typedef as2::put_aux::keyword_iterate keyword_;
+ typedef as2::modifier_tag::iterate_arg arg_;
typedef as2::put_aux::modulo_modifier<keyword_, arg_> modulo_;
typedef as2::result_of::deque<int>::type put_;
typedef as2::result_of::modulo_modifier<put_> meta1_;
@@ -74,16 +77,18 @@
}
{
//[iterate_deque
- typedef as2::functor_aux::post_increment<> arg_;
+ as2::result_of::deque<int>::type missing_tail = as2::deque<int>( 1 )( 10 )( -1 )( -1 );
+ int i = 2;
+
BOOST_AUTO(
- powers, (
- as2::deque<int>( 1 )( 10 )( -1 )( -1 ) % ( as2::_iterate = arg_( 2 ) )
- ) ( 100 )( 1000 )
+ consecutive_powers,
+ ( missing_tail % ( as2::_iterate = lambda::var( i )++ ) )( 100 )( 1000 )
);
- BOOST_ASSIGN_V2_CHECK( powers[0] == 1 );
- BOOST_ASSIGN_V2_CHECK( powers[1] == 10 );
- BOOST_ASSIGN_V2_CHECK( powers[2] == 100 );
- BOOST_ASSIGN_V2_CHECK( powers[3] == 1000 );
+
+ BOOST_ASSIGN_V2_CHECK( consecutive_powers[0] == 1 );
+ BOOST_ASSIGN_V2_CHECK( consecutive_powers[1] == 10 );
+ BOOST_ASSIGN_V2_CHECK( consecutive_powers[2] == 100 );
+ BOOST_ASSIGN_V2_CHECK( consecutive_powers[3] == 1000 );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/put/modifier/lookup.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/modifier/lookup.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/modifier/lookup.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -53,8 +53,9 @@
//[lookup
typedef std::map<std::string, int> C; C cal;
(
- /*Input is by default mapped to C::value_type but, here, we need C::key_type*/as2::put( cal ) /*Makes the input convertible to C::key_type*/% as2::_identity % ( as2::_lookup = (lambda::_1 = 31) )
- )( "jan" )( "mar" )( "may" )( "jul" )( "aug" )( "oct" )( "dec" );
+ as2::put( cal )/*<<Calls `cal.insert( C::value_type( "feb", 28 ) )`>>*/( "feb", 28 )( "apr", 30 )( "jun", 30 )( "sep", 30 )( "nov", 30 )/*<<Without this parameter, the compiler would complain that the subsequent argument (`"jan"`) is not convertible to `C::key_type`>>*/% ( as2::_fun = lambda::_1 ) % ( as2::_lookup = (lambda::_1 = 31) )
+ )/*<<Calls `cal["jan"] = 31`>>*/( "jan" )( "mar" )( "may" )( "jul" )( "aug" )( "oct" )( "dec" );
+
BOOST_ASSIGN_V2_CHECK( cal["jan"] == 31 );
BOOST_ASSIGN_V2_CHECK( cal["dec"] == 31 );
//]
Modified: sandbox/assign_v2/libs/assign/v2/test/put/modifier/repeat.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/modifier/repeat.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/modifier/repeat.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -25,7 +25,7 @@
namespace as2 = boost::assign::v2;
{
- //[repeat
+ //[repeat_simple
std::vector<int> cont;
( as2::put( cont ) % ( as2::_repeat = 2 ) )( 72 )( 31 )( 48 );
@@ -35,7 +35,7 @@
//]
}
{
- //[repeat_deque
+ //[repeat_simple_deque
BOOST_AUTO(
cont, (
as2::deque<int>( as2::_nil ) % ( as2::_repeat = 2 )
Modified: sandbox/assign_v2/libs/assign/v2/test/put/pipe.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/pipe.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -11,7 +11,7 @@
#include <libs/assign/v2/test/put/pipe/fun.h>
#include <libs/assign/v2/test/put/pipe/modifier.h>
#include <libs/assign/v2/test/put/pipe/put.h>
-#include <libs/assign/v2/test/put/pipe/put_range.h>
+// #include <libs/assign/v2/test/put/pipe/put_range.h>
#include <libs/assign/v2/test/put/pipe.h>
namespace test_assign_v2{
@@ -24,7 +24,7 @@
xxx_fun::test();
xxx_modifier::test();
xxx_put::test();
- xxx_put_range::test();
+ // xxx_put_range::test();
}
}// xxx_pipe
Modified: sandbox/assign_v2/libs/assign/v2/test/put/pipe/fun.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/pipe/fun.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/fun.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -20,30 +20,36 @@
namespace xxx_pipe{
namespace xxx_fun{
+ // TODO check headers
+
void test()
{
namespace as2 = boost::assign::v2;
- namespace lambda = boost::phoenix;
+ namespace lambda = boost::lambda;
{
- //[pipe_modulo_fun
- typedef int int_; std::vector<int_> incr_fact;
- int_ front = (
- incr_fact | ( as2::_put % ( as2::_fun = lambda::arg_names::arg1 + 1 ) )/*<<1!, 2!, 3!, 4!, 5!>>*/( 1 )( 2 )( 6 )( 24 )( 120 )
- ).front();
-
- BOOST_ASSIGN_V2_CHECK( front == 2 );
- BOOST_ASSIGN_V2_CHECK( incr_fact.back() == 121 );
+ //[pipe_modulo_fun_math
+ std::vector<double> exponent; typedef boost::function<double(double)> f_;
+ typedef boost::function<bool(double, double)> g_;
+ double eps = boost::numeric::bounds<double>::smallest();
+ BOOST_ASSIGN_V2_CHECK(
+ boost::range_equal(
+ exponent | ( as2::_put % ( as2::_fun = f_( log10 ) ) )( 1000.0 )( 10.0 )( 10000.0 )( 1.0 )( 100.0 ),
+ as2::csv_deque<double>( 3.0 )( 1.0 )( 4.0 )( 1.0 )( 2.0 ),
+ g_( abs( lambda::_1 - lambda::_2 ) < eps )
+ )
+ );
//]
}
{
//[csv_pipe_modulo_fun
- typedef int int_; std::vector<int_> incr_fact;
- int_ front = (
- incr_fact | ( as2::_csv_put % ( as2::_fun = lambda::arg_names::arg1 + 1 ) )/*<<1!, 2!, 3!, 4!, 5!>>*/( 1, 2, 6, 24, 120 )
- ).front();
-
- BOOST_ASSIGN_V2_CHECK( front == 2 );
- BOOST_ASSIGN_V2_CHECK( incr_fact.back() == 121 );
+ int i = 0, k = 1; std::list<int> factorials;
+ BOOST_ASSIGN_V2_CHECK(
+ boost::range_equal(
+ factorials | (
+ as2::_csv_put % ( as2::_fun = ( lambda::var(k) *= ( lambda::var(i)++ ) ) )
+ )()()()()(),
+ as2::csv_deque<int>( 2 )( 6 )( 24 )( 120 )
+ );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/iterate.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/iterate.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/iterate.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -29,16 +29,16 @@
// TODO construct arg_ with phoenix and perhaps skip
//[iterate
- typedef as2::functor_aux::post_increment<> arg_;
- typedef int T; boost::array<T, 4> powers; powers[0] = 1; powers[1] = 10;
- T front = (
- powers | ( as2::_put % ( as2::_iterate = arg_( 2 ) ) )( 100 )( 1000 )
- ).front();
+ //typedef as2::functor_aux::post_increment<> arg_;
+ //typedef int T; boost::array<T, 4> powers; powers[0] = 1; powers[1] = 10;
+ //T front = (
+ // powers | ( as2::_put % ( as2::_iterate = arg_( 2 ) ) )( 100 )( 1000 )
+ //).front();
- BOOST_ASSIGN_V2_CHECK( front == 1 );
- BOOST_ASSIGN_V2_CHECK( powers[1] == 10 );
- BOOST_ASSIGN_V2_CHECK( powers[2] == 100 );
- BOOST_ASSIGN_V2_CHECK( powers[3] == 1000 );
+ //BOOST_ASSIGN_V2_CHECK( front == 1 );
+ //BOOST_ASSIGN_V2_CHECK( powers[1] == 10 );
+ //BOOST_ASSIGN_V2_CHECK( powers[2] == 100 );
+ //BOOST_ASSIGN_V2_CHECK( powers[3] == 1000 );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/lookup.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/lookup.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/lookup.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -9,9 +9,7 @@
//////////////////////////////////////////////////////////////////////////////
#include <map>
#include <string>
-#include <cmath>
#include <boost/lambda/lambda.hpp>
-#include <boost/tuple/tuple.hpp>
#include <boost/assign/v2/detail/config/check.hpp>
#include <boost/assign/v2/detail/functor/identity.hpp>
@@ -32,18 +30,15 @@
namespace lambda = boost::lambda;
{
//[lookup
- typedef std::map<std::string, int> C; C cal;
- C::mapped_type n_mar = (
- cal | as2::_put( "feb", 28 )
- | ( /*Input is by default mapped to C::value_type but, here, we need C::key_type*/ as2::_put % /*Makes the input convertible to C::key_type*/as2::_identity % ( as2::_lookup = (lambda::_1 = 31) ) )( "jan" )( "mar" )( "may" )( "jul" )( "aug" )( "oct" )( "dec" )
- | ( as2::_put % as2::_identity % ( as2::_lookup = (lambda::_1 = 30) ) )( "apr" )( "jun" )( "sep" )( "nov" )
- )["mar"];
-
- BOOST_ASSIGN_V2_CHECK( n_mar == 31 );
- BOOST_ASSIGN_V2_CHECK( cal["jan"] == 31 );
- BOOST_ASSIGN_V2_CHECK( cal["dec"] == 31 );
- BOOST_ASSIGN_V2_CHECK( cal["apr"] == 30 );
- BOOST_ASSIGN_V2_CHECK( cal["nov"] == 30 );
+ typedef std::string str_; std::map<std::string, int> C; C cal;
+ BOOST_AUTO( _local, ( as2::_csv_put % ( as2::_fun = lambda::_1 ) ) );
+ BOOST_ASSIGN_V2_CHECK(
+ (
+ cal | as2::_put( "feb", 28 ) | ( _local % as2::_lookup = (lambda::_1 = 30) )( "apr" )( "jun" )( "sep" )( "nov" )
+ | ( _local % as2::_lookup = (lambda::_1 = 31) )( "jan" )( "mar" )( "may" )( "jul" )( "aug" )( "oct" )( "dec" )
+ )[ "mar" ] == 31
+ );
+ BOOST_ASSIGN_V2_CHECK( cal[ "jun" ] == 30 );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/repeat.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/repeat.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/modifier/repeat.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -27,13 +27,12 @@
{
//[repeat
std::vector<int> cont;
- int front = (
- cont | ( as2::_put % ( as2::_repeat = 2 ) )( 72 )( 31 )( 48 )
- ).front();
-
- BOOST_ASSIGN_V2_CHECK( cont.size() == 6 );
- BOOST_ASSIGN_V2_CHECK( front == 72 );
- BOOST_ASSIGN_V2_CHECK( cont.back() == 48 );
+ BOOST_ASSIGN_V2_CHECK(
+ boost::range_equal(
+ cont | ( as2::_put % ( as2::_repeat = 2 ) )( 72 )( 31 )( 48 )
+ ),
+ as2::csv_deque<int>( 72, 72, 31, 31, 48, 48 )
+ );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -18,6 +18,7 @@
#include <boost/assign/v2/detail/config/check.hpp>
#include <boost/assign/v2/put/pipe/put.hpp>
#include <boost/assign/v2/put/pipe/csv_put.hpp>
+#include <boost/range/algorithm/for_each.hpp>
#include <libs/assign/v2/test/put/pipe/put.h>
@@ -38,61 +39,25 @@
BOOST_ASSIGN_V2_CHECK( str_( cont[1] ) == "y" );
BOOST_ASSIGN_V2_CHECK( str_( cont[2] ) == "z" );
}
+/*
{
+ // TODO put in mix or chain
//[pipe_array
- const int sz = 3;
- typedef boost::array<int, sz> r_;
- boost::array<r_, sz> matrix3x3;
-
- {
- r_ r0, r1, r2;
- int front = ( /*Calls [^r0[i] = j] for [^( i, j ) = ( 0, 1 ), ( 1, 2 ), ( 2, 3 ) ] and returns r0*/ r0 | as2::_put( 1 )( 2 )( 3 ) ).front();
- int back = r0.back();
- r2 | as2::_put( 7 )( 8 )( 9 );
- r_ r = (
- matrix3x3 | as2::_put
- ( r0 )
- ( /*<<`r1` modified on the fly>>*/r1 | as2::_put( 4 )( 5 )( 6 ) )
- ( r2 )
- )[1];
-
- BOOST_ASSIGN_V2_CHECK( front == 1 );
- BOOST_ASSIGN_V2_CHECK( back == 3 );
- BOOST_ASSIGN_V2_CHECK( r == r1 );
- }
- for(int i = 0; i < 9; i++)
- {
- BOOST_ASSIGN_V2_CHECK( matrix3x3[ i / 3 ][ i % 3 ] == i + 1 );
- }
+ boost::array<int, 3> first3;
+ boost::array<int, 5> all5;
+ int i = first3.size() - 1;
+ (
+ put( all5 )(
+ as_arg_list( first3 | _csv_put( v, w ) )
+ ) % _iterate = var(i)++
+ )( x, y, z );
+
+ put( all5 )(
+ as_arg_list( first3 | _csv_put( v, w ) && csv_array( x, y, z ) )
+ );
//]
}
- {
- //[pipe_seq_var_args
- typedef double elem_; typedef std::list<elem_> r_; typedef std::vector<r_> ragged_array_;
- r_ a, b; elem_ front, back;
- front = ( a | as2::_put( 0.71 )( 0.63 )( 0.85 ) ).front();
- back = a.back();
-
- ragged_array_ ragged_array;
- r_ r = (
- ragged_array | as2::_put
- ( a )
- ( /*<<`b` modified on the fly>>*/ b | as2::_put( 0.61 )( 0.69 )( 0.92 )( 0.55 ) )
- ( 1, -99.99 )
- ( )
- )[2];
-
- elem_ eps = boost::numeric::bounds<elem_>::smallest();
- BOOST_ASSIGN_V2_CHECK( abs( front - 0.71 ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( back - 0.85 ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( r.front() + 99.0 ) < eps );
- BOOST_ASSIGN_V2_CHECK( abs( r.back() + 99.0 ) < eps );
- //]
- BOOST_ASSIGN_V2_CHECK( ragged_array[0].size() == a.size() );
- BOOST_ASSIGN_V2_CHECK( ragged_array[1].size() == b.size() );
- BOOST_ASSIGN_V2_CHECK( ragged_array[2].size() == 1 );
- BOOST_ASSIGN_V2_CHECK( ragged_array[3].size() == 0 );
- }
+*/
{
using namespace boost;
//[pipe_seq_ref_tuple
Modified: sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.cpp 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -1,62 +1 @@
-////////////////////////////////////////////////////////////////////////////
-// 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 <stack>
-#include <vector>
-#include <deque>
-#include <boost/array.hpp>
-#include <boost/tuple/tuple.hpp>
-#include <boost/assign/v2/detail/config/check.hpp>
-#include <boost/assign/v2/put/pipe/range.hpp>
-#include <boost/assign/v2/put/container/put.hpp>
-#include <libs/assign/v2/test/put/pipe/put_range.h>
-
-namespace test_assign_v2{
-namespace xxx_put{
-namespace xxx_pipe{
-namespace xxx_put_range{
-
- void test()
- {
- namespace as2 = boost::assign::v2;
-
-
- {
- //[pipe_range_assign
- typedef const char state_ [3]; state_ ct = "CT", nj = "NJ", ny = "NY", ca = "CA", /* ore = "OR",*/ wa = "WA";
- typedef int code_; typedef boost::tuple<state_/*<<Notice the reference>>*/&, code_> area_code_;
- std::deque< area_code_ > tri_state; as2::put( tri_state )( nj, 201 )( ct, 203 )( ny, 212 )( ny, 315 )( ny, 347 )( nj, 551 );
- std::deque< area_code_ > pacific ; as2::put( pacific )( wa, 206 )( ca, 209 )( ca, 213 )( wa, 253 );
-
- std::deque< area_code_ > states; states | as2::_put_range( tri_state ) | as2::_put_range( pacific );
-
- using namespace boost;
- BOOST_ASSIGN_V2_CHECK( get<0>( states.front() ) == nj );
- BOOST_ASSIGN_V2_CHECK( get<1>( states.front() ) == 201 );
- BOOST_ASSIGN_V2_CHECK( get<0>( states[tri_state.size()-1] ) == nj );
- BOOST_ASSIGN_V2_CHECK( get<1>( states[tri_state.size()-1] ) == 551 );
- BOOST_ASSIGN_V2_CHECK( get<0>( states[tri_state.size()] ) == wa );
- BOOST_ASSIGN_V2_CHECK( get<1>( states[tri_state.size()] ) == 206 );
- BOOST_ASSIGN_V2_CHECK( get<0>( states.back() ) == wa );
- BOOST_ASSIGN_V2_CHECK( get<1>( states.back() ) == 253 );
- //]
- }
- {
- //[pipe_range_constr
- std::vector<int> r( 3 ); r[0] = 72; r[1] = 31; r[2] = 48;
-
- BOOST_ASSIGN_V2_CHECK( ( ::boost::type< std::stack<int> >() | as2::_put_range( r ) ).top() == 48 );
- //]
- }
- }
-
-}// xxx_put_range
-}// xxx_pipe
-}// xxx_put
-}// test_assign_v2
+// TODO remove file
Modified: sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.h
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.h (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.h 2011-03-10 17:19:27 EST (Thu, 10 Mar 2011)
@@ -1,25 +1 @@
-//////////////////////////////////////////////////////////////////////////////
-// 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 LIBS_ASSIGN_V2_TEST_PUT_PIPE_PUT_RANGE_ER_2010_H
-#define LIBS_ASSIGN_V2_TEST_PUT_PIPE_PUT_RANGE_ER_2010_H
-
-namespace test_assign_v2{
-namespace xxx_put{
-namespace xxx_pipe{
-namespace xxx_put_range{
-
- void test();
-
-}// xxx_put_range
-}// xxx_pipe
-}// xxx_put
-}// test_assign_v2
-
-#endif
+// TODO remove file
\ No newline at end of file
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