|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66701 - in sandbox/statistics/support/boost/assign/v2/put: generic modifier
From: erwann.rogard_at_[hidden]
Date: 2010-11-23 09:58:45
Author: e_r
Date: 2010-11-23 09:58:43 EST (Tue, 23 Nov 2010)
New Revision: 66701
URL: http://svn.boost.org/trac/boost/changeset/66701
Log:
boost/assign/v2 small update
Text files modified:
sandbox/statistics/support/boost/assign/v2/put/generic/base.hpp | 8 ++++
sandbox/statistics/support/boost/assign/v2/put/modifier/incr_lookup.hpp | 63 ++++++++++++++++++++++----------------
sandbox/statistics/support/boost/assign/v2/put/modifier/repeat.hpp | 65 ++++++++++++++++++++++++---------------
3 files changed, 84 insertions(+), 52 deletions(-)
Modified: sandbox/statistics/support/boost/assign/v2/put/generic/base.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/put/generic/base.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/put/generic/base.hpp 2010-11-23 09:58:43 EST (Tue, 23 Nov 2010)
@@ -15,7 +15,13 @@
namespace v2{
namespace put_aux{
- struct put_base{};
+ struct put_base{
+
+ // This base is needed to be able to distinguish objects that serves as
+ // parameter buffers for a later use, and those, that actually need to
+ // be modified by a parameter. The latter must inherit publicly from
+ // put_base.
+ };
}// put_aux
}// v2
Modified: sandbox/statistics/support/boost/assign/v2/put/modifier/incr_lookup.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/put/modifier/incr_lookup.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/put/modifier/incr_lookup.hpp 2010-11-23 09:58:43 EST (Tue, 23 Nov 2010)
@@ -10,6 +10,8 @@
#ifndef BOOST_ASSIGN_V2_PUT_MODIFIER_INCR_LOOKUP_ER_2010_HPP
#define BOOST_ASSIGN_V2_PUT_MODIFIER_INCR_LOOKUP_ER_2010_HPP
#include <boost/mpl/apply.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/utility/enable_if.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/assign/v2/put/modifier/def.hpp>
#include <boost/assign/v2/detail/type_traits/value.hpp>
@@ -18,24 +20,20 @@
#include <boost/assign/v2/put/generic/new_fun.hpp>
#include <boost/assign/v2/put/generic/new_modifier.hpp>
#include <boost/assign/v2/put/generic/result_of_modulo.hpp>
-
-// Warning : Not yet supported.
-// TODO fix compile errors using put adaptor.
+#include <boost/assign/v2/put/generic/base.hpp>
namespace boost{
namespace assign{
namespace v2{
-
-// lookup_key
namespace modifier_tag{ struct incr_lookup{}; }
namespace put_aux{
template<>
struct modifier<v2::modifier_tag::incr_lookup>
{
-
+ typedef std::size_t size_type;
modifier():n( 0 ){}
- modifier(std::size_t m):n( m ){};
+ modifier(size_type const& m):n( m ){};
template<typename V,typename T>
void impl(V& v, BOOST_ASSIGN_V2_forward_param(T, t) )const{
@@ -43,21 +41,28 @@
}
private:
- std::size_t n;
+ size_type n;
};
- struct modulo_incr_lookup{
+ struct param_incr_lookup
+ {
- modulo_incr_lookup() : n( 1 ){}
- modulo_incr_lookup(std::size_t m) : n( m ){}
+ typedef std::size_t size_type;
- modulo_incr_lookup
- operator=(std::size_t m)const{
- typedef modulo_incr_lookup result_;
+ param_incr_lookup() : n( 1 ){}
+ param_incr_lookup(std::size_t m) : n( m ){}
+
+ param_incr_lookup
+ operator=(size_type const& m)const{
+ typedef param_incr_lookup result_;
return result_( m );
}
- std::size_t n;
+ size_type const& pop()const{ return this->n; }
+
+ private:
+
+ size_type n;
};
}// put_aux
@@ -66,18 +71,21 @@
template<typename T>
struct incr_lookup
{
+ typedef result_of_modulo::new_fun_modifier<T> meta_;
+ typedef functor_aux::identity fun_;
+ typedef v2::modifier_tag::incr_lookup tag_;
typedef typename boost::mpl::apply2<
- result_of_modulo::new_fun_modifier<T>,
- functor_aux::identity,
- v2::modifier_tag::incr_lookup
+ meta_,
+ fun_,
+ tag_
>::type type;
- typedef v2::modifier_tag::incr_lookup new_tag_;
- typedef put_aux::modifier<new_tag_> modifier_;
+ typedef put_aux::modifier<tag_> new_modifier_;
- static type call(const T& t, put_aux::modulo_incr_lookup const& kwd)
+ typedef put_aux::param_incr_lookup param_;
+ static type call(const T& t, param_ const& p)
{
- return type( t.unwrap(), _identity, kwd.n );
+ return type( t.unwrap(), _identity, param.pop() );
}
};
@@ -86,10 +94,13 @@
namespace put_aux{
template<typename T>
- typename result_of_modulo::incr_lookup<T>::type
+ typename boost::lazy_enable_if<
+ boost::is_base_of<put_aux::put_base, T>,
+ result_of_modulo::incr_lookup<T>
+ >::type
operator%(
T const& t,
- put_aux::modulo_incr_lookup const& kwd
+ put_aux::param_incr_lookup const& kwd
)
{
typedef result_of_modulo::incr_lookup<T> caller_;
@@ -98,8 +109,8 @@
}// put_aux
namespace{
- put_aux::modulo_incr_lookup const _incr_lookup
- = put_aux::modulo_incr_lookup();
+ put_aux::param_incr_lookup const _incr_lookup
+ = put_aux::param_incr_lookup();
}
}// v2
}// assign
Modified: sandbox/statistics/support/boost/assign/v2/put/modifier/repeat.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/put/modifier/repeat.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/put/modifier/repeat.hpp 2010-11-23 09:58:43 EST (Tue, 23 Nov 2010)
@@ -15,7 +15,7 @@
#include <boost/assign/v2/put/modifier/def.hpp>
#include <boost/assign/v2/put/generic/base.hpp>
#include <boost/assign/v2/put/generic/new_modifier.hpp>
-#include <boost/assign/v2/ref/wrapper/copy.hpp>
+//#include <boost/assign/v2/ref/wrapper/copy.hpp>
#include <boost/assign/v2/detail/pp/forward.hpp>
namespace boost{
@@ -27,66 +27,81 @@
namespace put_aux{
template<typename Tag>
- class modifier<v2::modifier_tag::repeat<Tag> > : v2::ref::wrapper<
+ class modifier<v2::modifier_tag::repeat<Tag> >
+ /*: v2::ref::wrapper<
v2::ref::assign_tag::copy,
std::size_t const
- >
+ >*/
{
typedef modifier<Tag> inner_;
- typedef v2::ref::wrapper<
+ /*typedef v2::ref::wrapper<
v2::ref::assign_tag::copy,
std::size_t const
- > super_t;
+ > super_t;*/
public:
typedef std::size_t size_type;
- modifier(){}
- explicit modifier( size_type const& n ):super_t( n ){};
+ modifier() : n( 1 ){}
+ // explicit modifier( size_type const& n ):super_t( n ){};
+ explicit modifier( size_type const& n_ ) : n( n ){};
- template<typename V,typename T>
- void impl(V& v, BOOST_ASSIGN_V2_forward_param(T, t) )
- const{
+ template<typename V, typename T>
+ void impl(V& v, BOOST_ASSIGN_V2_forward_param(T, t) )const
+ {
- size_type m = static_cast<super_t const&>(*this).unwrap();
+ size_type m = this->n; //static_cast<super_t const&>(*this).unwrap();
while(m--) this->inner.impl(
v,
BOOST_ASSIGN_V2_forward_arg(T, t)
);
}
- private:
+ size_type const& size()const{ return this->n; }
+
+ protected:
inner_ inner;
+ size_type n;
};
- class modulo_repeat : v2::ref::wrapper<
+ class param_repeat
+ /*: v2::ref::wrapper<
v2::ref::assign_tag::copy,
std::size_t const
- >
+ >*/
{
- typedef v2::ref::wrapper<
+
+ /*typedef v2::ref::wrapper<
v2::ref::assign_tag::copy,
std::size_t const
- > super_t;
+ > super_t;*/
public:
typedef std::size_t size_type;
- modulo_repeat(){}
- modulo_repeat( size_type const& n) : super_t( n ){}
+ param_repeat(){}
+ /*param_repeat( size_type const& n) : super_t( n ){}*/
+ param_repeat( size_type const& n_) : n( n_ ){}
- modulo_repeat operator=( size_type const& n)const
+ param_repeat operator=( size_type const& n_)const
{
- modulo_repeat result( n );
+ param_repeat result( n_ );
return result;
}
+ /*
size_type const& unwrap()const
{
return static_cast<super_t const&>(*this).unwrap();
}
+ */
+
+ size_type const& pop()const{ return this->n; }
+
+ protected:
+ size_type n;
};
@@ -104,10 +119,10 @@
new_tag_
>::type type;
- static type call(const T& t, put_aux::modulo_repeat const& h)
+ typedef put_aux::param_repeat param_;
+ static type call(const T& t, param_ const& p)
{
- modifier_ m( h.unwrap() );
- return type( t.unwrap(), t.fun, m );
+ return type( t.unwrap(), t.fun, p.pop() );
}
};
@@ -122,7 +137,7 @@
>::type
operator%(
T const& t,
- put_aux::modulo_repeat const& h
+ put_aux::param_repeat const& h
)
{
typedef result_of_modulo::repeat<T> caller_;
@@ -131,7 +146,7 @@
}// put_aux
namespace{
- put_aux::modulo_repeat const _repeat = put_aux::modulo_repeat();
+ put_aux::param_repeat const _repeat = put_aux::param_repeat();
}
}// v2
}// assign
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