|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60165 - in sandbox/statistics/detail/assign: boost/assign/auto_size boost/assign/auto_size/array boost/assign/auto_size/detail libs/assign/example libs/assign/src libs/assign/test
From: erwann.rogard_at_[hidden]
Date: 2010-03-04 22:41:06
Author: e_r
Date: 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
New Revision: 60165
URL: http://svn.boost.org/trac/boost/changeset/60165
Log:
m
Text files modified:
sandbox/statistics/detail/assign/boost/assign/auto_size/array/policy.hpp | 32 ++++++++
sandbox/statistics/detail/assign/boost/assign/auto_size/array/wrapper.hpp | 47 ++++++++++---
sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp | 136 ++++++++++++++++++---------------------
sandbox/statistics/detail/assign/boost/assign/auto_size/detail/csv.hpp | 48 +++++++++----
sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of.hpp | 19 +++++
sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of_csv.hpp | 2
sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of.hpp | 18 +++++
sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of_csv.hpp | 2
sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp | 29 +++++++
sandbox/statistics/detail/assign/libs/assign/src/main.cpp | 8 +-
sandbox/statistics/detail/assign/libs/assign/test/speed.cpp | 4
sandbox/statistics/detail/assign/libs/assign/test/speed.h | 4
sandbox/statistics/detail/assign/libs/assign/test/static_list_of_auto_size.cpp | 43 ++++++-----
13 files changed, 257 insertions(+), 135 deletions(-)
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/array/policy.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/array/policy.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/array/policy.hpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -10,13 +10,39 @@
#define BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_POLICY_ER_2010_HPP
#include <boost/shared_ptr.hpp>
#include <boost/assign/auto_size/array/interface.hpp>
-#include <boost/assign/auto_size/array/wrapper.hpp>
#include <boost/assign/auto_size/array/ref.hpp>
+#include <boost/assign/auto_size/detail/policy.hpp>
namespace boost{
namespace assign{
namespace detail{
namespace auto_size{
+
+ // tag::lazy_array designates a policy for auto_size::expr<>, that has the
+ // functionality of array_interface<>, and postones allocation until it is
+ // necessary. It is therefore suitable as the result of statements such as:
+ // fun(a)(b)(c);
+
+ namespace tag{
+ struct lazy_array{};
+ }
+
+ template<typename T,int N,template<typename> class Ref,typename D>
+ class lazy_array;
+
+ template<typename E> struct expr_size;
+ template<typename E> struct expr_elem;
+
+ template<>
+ struct policy<tag::lazy_array>
+ {
+ template<typename E,template<typename> class Ref>
+ struct apply{
+ typedef typename expr_size<E>::type size_;
+ typedef typename expr_elem<E>::type elem_;
+ typedef lazy_array<elem_,size_::value,Ref,E> type;
+ };
+ };
template<
typename E,typename T,int N,template<typename> class Ref,typename P
@@ -30,8 +56,8 @@
// Policy for the collection builder, auto_size::expr<>, that exposes an
// array interface
template<typename T,int N,template<typename> class Ref,typename D>
- class array_policy
- : public array_interface<T,N,Ref,array_policy<T,N,Ref,D> >
+ class lazy_array
+ : public array_interface<T,N,Ref,lazy_array<T,N,Ref,D> >
{
typedef typename auto_size::ref_array<T,N,Ref>::type ref_array_;
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/array/wrapper.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/array/wrapper.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/array/wrapper.hpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -10,25 +10,54 @@
#define BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_WRAPPER_ER_2010_HPP
#include <boost/assign/auto_size/array/interface.hpp>
#include <boost/assign/auto_size/array/ref.hpp>
-#include <boost/assign/auto_size/detail/auto_size.hpp>
+#include <boost/assign/auto_size/detail/expr.hpp> // needed for write_to_array
namespace boost{
namespace assign{
namespace detail{
namespace auto_size{
- // Used by csv.hpp
+ namespace tag{
+ struct static_array{};
+ }
+
+ // tag::static_array designates a data-structure that has the functonality
+ // of array_interface<> and is allocated at construction. It is therefore
+ // suitable as the result of functions that have the csv form :
+ // fun(a,b,c)
+ // Unlike lazy_array, it is not a suitable policy for auto_size::expr<>.
+ // This is desirable as otherwise the result from fun(a,b,c) would be
+ // costlier to compute (this has already been tested).
+
+ template<typename T,int N,template<typename> class Ref>
+ class static_array;
+
+ template<>
+ struct policy<tag::static_array>
+ {
+ template<typename T,int N,template<typename> class Ref>
+ struct apply{
+ typedef static_array<T,N,Ref> type;
+ };
+ };
+
+
template<typename T,int N,template<typename> class Ref>
- class array_wrapper
- : public array_interface<T,N,Ref,array_wrapper<T,N,Ref> >
+ class static_array
+ : public array_interface<T,N,Ref,static_array<T,N,Ref> >
{
typedef typename auto_size::ref_array<T,N,Ref>::type ref_array_;
public:
- array_wrapper(){}
-
+ static_array(){}
+
+ template<typename E>
+ static_array(const E& coll){
+ write_to_array(this->ref_array,coll);
+ }
+
ref_array_& ref_array_impl(){
return this->ref_array;
}
@@ -37,16 +66,12 @@
return this->ref_array;
}
- template<typename E>
- void initialize(const E& coll)const{
- write_to_array(this->ref_array,coll);
- }
-
private:
mutable ref_array_ ref_array;
};
+
}// auto_size
}// detail
}// assign
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////////////
-// assign::detail::auto_size.hpp //
+// assign::detail::expr.hpp //
// //
// (C) Copyright 2010 Erwann Rogard //
// Use, modification and distribution are subject to the //
@@ -16,6 +16,10 @@
#include <boost/type_traits.hpp>
#include <boost/assign/list_of.hpp> // needed for assign_reference
#include <boost/assign/auto_size/detail/assign_reference_copy.hpp>
+#include <boost/assign/auto_size/detail/policy.hpp>
+#include <boost/assign/auto_size/detail/types.hpp>
+#include <boost/assign/auto_size/detail/expr_size.hpp>
+#include <boost/assign/auto_size/detail/expr_elem.hpp>
#include <boost/assign/auto_size/array/policy.hpp>
// Creates a collection of references by deducing the number of arguments
@@ -29,108 +33,88 @@
//
// Acknowledgement: The idea of this class was developed in collaboration
// with M.P.G
-//
-// Revision history:
-// March 1, 2010 : Factored the interface into a policy. Csv improved by
-// returning array_wrapper, not array_policy, to avoid a pointer.
-// Feb 27, 2010 : Support for comma separated arguments (See csv.hpp)
-// Feb 25, 2010 : Complemented the boost::array interface
-// Feb 21, 2010 : Made member variables mutable and added constness to member
-// functions where appropriate.
-// Feb 9, 2010 :
-// - Added a template parameter for the reference wrapper
-// - The temporary array in the conversion operator is now assigned by calling
-// begin() and end() rather than write_to_array() to ensure consistency of
-// side effect.
-// Feb 5, 2010 : First version. rebind semantics.
namespace boost{
namespace assign{
namespace detail{
namespace auto_size{
-
- typedef boost::mpl::void_ top_;
-
+
+ // ----fwd declare ---- //
+
template<
- typename L,typename T,int N,template<typename> class Ref,typename P>
+ typename E,typename T,int N,template<typename> class Ref,typename P>
class expr;
- // ---- Policy meta classes --- //
-
- struct default_policy;
-
- struct default_policy{
- template<typename E,typename T,int N,template<typename> class Ref>
- struct apply{
- typedef expr<E,T,N,Ref,default_policy> expr_;
- typedef array_policy<T,N,Ref,expr_> type;
- };
- };
-
- struct no_policy{
- template<typename E,typename T,int N,template<typename> class Ref>
- struct apply{
- typedef boost::mpl::empty_base type;
- };
+ // ---- Traits --- //
+
+ template<typename E,typename T,int N,template<typename>class Ref,typename P>
+ struct expr_size<expr<E,T,N,Ref,P> >
+ : boost::mpl::int_<N>{};
+
+ template<typename E,typename T,int N,template<typename>class Ref,typename P>
+ struct expr_elem<expr<E,T,N,Ref,P> >
+ {
+ typedef T type;
};
// ---- Collection builder ---- //
-
- template<
- typename E,typename T,int N,template<typename> class Ref,typename P>
- struct next{
- typedef expr<E,T,N,Ref,P> expr_;
- typedef expr<expr_,T,N+1,Ref,P> type;
- };
template<
typename E,typename T,int N,template<typename> class Ref,typename P>
- class expr : public P::template apply<E,T,N,Ref>::type{
+ class expr : public policy<P>::template apply<expr<E,T,N,Ref,P>,Ref>::type{
typedef boost::mpl::int_<1> int_1_;
typedef boost::mpl::int_<N> int_n_;
typedef typename Ref<T>::type ref_;
- typedef typename P::template apply<E,T,N,Ref>::type super_;
+ typedef typename policy<P>::template apply<expr,Ref>::type super_;
+
+ template<typename E1>
+ struct next{
+ typedef expr<E1,T,N+1,Ref,P> type;
+ };
public:
typedef typename boost::mpl::equal_to<int_n_,int_1_>::type is_1st_;
typedef typename boost::mpl::if_<is_1st_,E,const E&>::type previous_;
- typedef typename next<E,T,N,Ref,P>::type next_;
- typedef next_ result_type;
+ typedef typename next<expr>::type result_type;
expr(const E& p,T& t):previous(p),ref(t){}
- next_ operator()(T& t)const{ return next_(*this,t); }
+ result_type operator()(T& t)const{ return result_type(*this,t); }
mutable previous_ previous;
mutable ref_ ref;
+
};
// ---- write_to_array ---- //
- typedef boost::mpl::bool_<false> false_;
- typedef boost::mpl::bool_<true> true_;
-
- template<typename A,typename E,typename T,int N,
- template<typename> class Ref,typename P>
- void write_to_array(A& a,const expr<E,T,N,Ref,P>& e){
- typedef expr<E,T,N,Ref,P> expr_;
- typedef typename expr_::is_1st_ exit_;
- write_to_array(a,e,exit_());
- }
-
- template<typename A,typename E,typename T,int N,
+ template<int Nshift,typename A,typename E,typename T,int N,
template<typename> class Ref,typename P>
void write_to_array(A& a,const expr<E,T,N,Ref,P>& e,false_ /*exit*/){
- a[N-1] = e.ref;
+ a[Nshift+N-1] = e.ref;
write_to_array(a,e.previous);
}
- template<typename A,typename E,typename T,int N,
+ template<int Nshift,typename A,typename E,typename T,int N,
template<typename> class Ref,typename P>
void write_to_array(A& a,const expr<E,T,N,Ref,P>& e,true_ /*exit*/){
- a[N-1] = e.ref;
+ a[Nshift+N-1] = e.ref;
}
+ template<int Nshift,typename A,typename E,typename T,int N,
+ template<typename> class Ref,typename P>
+ void write_to_array(A& a,const expr<E,T,N,Ref,P>& e){
+ typedef expr<E,T,N,Ref,P> expr_;
+ typedef typename expr_::is_1st_ exit_;
+ write_to_array<Nshift>(a,e,exit_());
+ }
+
+ template<typename A,typename E,typename T,int N,
+ template<typename> class Ref,typename P>
+ void write_to_array(A& a,const expr<E,T,N,Ref,P>& e){
+ return write_to_array<0>(a,e);
+ }
+
// ---- ref wrappers ---- //
template<typename T>
@@ -174,20 +158,24 @@
// ---- result_of ---- //
- template<typename T,int N,template<typename> class Ref,typename P>
- struct result_of{
- typedef typename result_of<T,N-1,Ref,P>::type previous;
- typedef expr<previous,T,N,Ref,P> type;
- };
+ namespace result_of{
+
+ template<typename T,int N,template<typename> class Ref,typename P>
+ struct expr{
+ typedef typename result_of::expr<T,N-1,Ref,P>::type previous;
+ typedef auto_size::expr<previous,T,N,Ref,P> type;
+ };
- template<typename T,template<typename> class Ref,typename P>
- struct result_of<T,1,Ref,P> : first_expr<T,Ref,P>{};
+ template<typename T,template<typename> class Ref,typename P>
+ struct expr<T,1,Ref,P> : first_expr<T,Ref,P>{};
+
+ template<typename T,int N,typename P = default_policy>
+ struct copy : result_of::expr<T,N,ref_copy,P>{};
- template<typename T,int N,typename P = default_policy>
- struct result_of_copy : result_of<T,N,ref_copy,P>{};
+ template<typename T,int N,typename P = default_policy>
+ struct rebind : result_of::expr<T,N,ref_rebind,P>{};
- template<typename T,int N,typename P = default_policy>
- struct result_of_rebind : result_of<T,N,ref_rebind,P>{};
+ }
}// auto_size
}// detail
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/csv.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/detail/csv.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/csv.hpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -13,7 +13,7 @@
#include <boost/preprocessor/repetition/enum.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
-#include <boost/assign/auto_size/detail/auto_size.hpp>
+#include <boost/assign/auto_size/detail/expr.hpp>
#include <boost/assign/auto_size/array/wrapper.hpp>
// Whereas adjacent unary function calls is the usual way to create a collec-
@@ -21,12 +21,16 @@
// are overloaded on the number of arguments.
//
// Let n = BOOST_ASSIGN_CSV_SIZE and a1,...,an, objects of type T, Ref an alias
-// for BOOST_ASSIGN_CSV_ref, and w<U,N> an alias for array_wrapper<U,N,Ref>.
+// for BOOST_ASSIGN_CSV_ref, P0 = BOOST_ASSIGN_CSV_DEF_POLICY and r<U,N,P> an
+// alias for result_of::expr<U,N,Ref,P>::type
//
// Usage:
// BOOST_ASSIGN_CSV(fun) creates for i=1,...,n the following overloads:
-// fun(a1,..,.ai)
-// cfun(a1,..,.ai)
+// Call Result
+// fun<P>(a1,..,.ai) r<T,i,P>
+// cfun<P>(a1,..,.ai) r<const T,i,P>
+// fun(a1,..,.ai) r<T,i,P0>
+// cfun(a1,..,.ai) r<const T,i,P0>
// which return instances of w<T,i> and w<const T,i>, respectively.
#ifndef BOOST_ASSIGN_CSV_SIZE
@@ -36,27 +40,41 @@
#ifndef BOOST_ASSIGN_CSV_ref
#error
#endif
+#define BOOST_ASSIGN_CSV_DEF_POLICY \
+ boost::assign::detail::auto_size::tag::static_array \
+/**/
+#define BOOST_ASSIGN_CSV_RESULT(U,N,P) \
+ typename boost::assign::detail::auto_size::policy<P>::template \
+ apply<U,N,BOOST_ASSIGN_CSV_ref>::type \
+/**/
+#define BOOST_ASSIGN_CSV_RESULT_DEF_POLICY(U,N) \
+ BOOST_ASSIGN_CSV_RESULT(U,N,BOOST_ASSIGN_CSV_DEF_POLICY) \
+/**/
#define BOOST_ASSIGN_CSV_ARG(z,n,arg) (BOOST_PP_CAT(arg,n))
+#define BOOST_ASSIGN_CSV_TPL(arg) \
+ BOOST_PP_CAT(<, \
+ BOOST_PP_CAT(arg,>)) \
+/**/
#define BOOST_ASSIGN_CSV_ITER_UNQUAL(F,T,U,N) \
namespace boost{ \
namespace assign{ \
+ template<typename P,typename T> \
+ BOOST_ASSIGN_CSV_RESULT(U,N,P) \
+ F(BOOST_PP_ENUM_PARAMS(N, U& _)) \
+ { \
+ return boost::assign::detail::auto_size::make_first_expr_no_policy< \
+ BOOST_ASSIGN_CSV_ref,T \
+ > BOOST_PP_REPEAT(N,BOOST_ASSIGN_CSV_ARG,_); \
+ } \
template<typename T> \
- boost::assign::detail::auto_size::array_wrapper< \
- U,N,BOOST_ASSIGN_CSV_ref \
- > \
+ BOOST_ASSIGN_CSV_RESULT_DEF_POLICY(U,N) \
F(BOOST_PP_ENUM_PARAMS(N, U& _)) \
{ \
- typedef boost::assign::detail::auto_size::array_wrapper< \
- U,N,BOOST_ASSIGN_CSV_ref> wrapper_; \
- wrapper_ wrapper; \
- wrapper.initialize( \
- boost::assign::detail::auto_size::make_first_expr_no_policy< \
+ return boost::assign::detail::auto_size::make_first_expr_no_policy< \
BOOST_ASSIGN_CSV_ref,T \
- > BOOST_PP_REPEAT(N,BOOST_ASSIGN_CSV_ARG,_) \
- ); \
- return wrapper; \
+ > BOOST_PP_REPEAT(N,BOOST_ASSIGN_CSV_ARG,_); \
} \
} \
} \
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of.hpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_ASSIGN_AUTO_SIZE_REF_LIST_OF_ER_2010_HPP
#define BOOST_ASSIGN_AUTO_SIZE_REF_LIST_OF_ER_2010_HPP
-#include <boost/assign/auto_size/detail/auto_size.hpp>
+#include <boost/assign/auto_size/detail/expr.hpp>
// Creates a collection of references whose functionality is that of
// auto_size::array_interface<>. It can be used either as the rhs or lhs
@@ -18,12 +18,29 @@
namespace boost{
namespace assign{
+ // specified policy :
+
+ template<typename P,typename T>
+ typename detail::auto_size::first_copy<const T,P>::type
+ cref_list_of(const T& t){
+ return detail::auto_size::first_copy<const T,P>::call(t);
+ }
+
+ template<typename P,typename T>
+ typename detail::auto_size::first_copy<T,P>::type
+ ref_list_of(const T& t){
+ return detail::auto_size::first_copy<T,P>::call(t);
+ }
+
+ // default policy :
+
template<typename T>
typename detail::auto_size::first_copy<const T>::type
cref_list_of(const T& t){
return detail::auto_size::first_copy<const T>::call(t);
}
+
template<typename T>
typename detail::auto_size::first_copy<T>::type
ref_list_of(T& t){
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of_csv.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of_csv.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of_csv.hpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -12,6 +12,8 @@
// Usage:
// ref_list_of_csv(a,b,c);
// cref_list_of_csv(a,b,c);
+// ref_list_of_csv<P>(a,b,c);
+// cref_list_of_csv<P>(a,b,c);
#define BOOST_ASSIGN_CSV_ref boost::assign::detail::auto_size::ref_copy
#include <boost/assign/auto_size/detail/csv.hpp>
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of.hpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_ASSIGN_AUTO_SIZE_REF_REBIND_LIST_OF_ER_2010_HPP
#define BOOST_ASSIGN_AUTO_SIZE_REF_REBIND_LIST_OF_ER_2010_HPP
-#include <boost/assign/auto_size/detail/auto_size.hpp>
+#include <boost/assign/auto_size/detail/expr.hpp>
// Creates a collection of references whose functionality is that of
// auto_size::array_interface<>. Rebind semantics apply if the collection
@@ -19,6 +19,22 @@
namespace boost{
namespace assign{
+ // specified policy :
+
+ template<typename P,typename T>
+ typename detail::auto_size::first_rebind<const T,P>::type
+ cref_rebind_list_of(const T& t){
+ return detail::auto_size::first_rebind<const T,P>::call(t);
+ }
+
+ template<typename P,typename T>
+ typename detail::auto_size::first_rebind<T,P>::type
+ ref_rebind_list_of(const T& t){
+ return detail::auto_size::first_rebind<T,P>::call(t);
+ }
+
+ // default policy :
+
template<typename T>
typename detail::auto_size::first_rebind<const T>::type
cref_rebind_list_of(const T& t){
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of_csv.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of_csv.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of_csv.hpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -12,6 +12,8 @@
// Usage:
// ref_rebind_list_of_csv(a,b,c);
// cref_rebind_list_of_csv(a,b,c);
+// ref_rebind_list_of_csv<P>(a,b,c);
+// cref_rebind_list_of_csv<P>(a,b,c);
#define BOOST_ASSIGN_CSV_ref boost::assign::detail::auto_size::ref_rebind
#include <boost/assign/auto_size/detail/csv.hpp>
Modified: sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -10,11 +10,12 @@
#include <vector>
#include <algorithm>
#include <boost/typeof/typeof.hpp>
+#include <boost/assign/auto_size/ref_list_of.hpp> // temporary
#include <boost/assign/auto_size/ref_list_of_csv.hpp>
#include <boost/assign/auto_size/ref_rebind_list_of_csv.hpp>
-#include <boost/assign/auto_size/array/wrapper.hpp>
#include <boost/assign/list_of.hpp>
+#include <boost/range/algorithm/max_element.hpp>
#include <libs/assign/example/ref_list_of.h>
void example_ref_list_of(std::ostream& os)
@@ -38,11 +39,17 @@
{
ints.clear();
ints = cref_list_of_csv(a,b,3);
+ std::copy(
+ boost::begin(ints),
+ boost::end(ints),
+ std::ostream_iterator<int>(os," ")
+ );
BOOST_ASSERT(ints[0] == a);
BOOST_ASSERT(ints[1] == b);
BOOST_ASSERT(ints[2] == c);
}
+/*
{
array.assign(-1);
array = cref_list_of_csv(a,b,3);
@@ -57,11 +64,28 @@
BOOST_ASSERT(b == 0);
BOOST_ASSERT(c == 0);
}
+*/
}
+/*
{
// ref_rebind_list_of_csv
{
- int a=1, b=2, c=3;
+ int a=1, b=2, c=3;
+
+ {
+ int d = 4;
+
+ BOOST_AUTO(
+ max,
+ *boost::max_element(
+ ref_rebind_list_of_csv(a,b,c)
+ )
+ );
+ max = d;
+ d = 5;
+ BOOST_ASSERT(max == 5);
+ }
+
ints.clear();
BOOST_AUTO(tmp,cref_rebind_list_of_csv(a,b,c));
{
@@ -81,6 +105,7 @@
}
}
}
+*/
os << "<- " << std::endl;
Modified: sandbox/statistics/detail/assign/libs/assign/src/main.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/src/main.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/src/main.cpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -1,13 +1,13 @@
#include <iostream>
#include <libs/assign/example/ref_list_of.h>
-#include <libs/assign/test/speed.h>
-#include <libs/assign/test/speed2.h>
+//#include <libs/assign/test/speed.h>
+//#include <libs/assign/test/speed2.h>
int main (int argc, char * const argv[]) {
example_ref_list_of(std::cout);
- test_speed(std::cout);
- test_speed2(std::cout);
+ //test_speed(std::cout);
+ //test_speed2(std::cout);
return 0;
Modified: sandbox/statistics/detail/assign/libs/assign/test/speed.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/speed.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/test/speed.cpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -183,7 +183,6 @@
}
}
}
-
{
N = 30;
assert(N < max_N);
@@ -317,7 +316,7 @@
}
}
}
-
+/*
{
N = 160;
assert(N < max_N);
@@ -427,6 +426,7 @@
}
}
}
+*/
os << "<- " << std::endl;
}
Modified: sandbox/statistics/detail/assign/libs/assign/test/speed.h
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/speed.h (original)
+++ sandbox/statistics/detail/assign/libs/assign/test/speed.h 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -2,8 +2,8 @@
// test::speed.h //
// //
//////////////////////////////////////////////////////////////////////////////
-#ifndef LIBS_ASSIGN_TEST_CREF_COPY_LIST_OF_SPEED_ER_2010_H
-#define LIBS_ASSIGN_TEST_CREF_COPY_LIST_OF_SPEED_ER_2010_H
+#ifndef LIBS_ASSIGN_TEST_SPEED_ER_2010_H
+#define LIBS_ASSIGN_TEST_SPEED_ER_2010_H
#include <ostream>
void test_speed(std::ostream&);
Modified: sandbox/statistics/detail/assign/libs/assign/test/static_list_of_auto_size.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/static_list_of_auto_size.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/test/static_list_of_auto_size.cpp 2010-03-04 22:41:05 EST (Thu, 04 Mar 2010)
@@ -68,28 +68,31 @@
void check_static_list_of_auto_size()
{
using namespace boost::assign;
+ {
+ BOOST_CHECK( cref_list_of( 1 )( 2 )( 3 )( 4 ).size() == 4 );
- BOOST_CHECK( cref_list_of( 1 )( 2 )( 3 )( 4 ).size() == 4 );
-
- int a=1,b=5,c=3,d=4,e=2,f=9,g=0,h=7;
+ int a=1,b=5,c=3,d=4,e=2,f=9,g=0,h=7;
- int& max = *max_element( ref_list_of(a)(b)(c)(d)(e)(f)(g)(h) );
- BOOST_CHECK_EQUAL( max, f );
- max = 8;
- BOOST_CHECK_EQUAL( f, 8 );
- const int& const_max = *max_element( cref_list_of(a)(b)(c)(d)(e)(f)(g)(h) );
- BOOST_CHECK_EQUAL( max, const_max );
-
- print( ref_list_of(a)(b)(c)(d)(e)(f)(g)(h) );
- print( cref_list_of(a)(b)(c)(d)(e)(f)(g)(h) );
-
- boost::array<int,4> array = cref_list_of(1)(2)(3)(4);
-
- BOOST_CHECK_EQUAL( array[0], 1 );
- BOOST_CHECK_EQUAL( array[3], 4 );
- //
- //print( cref_list_of( "foo" )( "bar" )( "foobar" ) );
- //
+ int& max = *max_element( ref_list_of(a)(b)(c)(d)(e)(f)(g)(h) );
+ BOOST_CHECK_EQUAL( max, f );
+ max = 8;
+ BOOST_CHECK_EQUAL( f, 8 );
+ const int& const_max = *max_element(
+ cref_list_of(a)(b)(c)(d)(e)(f)(g)(h)
+ );
+ BOOST_CHECK_EQUAL( max, const_max );
+
+ print( ref_list_of(a)(b)(c)(d)(e)(f)(g)(h) );
+ print( cref_list_of(a)(b)(c)(d)(e)(f)(g)(h) );
+
+ boost::array<int,4> array = cref_list_of(1)(2)(3)(4);
+
+ BOOST_CHECK_EQUAL( array[0], 1 );
+ BOOST_CHECK_EQUAL( array[3], 4 );
+ //
+ //print( cref_list_of( "foo" )( "bar" )( "foobar" ) );
+ //
+ }
}
#include <boost/test/unit_test.hpp>
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