|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70585 - in sandbox/assign_v2: boost/assign/v2/deque boost/assign/v2/detail/traits/ptr_container boost/assign/v2/detail/traits/value_container boost/assign/v2/interpreter boost/assign/v2/ref/aux_/list boost/assign/v2/ref/aux_/list/holder libs/assign/v2 libs/assign/v2/src libs/assign/v2/test/option libs/assign/v2/test/put
From: erwann.rogard_at_[hidden]
Date: 2011-03-26 16:13:31
Author: e_r
Date: 2011-03-26 16:13:29 EDT (Sat, 26 Mar 2011)
New Revision: 70585
URL: http://svn.boost.org/trac/boost/changeset/70585
Log:
upd assign_v2
Text files modified:
sandbox/assign_v2/boost/assign/v2/deque/conversion.hpp | 2
sandbox/assign_v2/boost/assign/v2/detail/traits/ptr_container/fwd.hpp | 2
sandbox/assign_v2/boost/assign/v2/detail/traits/ptr_container/to_value_container.hpp | 96 ++++++++++++++++++++++++++++++---------
sandbox/assign_v2/boost/assign/v2/detail/traits/value_container/category.hpp | 79 ++++++++++++++++++++++++--------
sandbox/assign_v2/boost/assign/v2/detail/traits/value_container/fwd.hpp | 34 ++++++++++++++
sandbox/assign_v2/boost/assign/v2/interpreter/modifier.hpp | 31 +-----------
sandbox/assign_v2/boost/assign/v2/ref/aux_/list/container.hpp | 4
sandbox/assign_v2/boost/assign/v2/ref/aux_/list/holder/tail.hpp | 2
sandbox/assign_v2/libs/assign/v2/src/main.cpp | 4
sandbox/assign_v2/libs/assign/v2/test/option/std_modifier.cpp | 22 +++++++-
sandbox/assign_v2/libs/assign/v2/test/put/ptr.cpp | 32 +++++++++++-
sandbox/assign_v2/libs/assign/v2/test/put/put.cpp | 39 +++++++++++++++
sandbox/assign_v2/libs/assign/v2/tutorial.cpp | 38 +++++++++------
13 files changed, 283 insertions(+), 102 deletions(-)
Modified: sandbox/assign_v2/boost/assign/v2/deque/conversion.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/deque/conversion.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/deque/conversion.hpp 2011-03-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -19,7 +19,7 @@
#define BOOST_ASSIGN_V2_SEQ (T)(F)(Tag)
#define BOOST_ASSIGN_V2_R deque_interpreter<T, F, Tag>
-BOOST_ASSIGN_V2_CONVERSION_CONVERTER_NAME_LOOKUP(BOOST_ASSIGN_V2_SEQ, BOOST_ASSIGN_V2_R)
+BOOST_ASSIGN_V2_CONVERSION_CONVERTER_NAME_LOOKUP((T)(F)(Tag), BOOST_ASSIGN_V2_R)
#undef BOOST_ASSIGN_V2_SEQ
#undef BOOST_ASSIGN_V2_R
Modified: sandbox/assign_v2/boost/assign/v2/detail/traits/ptr_container/fwd.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/detail/traits/ptr_container/fwd.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/detail/traits/ptr_container/fwd.hpp 2011-03-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -68,7 +68,7 @@
template
<
class Key,
- class T,
+ class Mapped,
class Hash,
class Pred,
class CloneAllocator,
Modified: sandbox/assign_v2/boost/assign/v2/detail/traits/ptr_container/to_value_container.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/detail/traits/ptr_container/to_value_container.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/detail/traits/ptr_container/to_value_container.hpp 2011-03-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -21,25 +21,28 @@
namespace v2{
namespace container_aux{
- template<typename A, typename T> struct to_value_allocator_helper{};
-
- template<typename T>
- struct to_value_allocator_helper<std::allocator<void*>, T>
- {
- typedef std::allocator<T> type;
- };
+ // VALUE
template<typename PtrC>
struct to_value_value : boost::remove_reference<
typename PtrC::reference
>{};
+ template<typename PtrC>
+ struct to_value_mapped : boost::remove_reference<
+ typename PtrC::mapped_reference
+ >{};
+
+ // ALLOCATOR
+
template<typename PtrC>
- struct to_value_allocator : to_value_allocator_helper<
- typename PtrC::allocator_type,
- typename to_value_value<PtrC>::type
- >
- {};
+ struct to_value_allocator
+ {
+ typedef std::allocator<typename to_value_value<PtrC>::type> type;
+ };
+
+
+ // ARRAY
template<typename PtrC> struct helper_size{};
@@ -58,6 +61,8 @@
> type;
};
+ // SEQUENCE
+
template<typename PtrC, template<typename, typename> class C>
struct to_value_sequence {
@@ -68,18 +73,22 @@
};
+ // MAP
+
template<typename PtrC, template<typename, typename, typename, typename> class C>
struct to_value_map{
typedef C<
typename PtrC::key_type,
- typename to_value_value<PtrC>::type,
+ typename to_value_mapped<PtrC>::type,
typename PtrC::key_compare,
- typename to_value_allocator<PtrC>::type
+ typename to_value_allocator<PtrC>::type
> type;
};
+ // SET
+
template<typename PtrC, template<typename, typename, typename> class C>
struct to_value_set{
@@ -91,30 +100,34 @@
};
+ // UNORDERED MAP
+
template<typename PtrC,
template<typename, typename, typename, typename, typename> class C>
- class to_value_unordered_map{
+ struct to_value_unordered_map{
typedef C<
typename PtrC::key_type,
- typename to_value_value<PtrC>::type,
+ typename to_value_mapped<PtrC>::type,
typename PtrC::hasher,
typename PtrC::key_equal,
typename to_value_allocator<PtrC>::type
- > container_type;
+ > type;
};
+ // UNORDERED SET
+
template<typename PtrC,
template<typename, typename, typename, typename> class C>
- class unordered_set_like{
+ struct to_value_unordered_set{
typedef C<
typename PtrC::key_type,
typename PtrC::hasher,
typename PtrC::key_equal,
typename to_value_allocator<PtrC>::type
- > container_type;
+ > type;
};
@@ -176,21 +189,25 @@
std::vector
>{};
+ // Map
+
template
<
class Key,
- class T,
+ class Mapped,
class Compare,
class CloneAllocator,
class Allocator
>
struct to_value_container<
- boost::ptr_map<Key, T, Compare, CloneAllocator, Allocator>
+ boost::ptr_map<Key, Mapped, Compare, CloneAllocator, Allocator>
> : to_value_map<
- boost::ptr_map<Key, T, Compare, CloneAllocator, Allocator>,
+ boost::ptr_map<Key, Mapped, Compare, CloneAllocator, Allocator>,
std::map
>{};
+ // Set
+
template
<
class Key,
@@ -205,7 +222,40 @@
std::set
>{};
- // TODO unordered
+ // Unordered map
+
+ template
+ <
+ class Key,
+ class Mapped,
+ class Hash,
+ class Pred,
+ class CloneAllocator,
+ class Allocator
+ >
+ struct to_value_container<
+ boost::ptr_unordered_map<Key, Mapped, Hash, Pred, CloneAllocator, Allocator>
+ > : to_value_unordered_map<
+ boost::ptr_unordered_map<Key, Mapped, Hash, Pred, CloneAllocator, Allocator>,
+ boost::unordered_map
+ >{};
+
+ // Unordered set
+
+ template
+ <
+ class Key,
+ class Hash,
+ class Pred,
+ class CloneAllocator,
+ class Allocator
+ >
+ struct to_value_container<
+ boost::ptr_unordered_set<Key, Hash, Pred, CloneAllocator, Allocator>
+ > : to_value_unordered_set<
+ boost::ptr_unordered_set<Key, Hash, Pred, CloneAllocator, Allocator>,
+ boost::unordered_set
+ >{};
}// container_aux
}// v2
Modified: sandbox/assign_v2/boost/assign/v2/detail/traits/value_container/category.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/detail/traits/value_container/category.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/detail/traits/value_container/category.hpp 2011-03-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -9,45 +9,84 @@
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_ASSIGN_V2_TRAITS_VALUE_CONTAINER_CATEGORY_ER_2010_HPP
#define BOOST_ASSIGN_V2_TRAITS_VALUE_CONTAINER_CATEGORY_ER_2010_HPP
-#include <boost/mpl/bool.hpp>
#include <boost/assign/v2/detail/traits/value_container/fwd.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/preprocessor/seq.hpp>
+#include <boost/preprocessor/cat.hpp>
namespace boost{
namespace assign{
namespace v2{
namespace container_aux{
- // FIFO
template<typename C> struct is_fifo : ::boost::mpl::false_{};
- template<typename T, typename A>
- struct is_fifo< std::queue<T, A> > : ::boost::mpl::true_{};
-
- // LIFO
template<typename V>
struct is_lifo : ::boost::mpl::false_{};
- template<typename T, typename A>
- struct is_lifo< std::stack<T,A> > : ::boost::mpl::true_{};
+ template<typename C>
+ struct is_associative : ::boost::mpl::false_{};
- // IS_SORTED
- template<typename V>
+ template<typename C>
struct is_sorted : ::boost::mpl::false_{};
- template<typename T, typename C, typename A>
- struct is_sorted< std::set<T, C, A> > : ::boost::mpl::true_{};
-
- template<typename K, typename T, typename C, typename A>
- struct is_sorted< std::map<K, T, C, A> > : ::boost::mpl::true_{};
-
- // IS_ARRAY
template<typename C> struct is_array : ::boost::mpl::false_{};
- template<typename T, std::size_t sz> struct is_array<
- boost::array<T, sz>
- > : ::boost::mpl::true_{};
+ // FIFO
+ template<typename T, typename A>
+ struct is_fifo< std::queue<T, A> > : ::boost::mpl::true_{};
+
+ // LIFO
+ template<typename T, typename A>
+ struct is_lifo< std::stack<T,A> > : ::boost::mpl::true_{};
}// container_aux
+
+#define BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORY(SeqPar, IsCategory, Identifier, SeqArg)\
+namespace container_aux{\
+ template<BOOST_PP_SEQ_ENUM(SeqPar)>\
+ struct IsCategory <\
+ Identifier<BOOST_PP_SEQ_ENUM(SeqArg)> \
+ > : ::boost::mpl::true_{};\
+}\
+/**/
+#define BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORIES_HELPER(r, data, elem)\
+ BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORY(\
+ BOOST_PP_SEQ_ELEM(0, data),\
+ elem,\
+ BOOST_PP_SEQ_ELEM(1, data),\
+ BOOST_PP_SEQ_ELEM(2, data)\
+ )
+/**/
+#define BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORIES(SeqPar, SeqIsCategory, Identifier, SeqArg)\
+ BOOST_PP_SEQ_FOR_EACH(\
+ BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORIES_HELPER,\
+ (SeqPar)(Identifier)(SeqArg),\
+ SeqIsCategory\
+ )\
+/**/
+
+BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORIES(
+ (typename T)( std::size_t sz), (is_array),
+ boost::array, (T)(sz)
+)
+BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORIES(
+ (typename K)(typename T)(typename C)(typename A), (is_sorted)(is_associative),
+ std::map, (K)(T)(C)(A)
+)
+BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORIES(
+ (typename T)(typename C)(typename A), (is_sorted)(is_associative),
+ std::set, (T)(C)(A)
+)
+BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORIES(
+ (typename K)(typename M)(typename H)(typename P)(typename A), (is_associative),
+ boost::unordered_map, (K)(M)(H)(P)(A)
+)
+BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORIES(
+ (typename K)(typename H)(typename P)(typename A), (is_associative),
+ boost::unordered_set, (K)(H)(P)(A)
+)
+
}// v2
}// assign
}// boost
Modified: sandbox/assign_v2/boost/assign/v2/detail/traits/value_container/fwd.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/detail/traits/value_container/fwd.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/detail/traits/value_container/fwd.hpp 2011-03-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -43,6 +43,40 @@
// http://www.boost.org/doc/libs/release/libs/circular_buffer/index.html
template<typename T, typename Alloc> class circular_buffer;
+ template <
+ class Key,
+ class Hash,
+ class Pred,
+ class Alloc
+ >
+ class unordered_set;
+
+ template <
+ class Key,
+ class Mapped,
+ class Hash,
+ class Pred,
+ class Alloc
+ >
+ class unordered_map;
+
+ template<
+ class Key,
+ class Mapped,
+ class Hash,
+ class Pred,
+ class Alloc
+ >
+ class unordered_multimap;
+
+ template<
+ class Key,
+ class Hash,
+ class Pred,
+ class Alloc
+ >
+ class unordered_multiset;
+
}// boost
#endif // BOOST_ASSIGN_V2_DETAIL_TRAITS_VALUE_CONTAINER_FWD_ER_2010_HPP
Modified: sandbox/assign_v2/boost/assign/v2/interpreter/modifier.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/interpreter/modifier.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/interpreter/modifier.hpp 2011-03-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -77,31 +77,6 @@
/**/
#endif
-
-#ifdef BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_ASSOCIATIVE
-#error
-#else
-#define BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_ASSOCIATIVE(CaseNumber)\
-BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_CASE(insert, container_aux::is_sorted, CaseNumber)\
-/**/
-#endif
-
-#ifdef BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_ARRAY
-#error
-#else
-#define BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_ARRAY(CaseNumber)\
-BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_CASE(iterate<>, container_aux::is_array, CaseNumber)
-/**/
-#endif
-
-#ifdef BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_ADAPTER
-#error
-#else
-#define BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_ADAPTER(CaseNumber)\
-BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_CASE(push, container_aux::has_push_deduced_value, CaseNumber)
-/**/
-#endif
-
#ifdef BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_DEFAULT
#error
#else
@@ -118,9 +93,9 @@
#ifdef BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH
#warning
#else
-BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_ASSOCIATIVE(0)
-BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_ARRAY(1)
-BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_ADAPTER(2)
+BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_CASE(insert, container_aux::is_associative, 0)
+BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_CASE(iterate<>, container_aux::is_array, 1)
+BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_CASE(push, container_aux::has_push_deduced_value, 2)
BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH_DEFAULT(3)
#define BOOST_ASSIGN_V2_OPTION_MODIFIER_SWITCH
#endif
Modified: sandbox/assign_v2/boost/assign/v2/ref/aux_/list/container.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/ref/aux_/list/container.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/ref/aux_/list/container.hpp 2011-03-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -25,7 +25,7 @@
template<typename Tag, typename H, typename T>
class container :
- public tail_holder<T>,
+ public tail_holder<T>,
public head_holder<H>,
public ::boost::mpl::apply2<policy<Tag>, H, T>::type
{
@@ -64,7 +64,7 @@
typedef typename result<H1 const&>::type result_;
return result_( *this, h );
}
-
+
};
}// list_aux
Modified: sandbox/assign_v2/boost/assign/v2/ref/aux_/list/holder/tail.hpp
==============================================================================
--- sandbox/assign_v2/boost/assign/v2/ref/aux_/list/holder/tail.hpp (original)
+++ sandbox/assign_v2/boost/assign/v2/ref/aux_/list/holder/tail.hpp 2011-03-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -43,7 +43,7 @@
typedef nil tail_type;
typedef ::boost::mpl::int_<0> static_size;
tail_holder(){}
-
+
typedef tail_type result_of_tail_type;
};
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-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -21,8 +21,8 @@
#include <libs/assign/v2/tutorial.h>
// Speed -- CPP0x required
-//#include <fstream>
-//#include <libs/assign/v2/speed/test.h>
+/*#include <fstream>
+#include <libs/assign/v2/speed/test.h>*/
#include <boost/assign/v2/include.hpp>
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-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -17,6 +17,7 @@
#include <boost/assign/v2/deque.hpp>
// Options come next
#include <boost/assign/v2/option/std_modifier.hpp>
+#include <boost/circular_buffer.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/algorithm/equal.hpp>
@@ -60,13 +61,28 @@
{
// fully qual boost::begin/end demanded by MSVC - error C2668
//[test_option_push_front
- std::deque<double> sqrt2;
+ boost::circular_buffer<int> cb(3);
+ ( as2::put( cb ) % as2::_push_front)( 3 )( 2 )( 1 );
+
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal(cb, as2::csv_deque(1, 2, 3) )
+ );
+
+ as2::put( cb )( 4 )( 5 );
+
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal(cb, as2::csv_deque(3, 4, 5) )
+ );
+
+ //]
+
+ /*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 ) );
- //]
+ BOOST_ASSIGN_V2_CHECK( boost::upper_bound( sqrt2, 1.41421 ) == boost::end( sqrt2 ) );*/
+
}
{
//[test_option_push
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-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -8,14 +8,18 @@
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
//////////////////////////////////////////////////////////////////////////////
#include <string>
+#include <utility>
#include <boost/assign/v2/detail/config/check.hpp>
#include <boost/assign/v2/detail/pp/ignore.hpp>
#include <boost/assign/v2/put.hpp>
+#include <boost/scoped_ptr.hpp>
#include <boost/ptr_container/ptr_array.hpp>
#include <boost/ptr_container/ptr_deque.hpp>
#include <boost/ptr_container/ptr_list.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_set.hpp>
+#include <boost/ptr_container/ptr_unordered_set.hpp>
+#include <boost/ptr_container/ptr_unordered_map.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <libs/assign/v2/test/put/ptr.h>
@@ -65,14 +69,16 @@
//]
}
// TODO
-/*
{
//[put_ptr_map
- boost::ptr_map<std::string, int> assoc;
- as2::put( assoc )( "jan", 31 )( "feb", 28 )( "mar", 31 );
+ typedef std::string key_;
+ boost::ptr_map<key_, int> assoc;
+ //( as2::put( assoc ) % _key % _mapped ) ( "jan", 31 )( "feb", 28 )( "mar", 31 );
+ //key_ key = "jan";
+ //std::pair<key_, int*> p( key, new int(31) );
+ //assoc.insert( p );
//]
}
-*/
{
//[put_ptr_set
typedef std::string T; boost::ptr_set<T> assoc;
@@ -82,6 +88,24 @@
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);
+
+ BOOST_ASSIGN_V2_CHECK( map["foo"] == 1 );
+ BOOST_ASSIGN_V2_CHECK( map["baz"] == 3 );
+ //]
+ */}
+ {
+ //[test_put_put_unordered_set
+ boost::ptr_unordered_set<std::string> set;
+ as2::put( set )("foo")("bar")("baz");
+
+ BOOST_ASSIGN_V2_CHECK( set.count("foo") == 1 );
+ BOOST_ASSIGN_V2_CHECK( set.count("baz") == 1 );
+ //]
+ }
}// test
}// xxx_ptr
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-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -18,8 +18,11 @@
#include <stack>
#include <string>
#include <utility>
-#include <boost/assign/v2/detail/config/check.hpp>
+#include <boost/circular_buffer.hpp>
+#include <boost/unordered_map.hpp>
+#include <boost/unordered_set.hpp>
+#include <boost/assign/v2/detail/config/check.hpp>
#include <boost/assign/v2/put.hpp>
#include <boost/assign/v2/deque/csv_deque.hpp>
#include <boost/tuple/tuple.hpp>
@@ -128,6 +131,40 @@
BOOST_ASSIGN_V2_CHECK( get<1>( tri_state_area.front() ) == 212 );
BOOST_ASSIGN_V2_CHECK( get<0>( tri_state_area.back() ) == ct );
}
+ {
+ //[test_put_put_unordered_map
+ boost::unordered_map<std::string, int> map;
+ as2::put( map )("foo", 1)("bar", 2)("baz", 3);
+
+ BOOST_ASSIGN_V2_CHECK( map["foo"] == 1 );
+ BOOST_ASSIGN_V2_CHECK( map["baz"] == 3 );
+ //]
+ }
+ {
+ //[test_put_put_unordered_set
+ boost::unordered_set<std::string> set;
+ as2::put( set )("foo")("bar")("baz");
+
+ BOOST_ASSIGN_V2_CHECK( set.count("foo") == 1 );
+ BOOST_ASSIGN_V2_CHECK( set.count("baz") == 1 );
+ //]
+ }
+ {
+ //test_put_put_cb
+ boost::circular_buffer<int> cb(3);
+ as2::put( cb )( 1 )( 2 )( 3 );
+
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal(cb, as2::csv_deque(1, 2, 3) )
+ );
+
+ as2::put( cb )( 4 )( 5 );
+
+ BOOST_ASSIGN_V2_CHECK(
+ range::equal(cb, as2::csv_deque(3, 4, 5) )
+ );
+ //]
+ }
}// test()
}// xxx_put
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-26 16:13:29 EDT (Sat, 26 Mar 2011)
@@ -11,7 +11,7 @@
#include <cstddef>
#include <vector>
#include <deque>
-#include <map>
+#include <map>
#include <queue>
#include <boost/assign/v2.hpp>
#include <boost/array.hpp>
@@ -50,7 +50,7 @@
typedef std::string T; ptr_set<T> assoc;
T x = "isomer", y = "ephemeral", z = "prosaic";
csv( put( assoc ), x, z, y );
-
+
assert( assoc.count( x ) == 1 );
assert( assoc.count( z ) == 1 );
//]
@@ -58,7 +58,7 @@
{
//[tutorial_piping
using namespace lambda;
- std::deque<int> cont;
+ std::deque<int> cont;
range::stable_partition( cont | _csv_put( 0, 1, 2, 3, 4, 5 ), _1 % 2 );
//]
//[tutorial_container_generation
@@ -69,18 +69,18 @@
//[tutorial_ref_array
int x = 4, y = 6, z = -1;
int const& max = *max_element( ref::csv_array( x, y, z ) );
-
+
assert( &max == &y );
//]
}
- {
+ {
//[tutorial_chain
std::vector<int> consecutive8( 8 ); for(int i = 0; i < 8; i++){ consecutive8[i] = 1 + i; }
array<int, 5> consecutive5; int six, seven, eight;
boost::copy(
consecutive8,
- boost::begin(
- consecutive5 | _chain( ref::csv_array( six, seven, eight ) | ref::_get )
+ boost::begin(
+ consecutive5 | _chain( ref::csv_array( six, seven, eight ) | ref::_get )
)
);
@@ -91,28 +91,34 @@
{
//[tutorial_conversion
std::queue<int> fifo = converter( csv_deque( 72, 31, 48 ) );
-
+
assert( fifo.front() == 72 ); assert( fifo.back() == 48 );
//]
}
{
//[tutorial_data_gen
- std::map<std::string, int> map;
+ std::map<std::string, int> map;
put( map )( "foo", 1 )( "bar", 2 )( "baz", 3 );
-
+
assert( map["bar"] = 2 );
//]
}
{
//[tutorial_option
using namespace lambda;
- array<int, 4> powers = converter( csv_deque( 1, 10, -1, -1 ) );
- std::size_t index = 2; 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 < powers.size(); index++, value *=10 )
- {
- assert( powers[index] == value );
+
+ for(
+ int value = 1, index = 0;
+ index < ar_::static_size;
+ index++, value *=10
+ )
+ {
+ assert( powers[index] == value );
}
//]
}
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