Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60626 - in sandbox/statistics/detail/assign: boost/assign/auto_size/chain boost/assign/auto_size/check libs/assign/doc libs/assign/example libs/assign/src
From: erwann.rogard_at_[hidden]
Date: 2010-03-15 18:57:52


Author: e_r
Date: 2010-03-15 18:57:51 EDT (Mon, 15 Mar 2010)
New Revision: 60626
URL: http://svn.boost.org/trac/boost/changeset/60626

Log:
m
Text files modified:
   sandbox/statistics/detail/assign/boost/assign/auto_size/chain/as_member.hpp | 42 ++++----------------
   sandbox/statistics/detail/assign/boost/assign/auto_size/chain/chain_convert.hpp | 79 +++++++++++++++------------------------
   sandbox/statistics/detail/assign/boost/assign/auto_size/chain/converter.hpp | 67 +++++++++------------------------
   sandbox/statistics/detail/assign/boost/assign/auto_size/check/ref_list_of.hpp | 1
   sandbox/statistics/detail/assign/libs/assign/doc/index.html | 5 +-
   sandbox/statistics/detail/assign/libs/assign/example/chain.cpp | 7 ++-
   sandbox/statistics/detail/assign/libs/assign/src/main.cpp | 4 +-
   7 files changed, 68 insertions(+), 137 deletions(-)

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/chain/as_member.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/chain/as_member.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/chain/as_member.hpp 2010-03-15 18:57:51 EDT (Mon, 15 Mar 2010)
@@ -1,54 +1,30 @@
 //////////////////////////////////////////////////////////////////////////////
-// assign::detail::chain_as_member.hpp //
+// assign::detail::chain_convert_as_member.hpp //
 // //
 // (C) Copyright 2010 Erwann Rogard //
 // Use, modification and distribution are subject to the //
 // Boost Software License, Version 1.0. (See accompanying file //
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
 //////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_CHAINABLE_ER_2010_HPP
-#define BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_CHAINABLE_ER_2010_HPP
-#include <boost/type_traits/add_const.hpp>
-#include <boost/assign/auto_size/chain/chain_convert.hpp>
+#ifndef BOOST_ASSIGN_AUTO_SIZE_CHAIN_CONVERT_AS_MEMBER_ER_2010_HPP
+#define BOOST_ASSIGN_AUTO_SIZE_CHAIN_CONVERT_AS_MEMBER_ER_2010_HPP
+//#include <boost/assign/auto_size/chain/chain_convert.hpp>
 
 namespace boost{
 namespace assign{
 namespace detail{
 
-
- // D is a derived type that is boost::chain'able
+ // D is a derived type that is chainable
     template<typename D>
- class chain_as_member{
-
- template<bool add_const>
- struct adaptor :
- assign::adaptor::chain_convert<
- typename boost::add_const<D>::type
- >{};
-
- template<typename R,bool add_const>
- struct result_impl
- : adaptor<add_const>::template result_impl<R,add_const>{};
-
- public:
+ class chain_convert_as_member{
 
        // TODO : complete
        // chain_convert(R&);
        // chain_convert(const R&);
 
- typename adaptor<false>::type
- chain_convert_l_adaptor(){
- return assign::chain_convert_l(
- static_cast<D&>(*this)
- );
- }
-
- typename adaptor<true>::type
- chain_convert_r_adaptor()const{
- return assign::chain_convert_r(
- static_cast<const D&>(*this)
- );
- }
+ // TODO : complete
+ // chain_convert_adaptor();
+ // chain_convert_adaptor();
 
     };
     

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/chain/chain_convert.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/chain/chain_convert.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/chain/chain_convert.hpp 2010-03-15 18:57:51 EDT (Mon, 15 Mar 2010)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// assign::detail::chain_convert_impl.hpp //
+// assign::detail::chain_convert.hpp //
 // //
 // (C) Copyright 2010 Erwann Rogard //
 // Use, modification and distribution are subject to the //
@@ -26,9 +26,10 @@
 
 namespace adaptor{
 
-template<typename R1,
- typename Conv = detail::pair_traits::meta::apply_conversion>
-class chain_convert
+namespace impl{
+
+template<typename R1,typename Conv>
+class chain_converter
     : public boost::sub_range<R1>
 {
 
@@ -44,7 +45,7 @@
     struct result_impl_generic{
         typedef typename result_of::chain_convert_impl<Conv,X1,X2>::type
             facade_;
- typedef chain_convert<facade_,Conv> type;
+ typedef impl::chain_converter<facade_,Conv> type;
     };
 
     public:
@@ -65,7 +66,7 @@
     template<typename F,typename R2>
     struct result<F(const R2&)> : result_impl<R2,true>{};
 
- chain_convert(const R1 & r) : super_(r){}
+ chain_converter(const R1 & r) : super_(r){}
     
     template<typename R2>
     typename result_impl<R2,false>::type
@@ -88,77 +89,57 @@
     private:
     mutable super_ copy;
 };
-
+}// impl
 }// adaptor
 
+namespace result_of{
+ template<typename R,
+ typename Conv = detail::pair_traits::meta::apply_conversion>
+ struct chain_convert_l{
+ typedef adaptor::impl::chain_converter<R,Conv> type;
+ };
+ template<typename R,
+ typename Conv = detail::pair_traits::meta::apply_conversion>
+ struct chain_convert_r{
+ typedef adaptor::impl::chain_converter<const R,Conv> type;
+ };
+
+}// result_of
 
 template<typename Conv,typename R>
-adaptor::chain_convert<Conv,R>
+typename result_of::chain_convert_l<R,Conv>::type
 chain_convert_l(R & r)
 {
- typedef adaptor::chain_convert<Conv,R> result_;
+ typedef typename result_of::chain_convert_l<R,Conv>::type result_;
     return result_(r);
 }
 
 template<typename Conv,typename R>
-adaptor::chain_convert<Conv,const R>
+typename result_of::chain_convert_r<R,Conv>::type
 chain_convert_r(const R & r)
 {
- typedef adaptor::chain_convert<Conv,const R> result_;
+ typedef typename result_of::chain_convert_r<R,Conv>::type result_;
     return result_(r);
 }
 
-/*
-
-template<typename Conv,typename R1, typename R2>
-typename result_of::chain_convert<R2,Conv>::template apply<R1>::type
-operator|(R1 & r1, const adaptor::chain_convert<R2,Conv> & adaptor)
-{
- return adaptor(r1);
-}
-
-template<typename Conv,typename R1, typename R2>
-typename result_of::chain_convert<R2,Conv>::template apply<const R1>::type
-operator|(const R1 & r1, const adaptor::chain_convert<R2,Conv> & adaptor)
-{
- return adaptor(r1);
-}
-*/
-
 // default
 
 template<typename R>
-adaptor::chain_convert<R>
+typename result_of::chain_convert_l<R>::type
 chain_convert_l(R & r)
 {
- typedef adaptor::chain_convert<R> result_;
+ typedef typename result_of::chain_convert_l<R>::type result_;
     return result_(r);
 }
 
 template<typename R>
-adaptor::chain_convert<const R>
-chain_convert_r(const R & r) // force const
+typename result_of::chain_convert_r<R>::type
+chain_convert_r(const R & r)
 {
- typedef adaptor::chain_convert<const R> result_;
+ typedef typename result_of::chain_convert_r<R>::type result_;
     return result_(r);
 }
 
-
-template<typename R1, typename R2>
-typename adaptor::chain_convert<R2>::template result_impl<R1,false>::type
-operator|(R1 & r1, const adaptor::chain_convert<R2>& adaptor)
-{
- return adaptor(r1);
-}
-
-template<typename R1, typename R2>
-typename adaptor::chain_convert<const R2>::template result_impl<R1,true>::type
-operator|(R1 & r1, const adaptor::chain_convert<const R2>& adaptor)
-{
- return adaptor(r1);
-}
-
-
 }// assign
 }// boost
 

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-15 18:57:51 EDT (Mon, 15 Mar 2010)
@@ -1,24 +1,23 @@
 //////////////////////////////////////////////////////////////////////////////
-// assign::detail::convert.hpp //
+// assign::detail::convert_range.hpp //
 // //
 // (C) Copyright 2010 Erwann Rogard //
 // Use, modification and distribution are subject to the //
 // Boost Software License, Version 1.0. (See accompanying file //
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
 //////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_ASSIGN_DETAIL_CONVERTER_ER_2010_HPP
-#define BOOST_ASSIGN_DETAIL_CONVERTER_ER_2010_HPP
+#ifndef BOOST_ASSIGN_DETAIL_CONVERT_RANGE_ER_2010_HPP
+#define BOOST_ASSIGN_DETAIL_CONVERT_RANGE_ER_2010_HPP
 #include <boost/mpl/assert.hpp>
 #include <boost/range.hpp>
 #include <boost/range/adaptor/transformed.hpp>
 #include <boost/type_traits/is_same.hpp>
 #include <boost/type_traits/is_convertible.hpp>
+#include <boost/assign/auto_size/chain/convert_iterator.hpp>
 
 // Usage:
 // convert_range<T>(r)
-
-// There must be a better way to convert than 'transform'. An iterator adaptor
-// that alters the reference type should suffice.
+// changes range_reference<R>::type to T.
 
 namespace boost{
 namespace assign{
@@ -26,53 +25,21 @@
 namespace adaptor{
 
 template<typename T>
-struct convert{
-
- convert(){}
-
- typedef T result_type;
-
- template<typename U>
- T operator()(U& arg)const{ return arg; }
-
- template<typename U>
- T operator()(const U& arg)const{ return arg; }
-
-};
+struct convert_range{ convert_range(){} };
 
 }// adaptor
 
 namespace result_of{
-
+
     template<typename T,typename Rng,
         typename U = typename boost::range_reference<Rng>::type>
     struct convert_range
     {
- typedef adaptor::convert<T> adaptor_;
- typedef boost::transform_range<adaptor_,Rng> type;
+ typedef adaptor::convert_range<T> adaptor_;
+ typedef typename boost::range_iterator<Rng>::type base_it_;
+ typedef detail::iterator_converter<base_it_,T> new_it_;
+ typedef boost::iterator_range<new_it_> type;
 
-/*
-template<typename I,typename T>
-class iterator_converter : boost::iterator_adaptor<
- iterator_converter<I,T>,
- I,
- use_default,
- typename boost::remove_reference<T>::type,
- T,
- use_default
->{
- typedef boost::iterator_adaptor<
- iterator_converter<I,T>,
- I,
- use_default,
- typename boost::remove_reference<T>::type,
- T,
- use_default
- > super_;
-
- iterator_converter(const I& base):super_(base){}
-};
-*/
         static void internal_check(){
             BOOST_MPL_ASSERT((boost::is_convertible<U,T>));
             typedef typename boost::range_reference<type>::type new_ref_;
@@ -80,10 +47,13 @@
         }
         static type call(Rng& r){
             internal_check();
- return type(adaptor_(),r);
+ return type(
+ detail::convert_iterator<T>(boost::begin(r)),
+ detail::convert_iterator<T>(boost::end(r))
+ );
         }
     };
-
+
 }
 
     template<typename T,typename Rng>
@@ -104,7 +74,7 @@
     template<typename T,typename Rng>
     inline typename detail::result_of
             ::convert_range<T,Rng>::type
- operator|( Rng& r, const detail::adaptor::convert<T>& f )
+ operator|( Rng& r, const detail::adaptor::convert_range<T>& f )
     {
         return convert_range<T>(r);
     }
@@ -112,12 +82,11 @@
     template<typename T,typename Rng>
     inline typename detail::result_of
             ::convert_range<T,const Rng>::type
- operator|( const Rng& r, const detail::adaptor::convert<T>& f )
+ operator|( const Rng& r, const detail::adaptor::convert_range<T>& f )
     {
         return convert_range<T>(r);
     }
 
-
 }// detail
 }// assign
 }// boost

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/check/ref_list_of.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/check/ref_list_of.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/check/ref_list_of.hpp 2010-03-15 18:57:51 EDT (Mon, 15 Mar 2010)
@@ -148,6 +148,7 @@
 
 }
 
+// TODO see how the checks can be aggregated with the unit_test
 
 }// auto_size
 }// detail

Modified: sandbox/statistics/detail/assign/libs/assign/doc/index.html
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/doc/index.html (original)
+++ sandbox/statistics/detail/assign/libs/assign/doc/index.html 2010-03-15 18:57:51 EDT (Mon, 15 Mar 2010)
@@ -475,13 +475,14 @@
 
 </p>
 
-<h3>Functions <code>chain_convert_l()</code> and <code>chain_convert_r()</code><a name="chain_convert"></h3>
+<h3><a name="chain_convert">Functions <code>chain_convert_l()</code> and <code>chain_convert_r()</code></a></h3>
 
 While the function range() works in combination with functions
 such as list_of(), it is not compatible with
 <a href="#ref_csv"><code>ref_csv()</code></a>, <a href="#ref_list"><code>ref_list_of()</code></a> and their variants,
 which are part of a different framework. The functions <code>chain_convert_l()</code>,
-and <code>chain_convert_r()</code> achieve a similar goal and have the same interface as list_of(). Continuing the example above,
+and <code>chain_convert_r()</code> achieve a similar goal and have the same interface as list_of(),
+(an idea originating from M.P.G). Continuing the example above,
 
 
 <blockquote><pre><span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>assign</span><span class=special>/</span><span class=identifier>auto_size</span><span class=special>/</span><span class=identifier>chain_convert</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>&gt;</span>

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-15 18:57:51 EDT (Mon, 15 Mar 2010)
@@ -12,6 +12,7 @@
 #include <boost/ref.hpp>
 #include <boost/assign/auto_size/ref_list_of.hpp>
 #include <boost/assign/auto_size/reference_wrapper/conversion_traits.hpp>
+#include <boost/assign/auto_size/chain/converter.hpp>
 #include <boost/assign/auto_size/chain/chain_convert.hpp>
 #include <libs/assign/example/chain.h>
 
@@ -20,6 +21,8 @@
 
     //boost::assign::detail::chain_mpl_check::compound();
  
+
+
     using namespace boost::assign;
     using namespace boost::assign::detail;
         os << "-> example_chain: " << std::endl;
@@ -34,7 +37,7 @@
     ar_ ar5; ar5.assign( 3 );
         BOOST_AUTO(tmp1,ref_list_of(a)(b)(c)(d));
         BOOST_AUTO(tmp2,ref_list_of(e)(f)(g)(h));
-
+
     boost::copy(
         chain_convert_r(tmp2)(ar4)(ar5),
         std::ostream_iterator<val_>(os," ")
@@ -53,7 +56,7 @@
     boost::copy(
         chain_convert_r(ref_list_of(a)(b)(c)(d))(ar2)(ar3),
         std::ostream_iterator<val_>(os," ")
- ); os << " ---, tier segments in reverse order ---> " << std::endl;
+ ); os << " --- tier segments in reverse order ---> " << std::endl;
 
     boost::copy(
         chain_convert_r(ar3)(ar2)(ref_list_of(a)(b)(c)(d)),

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-15 18:57:51 EDT (Mon, 15 Mar 2010)
@@ -7,8 +7,8 @@
 
 int main (int argc, char * const argv[]) {
 
- boost::assign::detail::auto_size::check_ref_list_of<int>();
- std::cout << "check_ref_list_of : ok" << std::endl;
+ //boost::assign::detail::auto_size::check_ref_list_of<int>();
+ //std::cout << "check_ref_list_of : ok" << std::endl;
     //boost::assign::detail::auto_size::check_ref_csv<int>();
     //std::cout << "check_ref_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