|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70804 - in sandbox/assign_v2: boost/assign/v2/detail/functor boost/assign/v2/option boost/assign/v2/pipe libs/assign/v2 libs/assign/v2/src libs/assign/v2/test libs/assign/v2/test/option libs/assign/v2/test/pipe/option libs/assign/v2/test/put libs/assign/v2/test/ref libs/assign/v2/test/unit_testing
From: erwann.rogard_at_[hidden]
Date: 2011-03-31 22:37:48
Author: e_r
Date: 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
New Revision: 70804
URL: http://svn.boost.org/trac/boost/changeset/70804
Log:
upd assign_v2
Text files modified:
sandbox/assign_v2/boost/assign/v2/detail/functor/pair.hpp | 6 +-
sandbox/assign_v2/boost/assign/v2/option/data_generator.hpp | 15 +++++++
sandbox/assign_v2/boost/assign/v2/pipe/csv_put.hpp | 24 ++++++------
sandbox/assign_v2/libs/assign/v2/src/main.cpp | 2 -
sandbox/assign_v2/libs/assign/v2/test/chain.cpp | 39 ++++++++++++++++---
sandbox/assign_v2/libs/assign/v2/test/conversion.cpp | 30 ++++++++-------
sandbox/assign_v2/libs/assign/v2/test/csv.cpp | 38 +++++++++++++++----
sandbox/assign_v2/libs/assign/v2/test/deque.cpp | 20 +++++-----
sandbox/assign_v2/libs/assign/v2/test/option/data.cpp | 25 +++++++++++-
sandbox/assign_v2/libs/assign/v2/test/option/iterate.cpp | 40 +++++++++++++++----
sandbox/assign_v2/libs/assign/v2/test/option/repeat.cpp | 12 ++++--
sandbox/assign_v2/libs/assign/v2/test/option/std_modifier.cpp | 22 +++-------
sandbox/assign_v2/libs/assign/v2/test/pipe/option/iterate.cpp | 13 ++++--
sandbox/assign_v2/libs/assign/v2/test/pipe/option/repeat.cpp | 4 +-
sandbox/assign_v2/libs/assign/v2/test/pipe/option/std_modifier.cpp | 12 +++---
sandbox/assign_v2/libs/assign/v2/test/put/ptr.cpp | 30 ++++++++------
sandbox/assign_v2/libs/assign/v2/test/put/put.cpp | 72 +++++++++++++++++++-----------------
sandbox/assign_v2/libs/assign/v2/test/ref/array.cpp | 4 +-
sandbox/assign_v2/libs/assign/v2/test/ref/csv_array.cpp | 8 ++--
sandbox/assign_v2/libs/assign/v2/test/ref/wrapper.cpp | 2
sandbox/assign_v2/libs/assign/v2/test/unit_testing/Jamfile.v2 | 1
sandbox/assign_v2/libs/assign/v2/tutorial.cpp | 78 ++++++++++++++++++++++-----------------
22 files changed, 309 insertions(+), 188 deletions(-)
Modified: sandbox/assign_v2/boost/assign/v2/detail/functor/pair.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/detail/functor/pair.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/detail/functor/pair.hpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -28,9 +28,9 @@
namespace functor_aux{
template<
- typename T // Value
- , typename K // Key
- , typename M // Mapped
+ typename T // Value
+ , typename K // Key
+ , typename M // Mapped
>
class pair/*<-*/
#if !BOOST_ASSIGN_V2_ENABLE_CPP0X
Modified: sandbox/assign_v2/boost/assign/v2/option/data_generator.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/option/data_generator.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/option/data_generator.hpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -120,6 +120,21 @@
}/*->*/;
+ template<>
+ struct option_data_generator<keyword_aux::value>/*<-*/
+ {
+ option_data_generator(){}
+ option_data_generator(keyword_aux::ignore){}
+
+ template<typename C>
+ typename deduce_value_generator<C>::type
+ data_generator()const
+ {
+ return typename deduce_value_generator<C>::type();
+ }
+
+ }/*->*/;
+
// Overrides data generator
template<typename C, typename F, typename ModifierTag
, typename DataTag, typename D, typename F1>
Modified: sandbox/assign_v2/boost/assign/v2/pipe/csv_put.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/pipe/csv_put.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/pipe/csv_put.hpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -90,12 +90,22 @@
return result_( *this, option );
}
- template<arg_list_size_type N, typename U = na_> // size?
+ template<arg_list_size_type N, typename U = na_>
struct result{
typedef interpreter_aux::arg_list<Head, Tail, N, U> type;
};
+
+ typename result<0>::type
+ operator()()const
+ {
+ typedef typename result<0>::type result_;
+ return result_(
+ *this,
+ ref::csv_array<na_>( _nil )
+ );
+ }
-#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
protected:
template<typename T, typename...Args>
@@ -128,16 +138,6 @@
#else
- typename result<0>::type
- operator()()const
- {
- typedef typename result<0>::type result_;
- return result_(
- *this,
- ref::csv_array<na_>( _nil )
- );
- }
-
#define BOOST_ASSIGN_V2_MACRO1(N, U)\
return result_( \
*this, \
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-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -8,7 +8,6 @@
// Test
#include <libs/assign/v2/test/chain.h>
#include <libs/assign/v2/test/conversion.h>
-#include <libs/assign/v2/test/csv.h>
#include <libs/assign/v2/test/detail.h>
#include <libs/assign/v2/test/deque.h>
#include <libs/assign/v2/test/interpreter.h>
@@ -66,7 +65,6 @@
using namespace test_assign_v2;
xxx_chain::test();
xxx_conversion::test();
- xxx_csv::test();
xxx_detail::test();
xxx_deque::test();
xxx_interpreter::test();
Modified: sandbox/assign_v2/libs/assign/v2/test/chain.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/chain.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/chain.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -43,7 +43,11 @@
typedef std::string T;
array<T, 2> head; head[0] = "A"; head[1] = "B";
std::list<T> tail; tail.push_back( "C" ); tail.push_back( "D" );
- std::vector<T> joined; copy( head | as2::_chain( tail ), std::back_inserter( joined ) );
+ std::vector<T> joined;
+ copy(
+ head | as2::_chain( tail ),
+ std::back_inserter( joined )
+ );
BOOST_ASSIGN_V2_CHECK(
range::equal( joined, as2::csv_deque<T>("A", "B", "C", "D") )
@@ -56,10 +60,24 @@
words[0] = "foo"; words[1] = "bar"; words[2] = "baz";
words[3] = "qux"; words[4] = "quux"; words[5] = "grault";
array<word, 3> head; std::list<word> tail( 3 );
- copy( words,boost::begin( head | as2::_chain( tail ) ) );
+
+ copy(
+ words,
+ boost::begin( head | as2::_chain( tail ) )
+ );
- BOOST_ASSIGN_V2_CHECK( range::equal( head, as2::csv_deque<word>( "foo", "bar", "baz" ) ) );
- BOOST_ASSIGN_V2_CHECK( range::equal( tail, as2::csv_deque<word>( "qux", "quux", "grault" ) ) );
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal(
+ head,
+ as2::csv_deque<word>( "foo", "bar", "baz" )
+ )
+ );
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal(
+ tail,
+ as2::csv_deque<word>( "qux", "quux", "grault" )
+ )
+ );
//]
}
// Boost.Assign.v2 containers
@@ -69,13 +87,20 @@
std::vector<int> iota8( 8 );
for(int i = 0; i < 8; i++){ iota8[i] = 1 + i; }
array<int, 5> iota5; int six, seven, eight;
+
boost::copy(
iota8,
- boost::begin( iota5 && (/*<< rvalue! >>*/ as2::ref::csv_array( six, seven, eight ) | as2::ref::_get ) )
+ boost::begin(
+ iota5 && (/*<< rvalue! >>*/ as2::ref::csv_array( six, seven, eight ) | as2::ref::_get )
+ )
);
- BOOST_ASSIGN_V2_CHECK( range::equal( iota5, as2::csv_deque( 1, 2, 3, 4, 5 ) ) );
- BOOST_ASSIGN_V2_CHECK( six == 6 ); BOOST_ASSIGN_V2_CHECK( seven == 7 ); BOOST_ASSIGN_V2_CHECK( eight == 8 );
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal( iota5, as2::csv_deque( 1, 2, 3, 4, 5 ) )
+ );
+ BOOST_ASSIGN_V2_CHECK( six == 6 );
+ BOOST_ASSIGN_V2_CHECK( seven == 7 );
+ BOOST_ASSIGN_V2_CHECK( eight == 8 );
//]
}
Modified: sandbox/assign_v2/libs/assign/v2/test/conversion.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/conversion.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/conversion.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -40,24 +40,24 @@
// External containers (fully qualified)
{
//[test_conversion_vec_array
- std::vector<int> r( 3 ); r[0] = 72; r[1] = 31; r[2] = 48;
+ std::vector<int> r( 3 ); r[0] = 1 ; r[1] = 10; r[2] = 100;
typedef array<int, 3> ar_;
ar_ const& ar = ( r | as2::_convert<ar_>() );
- BOOST_ASSIGN_V2_CHECK( range::equal( ar, as2::csv_deque( 72, 31, 48 ) ) );
+ BOOST_ASSIGN_V2_CHECK( range::equal( ar, as2::csv_deque( 1 , 10, 100 ) ) );
//]
}
{
//[test_conversion_vec_stack
- std::vector<int> r( 3 ); r[0] = 72; r[1] = 31; r[2] = 48;
+ std::vector<int> r( 3 ); r[0] = 1 ; r[1] = 10; r[2] = 100;
std::stack<int> lifo = as2::converter( r );
- BOOST_ASSIGN_V2_CHECK( lifo.top() == 48 );
+ BOOST_ASSIGN_V2_CHECK( lifo.top() == 100 );
//]
}
{
//[test_conversion_stl
- typedef int T; typedef std::vector<T> R; R r( 3 ); r[0] = 72; r[1] = 31; r[2] = 48;
+ typedef int T; typedef std::vector<T> R; R r( 3 ); r[0] = 1 ; r[1] = 10; r[2] = 100;
f< std::vector<T> >( as2::converter( r ), r );
f< std::deque<T> >( as2::converter( r ), r );
f< std::list<T> >( as2::converter( r ), r );
@@ -84,32 +84,34 @@
// Boost.Assign.2.0 containers - name lookup
{
//[test_conversion_as2_deque_array
- std::vector<int> r( 3 ); r[0] = 72; r[1] = 31; r[2] = 48;
+ std::vector<int> r( 3 ); r[0] = 1 ; r[1] = 10; r[2] = 100;
typedef array<int, 3> ar_;
- ar_ const& ar = ( as2::csv_deque( 72, 31, 48 ) | as2::_convert<ar_>() );
+ ar_ const& ar = ( as2::csv_deque( 1 , 10, 100 ) | as2::_convert<ar_>() );
- BOOST_ASSIGN_V2_CHECK( range::equal( ar, as2::csv_deque( 72, 31, 48 ) ) );
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal( ar, as2::csv_deque( 1 , 10, 100 ) )
+ );
//]
}
{
//[test_conversion_ref_array_stack
- std::stack<int> lifo = /*<<Notice unqualified (name lookup)>>*/converter( as2::ref::array( 72 )( 31 )( 48 ) );
+ std::stack<int> lifo = /*<<Notice unqualified (name lookup)>>*/converter( as2::ref::array( 1 )( 10 )( 100 ) );
- BOOST_ASSIGN_V2_CHECK( lifo.top() == 48 );
+ BOOST_ASSIGN_V2_CHECK( lifo.top() == 100 );
//]
}
{
//[test_conversion_ref_array_queue
- std::queue<int> fifo = /*<<Notice unqualified (name lookup)>>*/converter( as2::ref::csv_array( 72, 31, 48 ) );
+ std::queue<int> fifo = /*<<Notice unqualified (name lookup)>>*/converter( as2::ref::csv_array( 1 , 10, 100 ) );
- BOOST_ASSIGN_V2_CHECK( fifo.front() == 72 );
+ BOOST_ASSIGN_V2_CHECK( fifo.front() == 1 );
//]
}
{
//[test_conversion_as2_deque_stack
- std::stack<int> lifo = /*<<Notice unqualified (name lookup)>>*/converter( as2::csv_deque( 72, 31, 48 ) );
+ std::stack<int> lifo = /*<<Notice unqualified (name lookup)>>*/converter( as2::csv_deque( 1 , 10, 100 ) );
- BOOST_ASSIGN_V2_CHECK( lifo.top() == 48 );
+ BOOST_ASSIGN_V2_CHECK( lifo.top() == 100 );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/csv.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/csv.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/csv.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -8,10 +8,14 @@
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
//////////////////////////////////////////////////////////////////////////////
#include <deque>
+#include <map>
+#include <string>
#include <boost/assign/v2/detail/config/check.hpp>
#include <boost/assign/v2/csv.hpp>
#include <boost/assign/v2/deque.hpp>
#include <boost/assign/v2/put.hpp>
+// Options come after
+#include <boost/assign/v2/option/data_generator.hpp>
#include <boost/assign/v2/option/modifier/std.hpp>
#include <boost/range/algorithm/equal.hpp>
#include <libs/assign/v2/test/csv.h>
@@ -25,28 +29,46 @@
namespace as2 = assign::v2;
{
//[test_csv_put
- std::deque<int> cont;
- as2::csv( as2::put( cont ), 72, 31, 48 );
+ std::deque<int> cont;
+ as2::csv( as2::put( cont ), 1, 10, 100 );
- BOOST_ASSIGN_V2_CHECK( range::equal( cont, as2::csv_deque( 72, 31, 48 ) ) );
+ BOOST_ASSIGN_V2_CHECK( range::equal( cont, as2::csv_deque( 1, 10, 100 ) ) );
//]
}
{
+ //[test_csv_put_map
+ typedef std::map<std::string, int> C; typedef C::value_type T;
+ C cont;
+
+ as2::csv( as2::put( cont ) % (as2::_data = as2::_value), T("jan", 31), T("feb", 28), T("mar", 31) );
+
+ BOOST_ASSIGN_V2_CHECK( cont["jan"] == 31 );
+ BOOST_ASSIGN_V2_CHECK( cont["mar"] == 31 );
+ //]
+ }
+ {
//[test_csv_put_modulo
std::deque<int> cont;
- as2::csv( as2::put( cont ) % as2::_push_front, 72, 31, 48 );
+ as2::csv( as2::put( cont ) % as2::_push_front, 100, 10, 1 );
- BOOST_ASSIGN_V2_CHECK( range::equal( cont, as2::csv_deque( 48, 31, 72 ) ) );
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal( cont, as2::csv_deque( 1, 10, 100 ) )
+ );
//]
}
{
//[test_csv_deque_modulo
- BOOST_AUTO(
+ BOOST_AUTO(
cont,
- as2::csv( as2::deque<int>( as2::_nil ) % as2::_push_front, 72, 31, 48 )
+ as2::csv(
+ as2::deque<int>( as2::_nil ) % as2::_push_front,
+ 1, 10, 100
+ )
);
- BOOST_ASSIGN_V2_CHECK( range::equal( cont, as2::csv_deque( 48, 31, 72 ) ) );
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal( cont, as2::csv_deque( 1, 10, 100 ) )
+ );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/deque.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/deque.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/deque.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -31,13 +31,13 @@
typedef as2::result_of::deque<int>::type C;
C empty_cont = as2::deque<int>( as2::_nil );
- C cont1 = empty_cont( 72 )( 31 )( 48 );
- C cont2 = as2::deque<int>( 72 )( 31 )( 48 );
+ C cont1 = empty_cont( 1 )( 10 )( 100 );
+ C cont2 = as2::deque<int>( 1 )( 10 )( 100 );
std::deque<int> benchmark;
- benchmark.push_back( 72 );
- benchmark.push_back( 31 );
- benchmark.push_back( 48 );
+ benchmark.push_back( 1 );
+ benchmark.push_back( 10 );
+ benchmark.push_back( 100 );
BOOST_ASSIGN_V2_CHECK( range::equal( benchmark, cont1 ) );
BOOST_ASSIGN_V2_CHECK( range::equal( benchmark, cont2 ) );
@@ -79,13 +79,13 @@
BOOST_MPL_ASSERT(( is_same<C, as2::result_of::deque<int>::type> ));
- C cont1 = as2::csv_deque( 72, 31, 48 );
- C cont2 = as2::csv_deque( 72, 31 )( 48 );
+ C cont1 = as2::csv_deque( 1, 10, 100 );
+ C cont2 = as2::csv_deque( 1, 10 )( 100 );
std::deque<int> benchmark;
- benchmark.push_back( 72 );
- benchmark.push_back( 31 );
- benchmark.push_back( 48 );
+ benchmark.push_back( 1 );
+ benchmark.push_back( 10 );
+ benchmark.push_back( 100 );
BOOST_ASSIGN_V2_CHECK( range::equal( benchmark, cont1 ) );
BOOST_ASSIGN_V2_CHECK( range::equal( benchmark, cont2 ) );
Modified: sandbox/assign_v2/libs/assign/v2/test/option/data.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/option/data.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/option/data.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -10,6 +10,7 @@
#include <cmath> // MSVC #include <math.h>
#include <deque>
#include <list>
+#include <map>
#include <vector>
#include <boost/array.hpp>
#include <boost/assign/v2/detail/config/check.hpp>
@@ -42,11 +43,11 @@
typedef function<double(double)> f_;
(
as2::put( exponent ) % ( as2::_data = f_( /*<-*/fp(/*->*/ log10 /*<-*/)/*->*/ ) )
- )/*<<Equivalent to `as2::put( exponent )( log10( 1000.0 ) )( log10( 10.0 ) )( log10( 10000.0 ) )( log10( 1.0 ) )( log10( 100.0 ) )`>>*/( 1000.0 )( 10.0 )( 10000.0 )( 1.0 )( 100.0 );
+ )( 1.0 )( 10.0 )( 100.0 )( 1000.0 )( 10000.0 );
double eps = numeric::bounds<double>::smallest();
- BOOST_ASSIGN_V2_CHECK( fabs( exponent.front() - 3.0 ) < eps );
- BOOST_ASSIGN_V2_CHECK( fabs( exponent.back() - 2.0 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( fabs( exponent.front() - 0.0 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( fabs( exponent.back() - 4.0 ) < eps );
//]
}
{
@@ -64,6 +65,24 @@
BOOST_ASSIGN_V2_CHECK( range::equal( factorials, as2::csv_deque( 1, 2, 6, 24, 120 ) ) );
//]
}
+ {
+ //[test_option_data_value
+ typedef std::string word_;
+ const char foo[] = "foo";
+ const char bar[4] = { 'b', 'a', 'r', '\0' };
+ word_ baz = "***baz";
+ typedef std::map<int, word_> C;
+ typedef C::value_type T;
+ typedef C::mapped_type D;
+ C map;
+ (
+ as2::put( map ) % ( as2::_data = as2::_value )
+ )( 1, D( foo, 3 ) )( 2, bar )( 3, D( baz, 3, 3 ) )( 4, "qux");
+
+ BOOST_ASSIGN_V2_CHECK( map[1] == "foo" ); BOOST_ASSIGN_V2_CHECK( map[2] == "bar" );
+ BOOST_ASSIGN_V2_CHECK( map[3] == "baz" ); BOOST_ASSIGN_V2_CHECK( map[4] == "qux" );
+ //]
+ }
}
Modified: sandbox/assign_v2/libs/assign/v2/test/option/iterate.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/option/iterate.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/option/iterate.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -7,6 +7,7 @@
// 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 <boost/array.hpp>
#include <boost/assign/v2/detail/config/check.hpp>
@@ -48,10 +49,21 @@
{
//[test_option_iterate_shifted
using namespace lambda;
- typedef int T; array<T, 4> powers; powers[0] = 1; powers[1] = 10;
- int index = 2; ( as2::put( powers ) % ( as2::_iterate = var( index )++ ) )( 100 )( 1000 );
-
- BOOST_ASSIGN_V2_CHECK( range::equal( powers, as2::csv_deque( 1, 10, 100, 1000 ) ) );
+ typedef int T; array<T, 10> alternating;
+ alternating[0] = -1; alternating[1] = +1;
+ alternating[2] = -2;
+
+ int index = 3;
+ (
+ as2::put( alternating ) % ( as2::_iterate = var( index )++ )
+ )( +2 )( -3 )( +3 )( -4 )( +4 )( -5 )( +5 );
+
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal(
+ alternating,
+ as2::csv_deque( -1, +1, -2, +2, -3, +3, -4, +4, -5, +5 )
+ )
+ );
//]
}
{
@@ -69,15 +81,25 @@
{
//[test_option_iterate_shifted_deque
using namespace lambda;
- as2::result_of::deque<int>::type missing_tail = as2::deque<int>( 1 )( 10 )( -1 )( -1 );
- int index = 2;
+
+ as2::result_of::deque<int>::type incomplete
+ = as2::deque<int>( -1 )( +1 )( -2 )
+ ( as2::as_arg_list( std::vector<int>( 7 ) ) );
+ int index = 3;
BOOST_AUTO(
- powers,
- ( missing_tail % ( as2::_iterate = var( index )++ ) )( 100 )( 1000 )
+ alternating ,
+ (
+ incomplete % ( as2::_iterate = var( index )++ )
+ )( +2 )( -3 )( +3 )( -4 )( +4 )( -5 )( +5 )
);
- BOOST_ASSIGN_V2_CHECK( range::equal( powers, as2::csv_deque( 1, 10, 100, 1000 ) ) );
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal(
+ alternating,
+ as2::csv_deque( -1, +1, -2, +2, -3, +3, -4, +4, -5, +5 )
+ )
+ );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/option/repeat.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/option/repeat.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/option/repeat.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -29,9 +29,11 @@
{
//[test_option_repeat_simple
std::vector<int> cont;
- ( as2::put( cont ) % ( as2::_repeat = 2 ) )( 72 )( 31 )( 48 );
+ ( as2::put( cont ) % ( as2::_repeat = 2 ) )( 1 )( 10 )( 100 );
- BOOST_ASSIGN_V2_CHECK( range::equal( cont, as2::csv_deque( 72, 72, 31, 31, 48, 48 ) ) );
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal( cont, as2::csv_deque( 1, 1, 10, 10, 100, 100 ) )
+ );
//]
}
{
@@ -39,10 +41,12 @@
BOOST_AUTO(
cont, (
as2::deque<int>( as2::_nil ) % as2::_push_front % ( as2::_repeat = 2 )
- )( 72 )( 31 )( 48 )
+ )( 1 )( 10 )( 100 )
);
- BOOST_ASSIGN_V2_CHECK( range::equal( cont, as2::csv_deque( 48, 48, 31, 31, 72, 72 ) ) );
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal( cont, as2::csv_deque( 100, 100, 10, 10, 1, 1 ) )
+ );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/option/std_modifier.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/option/std_modifier.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/option/std_modifier.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -72,21 +72,13 @@
);
//]
-
- /*std::deque<double> sqrt2;
- ( as2::put( sqrt2 ) % as2::_push_front )( 1.41421 )( 1.4142 )( 1.414 )( 1.41 );
-
-
- BOOST_ASSIGN_V2_CHECK( boost::lower_bound( sqrt2, 1.41 ) == boost::begin( sqrt2 ) );
- BOOST_ASSIGN_V2_CHECK( boost::upper_bound( sqrt2, 1.41421 ) == boost::end( sqrt2 ) );*/
-
}
{
//[test_option_push
- std::queue<int> fifo; ( as2::put( fifo ) % as2::_push )( 72 )( 31 )( 48 );
+ std::queue<int> fifo; ( as2::put( fifo ) % as2::_push )( 1 )( 10 )( 100 );
- BOOST_ASSIGN_V2_CHECK( fifo.front() == 72 );
- BOOST_ASSIGN_V2_CHECK( fifo.back() == 48 );
+ BOOST_ASSIGN_V2_CHECK( fifo.front() == 1 );
+ BOOST_ASSIGN_V2_CHECK( fifo.back() == 100 );
//]
}
{
@@ -100,9 +92,9 @@
{
//[test_option_push_back
std::list<int> list;
- ( as2::put( list ) % as2::_push_back )( 72 )( 31 )( 48 );
+ ( as2::put( list ) % as2::_push_back )( 1 )( 10 )( 100 );
- BOOST_ASSIGN_V2_CHECK( range::equal( list, as2::csv_deque( 72, 31, 48 ) ) );
+ BOOST_ASSIGN_V2_CHECK( range::equal( list, as2::csv_deque( 1, 10, 100 ) ) );
//]
}
// DEQUE
@@ -120,11 +112,11 @@
{
//[test_option_push_front_deque
BOOST_AUTO(
- powers,
+ two_power_n,
( as2::deque<int>( as2::_nil ) % as2::_push_front )( 16 )( 8 )( 4 )( 2 )( 1 )
);
- BOOST_ASSIGN_V2_CHECK( range::equal( powers, as2::csv_deque( 1, 2, 4, 8, 16 ) ) );
+ BOOST_ASSIGN_V2_CHECK( range::equal( two_power_n, as2::csv_deque( 1, 2, 4, 8, 16 ) ) );
//]
}
}
Modified: sandbox/assign_v2/libs/assign/v2/test/pipe/option/iterate.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/pipe/option/iterate.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/pipe/option/iterate.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -30,14 +30,19 @@
{
//[test_pipe_option_iterate
- typedef int T; boost::array<T, 4> powers; powers[0] = 1; powers[1] = 10;
+ typedef int T;
+ boost::array<T, 10> alternating;
+ alternating[0] = -1; alternating[1] = +1;
+ alternating[2] = -2;
- int i = 2;
+ int i = 3;
using namespace lambda;
BOOST_ASSIGN_V2_CHECK(
boost::range::equal(
- powers | ( as2::_csv_put % ( as2::_iterate = var( i )++ ) )( 100, 1000 ),
- as2::csv_deque<T>( 1, 10, 100, 1000 )
+ alternating | (
+ as2::_csv_put % ( as2::_iterate = var( i )++ )
+ )( +2, -3, +3, -4, +4, -5, +5 ),
+ as2::csv_deque<T>( -1, +1, -2, +2, -3, +3, -4, +4, -5, +5 )
)
);
//]
Modified: sandbox/assign_v2/libs/assign/v2/test/pipe/option/repeat.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/pipe/option/repeat.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/pipe/option/repeat.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -31,8 +31,8 @@
std::vector<int> cont;
BOOST_ASSIGN_V2_CHECK(
range::equal(
- cont | ( as2::_csv_put % ( as2::_repeat = 2 ) )( 72, 31, 48 ),
- as2::csv_deque<int>( 72, 72, 31, 31, 48, 48 )
+ cont | ( as2::_csv_put % ( as2::_repeat = 2 ) )( 1, 10 ,100 ),
+ as2::csv_deque<int>( 1, 1, 10, 10, 100, 100 )
)
);
//]
Modified: sandbox/assign_v2/libs/assign/v2/test/pipe/option/std_modifier.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/pipe/option/std_modifier.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/pipe/option/std_modifier.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -40,22 +40,22 @@
{
//[test_pipe_option_push_front
- std::deque<int> powers; int front = (
- powers | ( as2::_csv_put % as2::_push_front )( 16, 8, 4, 2, 1 )
+ std::deque<int> two_power_n; int front = (
+ two_power_n | ( as2::_csv_put % as2::_push_front )( 16, 8, 4, 2, 1 )
).front();
BOOST_ASSIGN_V2_CHECK( front == 1 );
- BOOST_ASSIGN_V2_CHECK( powers[4] == 16 );
+ BOOST_ASSIGN_V2_CHECK( two_power_n[4] == 16 );
//]
}
{
//[test_pipe_option_push
typedef int int_; std::queue<int_> fifo; int_ front = (
- fifo | ( as2::_csv_put % as2::_push )( 72, 31, 48 )
+ fifo | ( as2::_csv_put % as2::_push )( 1, 10, 100 )
).front();
- BOOST_ASSIGN_V2_CHECK( front == 72 );
- BOOST_ASSIGN_V2_CHECK( fifo.back() == 48 );
+ BOOST_ASSIGN_V2_CHECK( front == 1 );
+ BOOST_ASSIGN_V2_CHECK( fifo.back() == 100 );
//]
}
{
Modified: sandbox/assign_v2/libs/assign/v2/test/put/ptr.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/ptr.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/ptr.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -68,16 +68,15 @@
BOOST_ASSIGN_V2_CHECK( cont.back() == z );
//]
}
- // TODO
{
//[put_ptr_map
typedef std::string key_;
boost::ptr_map<key_, int> assoc;
as2::put( assoc )( "jan", 31 )( "feb", 28 )( "mar", 31 );
- key_ key = "jan";
- //typedef std::auto_ptr<int> auto_;
- //std::pair< const key_, const auto_ > p( key, auto_( new int( 31 ) ) );
- //assoc.base().insert( p );
+
+
+ BOOST_ASSIGN_V2_CHECK( assoc["jan"] == 31 );
+ BOOST_ASSIGN_V2_CHECK( assoc["mar"] == 31 );
//]
}
{
@@ -85,26 +84,31 @@
typedef std::string T; boost::ptr_set<T> assoc;
T x = "isomer", y = "ephemeral", z = "prosaic";
as2::put( assoc )/*<<Calls `assoc.insert( new T( t ) )` for `t` [^=] `x`, `y`, and `z`>>*/( x )( z )( y );
+
BOOST_ASSIGN_V2_CHECK( assoc.count( x ) == 1 );
BOOST_ASSIGN_V2_CHECK( assoc.count( z ) == 1 );
//]
}
- {
+ {
//[test_put_put_unordered_map
- boost::ptr_unordered_map<std::string, int> map;
- as2::put( map )("foo", 1)("bar", 2)("baz", 3);
+ typedef std::string word_;
+ const char foo[] = "foo";
+ const char bar[4] = { 'b', 'a', 'r', '\0' };
+ word_ baz = "***baz";
+ boost::ptr_unordered_map<int, word_> map;
+ as2::put( map )( 1, foo, 3 )( 2, bar )( 3, baz, 3, 3 )( 4, "qux");
- BOOST_ASSIGN_V2_CHECK( map["foo"] == 1 );
- BOOST_ASSIGN_V2_CHECK( map["baz"] == 3 );
+ assert( map[1] == "foo" ); assert( map[2] == "bar" );
+ assert( map[3] == "baz" ); assert( map[4] == "qux" );
//]
}
{
//[test_put_put_unordered_set
boost::ptr_unordered_set<std::string> set;
- as2::put( set )("foo")("bar")("baz");
+ as2::put( set )( "foo" )( "bar" )( "baz" );
- BOOST_ASSIGN_V2_CHECK( set.count("foo") == 1 );
- BOOST_ASSIGN_V2_CHECK( set.count("baz") == 1 );
+ BOOST_ASSIGN_V2_CHECK( set.count( "foo" ) == 1 );
+ BOOST_ASSIGN_V2_CHECK( set.count( "baz" ) == 1 );
//]
}
}// test
Modified: sandbox/assign_v2/libs/assign/v2/test/put/put.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/put/put.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/put/put.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -49,17 +49,17 @@
{
//[test_put_put_bitset
- typedef std::string str_; typedef std::bitset<3> data_;
- /*<<Keep in mind that although `data_( str_( "011" ) )`, for instance, is valid, `consecutive.push_back( str_( "011" ) )` isn't (GCC4.2)>>*/ std::vector<data_> consecutive;
- /*<<Calls `consecutive.push_back( data_( t ) );` for [^t = ]`str_( "000" )`[^, ..., ]`str_( "111" )`>>*/as2::put( consecutive )
+ typedef std::string str_; typedef std::bitset<3> number;
+ /*<<Keep in mind that although `number( str_( "011" ) )`, for instance, is valid, `range_3bit.push_back( str_( "011" ) )` isn't (GCC4.2)>>*/ std::vector<number> range_3bit;
+ /*<<Calls `range_3bit.push_back( number( t ) );` for [^t = ]`str_( "000" )`[^, ..., ]`str_( "111" )`>>*/as2::put( range_3bit )
( str_( "000" ) )( str_( "001" ) )
( str_( "010" ) )( str_( "011" ) )
( str_( "100" ) )( str_( "101" ) )
( str_( "110" ) )( str_( "111" ) );
- for(unsigned i = 0; i < consecutive.size(); i++)
+ for(unsigned i = 0; i < range_3bit.size(); i++)
{
- BOOST_ASSIGN_V2_CHECK( consecutive[i].to_ulong() == i );
+ BOOST_ASSIGN_V2_CHECK( range_3bit[i].to_ulong() == i );
}
//]
// unsigned i else warning comparison between signed & unsigned
@@ -67,28 +67,28 @@
{
//[test_put_put_numeric_kb
std::vector<int> numeric( 10 ); iota( numeric, 0 ); typedef std::string str_;
- typedef variant< int, str_ > data_; array<data_, 16> numeric_kb;
- as2::put( numeric_kb )
- /*<<Calls `numeric_kb[ i ] = data_( t )` for [^( i, t ) = ( 0, "+" ), ..., ( 5, "." )]>>*/( "+" )( "-" )( "*" )( "/" )( "=" )( "." )
- /*<<Calls `numeric_kb[ 6 + i ] = data_( *( b + i ) )` for [^i = 0, ..., 9] and [^b =] `boost::begin( numeric )`>>*/( as2::as_arg_list( numeric ) );
+ typedef variant< int, str_ > key_; array<key_, 16> keypad;
+ as2::put( keypad )
+ /*<<Calls `keypad[ i ] = key_( t )` for [^( i, t ) = ( 0, "+" ), ..., ( 5, "." )]>>*/( "+" )( "-" )( "*" )( "/" )( "=" )( "." )
+ /*<<Calls `keypad[ 6 + i ] = key_( *( b + i ) )` for [^i = 0, ..., 9] and [^b =] `boost::begin( numeric )`>>*/( as2::as_arg_list( numeric ) );
- BOOST_ASSIGN_V2_CHECK( get<str_>( numeric_kb.front() ) == "+" );
- BOOST_ASSIGN_V2_CHECK( get<int>( numeric_kb.back() ) == 9 );
+ BOOST_ASSIGN_V2_CHECK( get<str_>( keypad.front() ) == "+" );
+ BOOST_ASSIGN_V2_CHECK( get<int>( keypad.back() ) == 9 );
//]
- BOOST_ASSIGN_V2_CHECK( get<str_>( numeric_kb[ 5 ] ) == "." );
- BOOST_ASSIGN_V2_CHECK( get<int>( numeric_kb[ 6 ] ) == 0 );
+ BOOST_ASSIGN_V2_CHECK( get<str_>( keypad[ 5 ] ) == "." );
+ BOOST_ASSIGN_V2_CHECK( get<int>( keypad[ 6 ] ) == 0 );
}
{
//[test_put_put_ragged
- 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( 4 ); b[0] = 0.61; b[1] = 0.69; b[2] = 0.92; b[3] = 0.55;
- array<variable_size_, 4> ragged;
+ typedef double data_; typedef std::vector<data_> uneven_;
+ uneven_ a( 3 ); a[0] = 0.71; a[1] = 0.63; a[2] = 0.85;
+ uneven_ b( 4 ); b[0] = 0.61; b[1] = 0.69; b[2] = 0.92; b[3] = 0.55;
+ array<uneven_, 4> ragged;
as2::put( ragged )
- /*<<Calls `ragged.push_back( variable_size_( begin( a ), 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_( ) )`>>*/( );
+ /*<<Calls `ragged.push_back( uneven_( begin( a ), end( a ) ) )`>>*/( boost::begin( a ), boost::end( a ) )
+ /*<<Calls `ragged.push_back( uneven_( b ) )`>>*/( b )
+ /*<<Calls `ragged.push_back( uneven_( 1, -99.99 ) )`>>*/( 1, -99.99 )
+ /*<<Calls `ragged.push_back( uneven_( ) )`>>*/( );
BOOST_ASSIGN_V2_CHECK( ragged[0].size() == a.size() );
BOOST_ASSIGN_V2_CHECK( ragged[3].size() == 0 );
@@ -123,32 +123,36 @@
// http://bioinfo.mbb.yale.edu/~mbg/dom/fun3/area-codes/
//[test_put_put_area_codes
typedef const char us_state_ [3]; us_state_ ct = "CT", nj = "NJ", ny = "NY";
- typedef int area_code_; typedef tuple<us_state_/*<<Notice the [*reference]>>*/&, area_code_> data_; std::deque< data_ > tri_state_area;
+ typedef int area_code_; typedef tuple<us_state_/*<<Notice the [*reference]>>*/&, area_code_> data_; std::deque< data_ > region;
/*<<Calls `tri_state.push_back( data_( s, c ) )` for [^( s, c ) =( ny, 212 )...( ct, 203 )]>>*/
- as2::put( tri_state_area )( ny, 212 )( ny, 718 )( ny, 516 )( ny, 914 )( nj, 210 )( nj, 908 )( nj, 609 )( ct, 203 );
+ as2::put( region )( 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.back() ) == 203 );
+ BOOST_ASSIGN_V2_CHECK( get<0>( region.front() ) == ny );
+ BOOST_ASSIGN_V2_CHECK( get<1>( region.back() ) == 203 );
//]
- 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>( region.front() ) == 212 );
+ BOOST_ASSIGN_V2_CHECK( get<0>( region.back() ) == ct );
}
{
//[test_put_put_unordered_map
- boost::unordered_map<std::string, int> map;
- as2::put( map )("foo", 1)("bar", 2)("baz", 3);
+ typedef std::string word_;
+ const char foo[] = "foo";
+ const char bar[4] = { 'b', 'a', 'r', '\0' };
+ word_ baz = "***baz";
+ boost::unordered_map<int, word_> map;
+ as2::put( map )/*<<Calls `map.insert( 1, str_( foo, 3 ) )`>>*/( 1, foo, 3 )( 2, bar )( 3, baz, 3, 3 )( 4, "qux");
- BOOST_ASSIGN_V2_CHECK( map["foo"] == 1 );
- BOOST_ASSIGN_V2_CHECK( map["baz"] == 3 );
+ assert( map[1] == "foo" ); assert( map[2] == "bar" );
+ assert( map[3] == "baz" ); assert( map[4] == "qux" );
//]
}
{
//[test_put_put_unordered_set
boost::unordered_set<std::string> set;
- as2::put( set )("foo")("bar")("baz");
+ as2::put( set )( "foo" )( "bar" )( "baz" );
- BOOST_ASSIGN_V2_CHECK( set.count("foo") == 1 );
- BOOST_ASSIGN_V2_CHECK( set.count("baz") == 1 );
+ BOOST_ASSIGN_V2_CHECK( set.count( "foo" ) == 1 );
+ BOOST_ASSIGN_V2_CHECK( set.count( "baz" ) == 1 );
//]
}
{
Modified: sandbox/assign_v2/libs/assign/v2/test/ref/array.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/ref/array.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/ref/array.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -31,11 +31,11 @@
{
//[test_ref_array_temporaries
boost::array<int, 3> ar;
- ar[0] = 72; ar[1] = 31; ar[2] = 48;
+ ar[0] = 1; ar[1] = 10; ar[2] = 100;
BOOST_ASSIGN_V2_CHECK(
range::equal(
- as2::ref::array( 72 )( 31 )( 48 ),
+ as2::ref::array( 1 )( 10 )( 100 ),
ar
)
)/*<<Temporaries destroyed past semicolon>>*/;
Modified: sandbox/assign_v2/libs/assign/v2/test/ref/csv_array.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/ref/csv_array.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/ref/csv_array.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -29,11 +29,11 @@
{
//[test_ref_csv_array_temporaries
boost::array<int, 3> ar;
- ar[0] = 72; ar[1] = 31; ar[2] = 48;
+ ar[0] = 1; ar[1] = 10; ar[2] = 100;
BOOST_ASSIGN_V2_CHECK(
range::equal(
- as2::ref::csv_array( 72, 31, 48 ),
+ as2::ref::csv_array( 1, 10, 100 ),
ar
)
)/*<<Temporaries destroyed past semicolon>>*/;
@@ -42,7 +42,7 @@
{
//[test_ref_csv_array_read
typedef int const T;
- T x = 72, y = 31, z = 48;
+ T x = 1, y = 10, z = 100;
as2::ref::nth_result_of::csv_array<3, T>::type ar
= as2::ref::csv_array( x, y, z );
/*<-*/{/*->*/
@@ -69,7 +69,7 @@
{
//[test_ref_csv_array_write
typedef int T; T x, y, z;
- std::vector<T> r( 3 ); r[0] = 72; r[1] = 31; r[2] = 48;
+ std::vector<T> r( 3 ); r[0] = 1; r[1] = 10; r[2] = 100;
boost::copy( r,boost::begin( as2::ref::csv_array( x, y, z ) | as2::ref::_get ) );
BOOST_ASSIGN_V2_CHECK( x == r[0] );
Modified: sandbox/assign_v2/libs/assign/v2/test/ref/wrapper.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/ref/wrapper.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/test/ref/wrapper.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -29,7 +29,7 @@
w.assign( b ); BOOST_ASSIGN_V2_CHECK( a == b );
w = c; BOOST_ASSIGN_V2_CHECK( a == c );
}
- {
+ {
typedef as2::ref::copy_wrapper<val_ const>::type w_;
w_ w;
val_ a = 1;
Modified: sandbox/assign_v2/libs/assign/v2/test/unit_testing/Jamfile.v2
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/test/unit_testing/Jamfile.v2 (original)
+++ sandbox/assign_v2/libs/assign/v2/test/unit_testing/Jamfile.v2 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -18,7 +18,6 @@
test-suite assign :
[ assign-test chain ]
[ assign-test conversion ]
- [ assign-test csv ]
[ assign-test deque ]
[ assign-test detail ]
[ assign-test interpreter ]
Modified: sandbox/assign_v2/libs/assign/v2/tutorial.cpp
==============================================================================
--- sandbox/assign_v2/libs/assign/v2/tutorial.cpp (original)
+++ sandbox/assign_v2/libs/assign/v2/tutorial.cpp 2011-03-31 22:37:46 EDT (Thu, 31 Mar 2011)
@@ -37,23 +37,13 @@
//[tutorial_assign
std::vector<int> numeric( 10 ); iota( numeric, 0 );
typedef std::string str_; typedef variant< int, str_ > data_;
- array<data_, 16> numeric_keyboard;
- put( numeric_keyboard )
+ array<data_, 16> keypad;
+ put( keypad )
( "+" )( "-" )( "*" )( "/" )( "=" )( "." )
( as_arg_list( numeric ) );
- assert( get<str_>( numeric_keyboard.front() ) == "+" );
- assert( get<int>( numeric_keyboard.back() ) == 9 );
- //]
- }
- {
- //[tutorial_ptr_container
- typedef std::string T; ptr_set<T> assoc;
- T x = "isomer", y = "ephemeral", z = "prosaic";
- /*<<Calls `assoc.insert( new T( t ) )` for [^t = x, y, z]>>*/csv( put( assoc ), x, z, y );
-
- assert( assoc.count( x ) == 1 );
- assert( assoc.count( z ) == 1 );
+ assert( get<str_>( keypad.front() ) == "+" );
+ assert( get<int>( keypad.back() ) == 9 );
//]
}
{
@@ -75,8 +65,20 @@
//]
}
{
+ //[tutorial_ptr_container
+ typedef std::string T; ptr_set<T> assoc;
+ T x = "isomer", y = "ephemeral", z = "prosaic";
+ /*<<Calls `assoc.insert( new T( t ) )` for [^t = x, y, z]>>*/
+ assoc | _csv_put( x, z, y );
+
+ assert( assoc.count( x ) == 1 );
+ assert( assoc.count( z ) == 1 );
+ //]
+ }
+ {
//[tutorial_chain
- std::vector<int> iota8( 8 ); for(int i = 0; i < 8; i++){ iota8[i] = 1 + i; }
+ std::vector<int> iota8( 8 );
+ for(int i = 0; i < 8; i++){ iota8[i] = 1 + i; }
array<int, 5> iota5; int six, seven, eight;
boost::copy(
iota8,
@@ -85,25 +87,29 @@
)
);
- assert( range::equal( iota5, csv_deque(1, 2, 3, 4, 5) ) );
- assert( six == 6 ); assert( seven == 7 ); assert( eight == 8 );
+ assert(
+ range::equal( iota5, csv_deque(1, 2, 3, 4, 5) )
+ );
+ assert( six == 6 );
+ assert( seven == 7 );
+ assert( eight == 8 );
//]
}
{
//[tutorial_conversion
- std::queue<int> fifo = converter( csv_deque( 72, 31, 48 ) );
+ std::queue<int> fifo = converter( csv_deque( 1, 10, 100 ) );
- assert( fifo.front() == 72 ); assert( fifo.back() == 48 );
+ assert( fifo.front() == 1 ); assert( fifo.back() == 100 );
//]
}
{
//[tutorial_data_gen
- typedef std::string str_;
+ typedef std::string word_;
const char foo[] = "foo";
const char bar[4] = { 'b', 'a', 'r', '\0' };
- str_ baz = "***baz***";
- std::map<int, str_> map;
- put( map )( 1, foo, 3 )( 2, bar )( 3, baz, 3, 3 )( 4, "qux");
+ word_ baz = "***baz";
+ std::map<int, word_> map;
+ put( map )/*<<Calls `map.insert( 1, str_( foo, 3 ) )`>>*/( 1, foo, 3 )( 2, bar )( 3, baz, 3, 3 )( 4, "qux");
assert( map[1] == "foo" ); assert( map[2] == "bar" );
assert( map[3] == "baz" ); assert( map[4] == "qux" );
@@ -111,17 +117,21 @@
}
{
//[tutorial_option
- using namespace lambda;
- typedef array<int, 4> ar_;
- ar_ powers = converter( csv_deque( 1, 10, -1, -1 ) );
-
- ar_::size_type index = 2; using namespace lambda;
- ( put( powers ) % ( _iterate = var( index )++ ) )( 100 )( 1000 );
-
- for(int value = 1, index = 0; index < ar_::static_size; index++, value *=10)
- {
- assert( powers[index] == value );
- }
+ typedef array<int, 10> C; C alternating;
+ alternating[0] = -1; alternating[1] = +1;
+ alternating[2] = -2;
+
+ C::size_type index = 3; using namespace lambda;
+ (
+ put( alternating ) % ( _iterate = var( index )++ )
+ )( +2 )( -3 )( +3 )( -4 )( +4 )( -5 )( +5 );
+
+ assert(
+ range::equal(
+ alternating,
+ csv_deque( -1, +1, -2, +2, -3, +3, -4, +4, -5, +5 )
+ )
+ );
//]
}
}
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