Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60587 - in sandbox/statistics/detail/assign: boost/assign/auto_size/chain boost/assign/auto_size/check boost/assign/auto_size/detail boost/assign/auto_size/reference_wrapper libs/assign/example
From: erwann.rogard_at_[hidden]
Date: 2010-03-14 18:01:32


Author: e_r
Date: 2010-03-14 18:01:31 EDT (Sun, 14 Mar 2010)
New Revision: 60587
URL: http://svn.boost.org/trac/boost/changeset/60587

Log:
m
Text files modified:
   sandbox/statistics/detail/assign/boost/assign/auto_size/chain/auto_convert.hpp | 6 +-
   sandbox/statistics/detail/assign/boost/assign/auto_size/chain/converter.hpp | 16 ++++----
   sandbox/statistics/detail/assign/boost/assign/auto_size/chain/generalized_chain.hpp | 14 +++++---
   sandbox/statistics/detail/assign/boost/assign/auto_size/check/copy_iterator.hpp | 1
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp | 3 -
   sandbox/statistics/detail/assign/boost/assign/auto_size/reference_wrapper/rebind.hpp | 2
   sandbox/statistics/detail/assign/libs/assign/example/chain.cpp | 65 ++++++++++++++++------------------------
   7 files changed, 49 insertions(+), 58 deletions(-)

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/chain/auto_convert.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/chain/auto_convert.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/chain/auto_convert.hpp 2010-03-14 18:01:31 EDT (Sun, 14 Mar 2010)
@@ -17,9 +17,9 @@
 #include <iostream> // TODO remove
 
 // Usage:
-// chain_auto_convert(r1,r2)
-// returns a range that is formed by joining r1 and r2 whose reference is
-// convertible from either of those of r1 and r2.
+// boost::copy(r1,boost::begin(chain_auto_convert(r1,r2)));
+//
+// Note that this assignement cannot work with boost::chain(r1,r2)
 //
 // Requirements : if either of r1 or r1 contains reference wrappers (W) pointing
 // to some type T,

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/chain/converter.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/chain/converter.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/chain/converter.hpp 2010-03-14 18:01:31 EDT (Sun, 14 Mar 2010)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// assign::detail::converter.hpp //
+// assign::detail::convert.hpp //
 // //
 // (C) Copyright 2010 Erwann Rogard //
 // Use, modification and distribution are subject to the //
@@ -20,12 +20,12 @@
 namespace boost{
 namespace assign{
 namespace detail{
-namespace functional{
+namespace adaptor{
 
 template<typename T>
-struct converter{
+struct convert{
 
- converter(){}
+ convert(){}
 
     typedef T result_type;
 
@@ -37,7 +37,7 @@
 
 };
 
-}// functional
+}// adaptor
 
 namespace result_of{
         
@@ -45,7 +45,7 @@
         typename U = typename boost::range_reference<Rng>::type>
     struct convert_range
     {
- typedef functional::converter<T> adaptor_;
+ typedef adaptor::convert<T> adaptor_;
         typedef boost::transform_range<adaptor_,Rng> type;
         
         static void internal_check(){
@@ -79,7 +79,7 @@
     template<typename T,typename Rng>
     inline typename detail::result_of
             ::convert_range<T,Rng>::type
- operator|( Rng& r, const detail::functional::converter<T>& f )
+ operator|( Rng& r, const detail::adaptor::convert<T>& f )
     {
         return convert_range<T>(r);
     }
@@ -87,7 +87,7 @@
     template<typename T,typename Rng>
     inline typename detail::result_of
             ::convert_range<T,const Rng>::type
- operator|( const Rng& r, const detail::functional::converter<T>& f )
+ operator|( const Rng& r, const detail::adaptor::convert<T>& f )
     {
         return convert_range<T>(r);
     }

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/chain/generalized_chain.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/chain/generalized_chain.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/chain/generalized_chain.hpp 2010-03-14 18:01:31 EDT (Sun, 14 Mar 2010)
@@ -26,11 +26,11 @@
 
     namespace impl{
     
+
+ // There shouldn't be a need to add const, it's taken care of by
+ // Binary?
         template<typename Binary,typename R1,typename R2>
- struct caller : Binary::template apply<
- typename boost::add_const<R1>::type,
- typename boost::add_const<R2>::type
- >{};
+ struct caller : Binary::template apply<R1,R2>{};
     
         template<typename F,typename L>
         struct exit_cond;
@@ -43,7 +43,11 @@
             typedef typename boost::mpl::next<F>::type next_it_;
             typedef typename impl::generic<Binary,next_it_,L> next_;
             typedef typename next_::type arg2_;
- typedef generalized_chain::impl::caller<Binary,arg1_,arg2_> caller_;
+ typedef generalized_chain::impl::caller<
+ Binary,
+ typename boost::add_const<arg1_>::type,
+ typename boost::add_const<arg2_>::type
+ > caller_;
             typedef typename caller_::type type;
 
             BOOST_STATIC_CONSTANT(int,iteration = next_::iteration + 1);

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/check/copy_iterator.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/check/copy_iterator.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/check/copy_iterator.hpp 2010-03-14 18:01:31 EDT (Sun, 14 Mar 2010)
@@ -10,6 +10,7 @@
 #define BOOST_ASSIGN_DETAIL_AUTO_SIZE_CHECK_COPY_ITERATOR_ER_2010_HPP
 #include <algorithm>
 #include <boost/range.hpp>
+#include <boost/array.hpp>
 
 #ifndef BOOST_ASSIGN_CHECK_EQUAL
 #error

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp 2010-03-14 18:01:31 EDT (Sun, 14 Mar 2010)
@@ -45,8 +45,7 @@
 // with M.P.G
 //
 // range<int>() is provided to achieve conformity with the rest of Boost.Assign
-// but it is in fact ill suited here. The policy P, however, will usually
-// interoperate with chain_auto_convert which serves a similar purpose.
+// but it is in fact ill suited here.
 
 namespace boost{
 namespace assign{

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/reference_wrapper/rebind.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/reference_wrapper/rebind.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/reference_wrapper/rebind.hpp 2010-03-14 18:01:31 EDT (Sun, 14 Mar 2010)
@@ -24,7 +24,7 @@
         assign_reference_rebind( T& r ) : ref_(&r)
         { }
 
- void operator=( T& r )
+ void operator=( T& r ) // should it return itself?
         {
             this->ref_ = &r;
         }

Modified: sandbox/statistics/detail/assign/libs/assign/example/chain.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/example/chain.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/example/chain.cpp 2010-03-14 18:01:31 EDT (Sun, 14 Mar 2010)
@@ -9,8 +9,10 @@
 #include <boost/typeof/typeof.hpp>
 #include <boost/next_prior.hpp>
 #include <boost/range/algorithm/copy.hpp>
+#include <boost/ref.hpp>
 #include <boost/assign/auto_size/ref_list_of.hpp>
-#include <boost/assign/auto_size/chain_auto_convert.hpp>
+#include <boost/assign/auto_size/reference_wrapper/conversion_traits.hpp>
+#include <boost/assign/auto_size/chain/chain_convert.hpp>
 #include <libs/assign/example/chain.h>
 
 void example_chain(std::ostream& os)
@@ -22,63 +24,48 @@
     using namespace boost::assign::detail;
         os << "-> example_chain: " << std::endl;
     typedef int val_;
- const val_ a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8, i = 9 ;
- typedef boost::array<val_,3> ar_;
+ val_ a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8, i = 9 ;
+ typedef boost::array<val_,4> ar_;
     typedef std::vector<val_> vec_;
     ar_ ar1; ar1.assign( -1 );
     ar_ ar2; ar2.assign( 0 );
     ar_ ar3; ar3.assign( 1 );
     ar_ ar4; ar4.assign( 2 );
         BOOST_AUTO(tmp1,ref_list_of(a)(b)(c)(d));
- BOOST_AUTO(tmp2,cref_list_of(e)(f)(g)(h));
-
- const int shift = 0;
+ BOOST_AUTO(tmp2,ref_list_of(e)(f)(g)(h));
+
 
     boost::copy(
- chain_auto_convert(
- ref_list_of(a)(b)(c)(d),
- chain_auto_convert(
- cref_list_of(e)(f)(g)(h),
- ar1
- )
- ),
+ chain_convert(tmp2)(ar4),
         std::ostream_iterator<val_>(os," ")
+ ); os << " --- becomes ---> ";
+
+ boost::copy(
+ chain_convert(tmp1)(ar2),
+ boost::begin(chain_convert(tmp2)(ar4))
     );
- os << "chain(x,chain(y,z)) - rvalues : OK" << std::endl;
 
     boost::copy(
- chain_auto_convert(
- tmp1,
- chain_auto_convert(
- tmp2,
- ar1
- )
- ),
+ chain_convert(tmp2)(ar4),
         std::ostream_iterator<val_>(os," ")
- );
- os << "chain(x,chain(y,z)) - lvalues : OK" << std::endl;
+ ); os << " --- that should equal ---> ";
 
- //boost::copy(
- // chain_auto_convert(
- // ref_list_of(a)(b)(c)(d)
- // ,cref_list_of(e)(f)(g)(h)
- // ,ar1
- // ),
- // std::ostream_iterator<val_>(os," ")
- //); // EXC_BAD_ACCESS
- os << " chain(x,y,z)- rvalues : EXC_BAD_ACCESS" << std::endl;
-
     boost::copy(
- chain_auto_convert(
- tmp1
- ,tmp2
- ,ar1
- ),
+ chain_convert(ref_list_of(a)(b)(c)(d))(ar2),
         std::ostream_iterator<val_>(os," ")
     );
- os << "chain(x,y,z) - lvalues : Some faulty values" << std::endl;
 
 
+ // Why chain_convert is required :
+ //invalid initialization of reference of type 'boost::assign::detail::assign_reference_copy<example_chain::val_>&'
+ // from expression of type 'int'
+ //boost::copy(
+ // boost::chain(tmp1,ar2),
+ // boost::begin(
+ // boost::chain(tmp2,ar4)
+ // )
+ //);
+
         os << "<- " << std::endl;
     
 }


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