Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60792 - in sandbox/statistics/detail/assign: boost/assign/auto_size/array libs/assign/example libs/assign/src
From: erwann.rogard_at_[hidden]
Date: 2010-03-23 11:17:19


Author: e_r
Date: 2010-03-23 11:17:17 EDT (Tue, 23 Mar 2010)
New Revision: 60792
URL: http://svn.boost.org/trac/boost/changeset/60792

Log:
m
Text files modified:
   sandbox/statistics/detail/assign/boost/assign/auto_size/array/converter.hpp | 27 +++++--------
   sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp | 78 +++++++++++++++++++++++++++++++++------
   sandbox/statistics/detail/assign/libs/assign/example/range.cpp | 2 +
   sandbox/statistics/detail/assign/libs/assign/src/main.cpp | 9 ++--
   4 files changed, 82 insertions(+), 34 deletions(-)

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/array/converter.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/array/converter.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/array/converter.hpp 2010-03-23 11:17:17 EDT (Tue, 23 Mar 2010)
@@ -9,43 +9,37 @@
 #ifndef BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_CONVERTER_ER_2010_HPP
 #define BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_CONVERTER_ER_2010_HPP
 #include <boost/typeof/typeof.hpp>
-#include <boost/assign/list_of.hpp> // for assign_detail::converter
-#include <boost/assign/auto_size/comparison_op/range.hpp>
 
 namespace boost{
 namespace assign{
 namespace detail{
 namespace auto_size{
 
- // This has yet to be figured out (how to forward to a crtp class).
     template< typename T, typename I >
     class converter
- : protected boost::assign_detail::converter<auto_size::converter<T,I>,I>
- , public range_comparison_op::base_of< T >::type
     {
- typedef auto_size::converter<T,I> this_;
- typedef boost::assign_detail::converter<this_,I> impl_;
 
- friend class boost::assign_detail::converter<this_,I>;
+// friend class boost::assign_detail::converter<this_,I>;
 
     public:
- typedef typename impl_::iterator iterator;
- typedef typename impl_::const_iterator const_iterator;
+ typedef typename I iterator;
+ typedef typename I const_iterator;
                 
         template< class Container >
         Container convert_to_container() const
         {
- return this->impl().convert_to_container<Container>();
+ return static_cast<
+ const T&>(*this).convert_to_container<Container>();
         }
         
         template< class Container >
         Container to_container( Container& c ) const
         {
- return this->impl().to_container(c);
+ return static_cast<const T&>(*this).to_container(c);
         }
 
         struct result_of_to_adapter{
- static const impl_ impl;
+ static const D impl;
             
             typedef BOOST_TYPEOF_TPL( impl.to_adapter() ) type;
         
@@ -56,24 +50,23 @@
         typename result_of_to_adapter::type
         to_adapter() const
         {
- return this->impl().to_adapter();
+ return static_cast<const T&>(*this).to_adapter();
         }
 
         template< class Adapter >
         Adapter to_adapter( Adapter& a ) const
         {
- return this->impl().to_adapter(a);
+ return static_cast<const T&>(*this).to_adapter(a);
         }
 
         template< class Array >
         Array to_array( Array& a ) const
         {
- return this->impl().to_array(a);
+ return static_cast<const T&>(*this).to_array(a);
         }
 
     };
 
-
 }// auto_size
 }// detail
 }// assign

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp 2010-03-23 11:17:17 EDT (Tue, 23 Mar 2010)
@@ -13,9 +13,11 @@
 #include <boost/mpl/int.hpp>
 #include <boost/array.hpp>
 #include <boost/range.hpp>
-#include <boost/assign/auto_size/array/converter.hpp>
+#include <boost/assign/list_of.hpp>
+#include <boost/assign/auto_size/comparison_op/range.hpp>
 #include <boost/assign/auto_size/reference_wrapper/has_copy_semantics.hpp>
 #include <boost/assign/auto_size/array/ref.hpp>
+//#include <boost/assign/auto_size/array/converter.hpp>
 
 namespace boost{
 namespace assign{
@@ -41,26 +43,27 @@
 
     };
                    
- // Warning : do not yet use comparison operatators between array_interfaces.
-
     // Used as a base class of D, adds the array and conversion interface
     //
     // Requirements: let d1 and d2 instances of D and const D, respectively
     // Valid expression Result
     // d1.ref_array_impl() array_interface::ref_array_&
     // d2.ref_array_impl() array_interface::const ref_array_&
+ //
+ // All non comparison ops are forwarded to converter<>. Comparison ops
+ // are taken care of by range_comparison_op::base_of<>::type.
     template<typename T,std::size_t N,template<typename> class R,typename D>
     class array_interface
- : public
+ :
         assign_detail::converter<
             array_interface<T,N,R,D>,
             typename array_interface_traits<T,N,R>::const_iterator
- >
- //auto_size::converter<
- // array_interface<T,N,R,D>,
- // typename array_interface_traits<T,N,R>::const_iterator
- //>
+ >,
+ public range_comparison_op::base_of<
+ array_interface<T,N,R,D>
+ >::type
     {
+
         typedef array_interface_traits<T,N,R> traits;
         typedef typename traits::ref_ ref_;
         typedef typename traits::ref_array_ ref_array_;
@@ -94,10 +97,8 @@
         const_reference back() const{ return (this->ref_array()).back(); }
         
         void swap(array_interface& other){
- // Before March 19th :
- //(this->ref_array()).swap(other.ref_array());
- // does not swap anything under Mingw, hence the change below:
             typedef boost::mpl::int_<N> int_n_;
+ // TODO swap(this->ref_array(),other.ref_array());
             this->swap_impl(other,int_n_());
         }
 
@@ -106,6 +107,20 @@
             return this->assign(val,pred_());
         }
 
+ // converter
+ protected:
+ typedef assign_detail::converter<
+ array_interface<T,N,R,D>,
+ typename array_interface_traits<T,N,R>::const_iterator
+ > converter_;
+
+ friend class assign_detail::converter<
+ array_interface<T,N,R,D>,
+ typename array_interface_traits<T,N,R>::const_iterator
+ >;
+
+ public:
+
         template< class Container >
         operator Container() const
         {
@@ -113,6 +128,45 @@
                     this-> BOOST_NESTED_TEMPLATE convert_to_container<Container>();
         }
 
+ template< class Container >
+ Container convert_to_container() const
+ {
+ return converter_::template convert_to_container<Container>();
+ }
+
+ template< class Container >
+ Container to_container( Container& c ) const
+ {
+ return converter_::to_container(c);
+ }
+
+ struct result_of_to_adapter{
+ static const converter_ impl;
+
+ typedef BOOST_TYPEOF_TPL( impl.to_adapter() ) type;
+
+ // needed bec converter_::adapter_converter is private
+
+ };
+
+ typename result_of_to_adapter::type
+ to_adapter() const
+ {
+ return converter_::to_adapter();
+ }
+
+ template< class Adapter >
+ Adapter to_adapter( Adapter& a ) const
+ {
+ return converter_::to_adapter(a);
+ }
+
+ template< class Array >
+ Array to_array( Array& a ) const
+ {
+ return converter_::to_array(a);
+ }
+
         private:
         typedef boost::mpl::bool_<false> false_;
         typedef boost::mpl::bool_<true> true_;

Modified: sandbox/statistics/detail/assign/libs/assign/example/range.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/example/range.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/example/range.cpp 2010-03-23 11:17:17 EDT (Tue, 23 Mar 2010)
@@ -36,6 +36,8 @@
     BOOST_AUTO(tmp1,ref_list_of(a)(b));
     BOOST_AUTO(tmp2,ref_list_of(c)(d));
     BOOST_AUTO(tmp3,ref_list_of(e)(f));
+
+
     os << " chain_l(tmp1)(tmp2)(tmp3) = (";
     boost::copy(
         chain_convert_l(tmp1)(ar5)(tmp3),

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-23 11:17:17 EDT (Tue, 23 Mar 2010)
@@ -1,17 +1,16 @@
 #include <iostream>
 #define BOOST_ASSIGN_CHECK_EQUAL(a,b) BOOST_ASSERT(a==b)
-#include <boost/assign/auto_size/check/ref_list_of.hpp>
+//#include <boost/assign/auto_size/check/ref_list_of.hpp>
 //#include <boost/assign/auto_size/check/ref_csv.hpp>
 #undef BOOST_ASSIGN_CHECK_EQUAL
-//#include <libs/assign/example/chain.h>
 #include <libs/assign/example/range.h>
 
 int main (int argc, char * const argv[]) {
 
- using namespace boost::assign::detail::auto_size;
+ //using namespace boost::assign::detail::auto_size;
 
- check_ref_list_of_int();
- std::cout << "check_ref_list_of : ok" << std::endl;
+ //check_ref_list_of_int();
+ //std::cout << "check_ref_list_of : ok" << std::endl;
      //check_ref_csv_int();
      //std::cout << "check_csv : ok" << 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