Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60506 - in sandbox/statistics/detail/assign/boost/assign: auto_size/detail chain
From: erwann.rogard_at_[hidden]
Date: 2010-03-12 01:52:20


Author: e_r
Date: 2010-03-12 01:52:19 EST (Fri, 12 Mar 2010)
New Revision: 60506
URL: http://svn.boost.org/trac/boost/changeset/60506

Log:
m
Added:
   sandbox/statistics/detail/assign/boost/assign/chain/
   sandbox/statistics/detail/assign/boost/assign/chain/add_const.hpp (contents, props changed)
   sandbox/statistics/detail/assign/boost/assign/chain/auto_convert.hpp (contents, props changed)
   sandbox/statistics/detail/assign/boost/assign/chain/converter.hpp (contents, props changed)
   sandbox/statistics/detail/assign/boost/assign/chain/is_reference_wrapper.hpp (contents, props changed)
   sandbox/statistics/detail/assign/boost/assign/chain/pair_traits.hpp (contents, props changed)
   sandbox/statistics/detail/assign/boost/assign/chain/reference_traits.hpp (contents, props changed)
   sandbox/statistics/detail/assign/boost/assign/chain/reference_wrapper_traits.hpp (contents, props changed)
Text files modified:
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp | 1 -
   1 files changed, 0 insertions(+), 1 deletions(-)

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-12 01:52:19 EST (Fri, 12 Mar 2010)
@@ -20,7 +20,6 @@
 #include <boost/type_traits.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/range.hpp>
-//#include <boost/range/chain.hpp>
 #include <boost/assign/auto_size/array/has_static_size.hpp>
 #include <boost/assign/auto_size/array/static_size.hpp>
 #include <boost/assign/auto_size/reference_wrapper/copy.hpp>

Added: sandbox/statistics/detail/assign/boost/assign/chain/add_const.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/chain/add_const.hpp 2010-03-12 01:52:19 EST (Fri, 12 Mar 2010)
@@ -0,0 +1,27 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::add_const.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_AUTO_SIZE_CHAIN_ADD_CONST_ER_2010_HPP
+#define BOOST_ASSIGN_DETAIL_AUTO_SIZE_CHAIN_ADD_CONST_ER_2010_HPP
+#include <boost/type_traits.hpp>
+
+namespace boost{
+namespace assign{
+namespace detail{
+
+ // This is only for testing purposes
+
+ template<typename Rng>
+ typename boost::add_const<Rng>::type
+ add_const(Rng& rng){ return rng; }
+
+}// detail
+}// assign
+}// boost
+
+#endif

Added: sandbox/statistics/detail/assign/boost/assign/chain/auto_convert.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/chain/auto_convert.hpp 2010-03-12 01:52:19 EST (Fri, 12 Mar 2010)
@@ -0,0 +1,106 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::chain_auto_convert.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_CHAIN_AUTO_CONVERT_ER_2010_HPP
+#define BOOST_ASSIGN_DETAIL_CHAIN_AUTO_CONVERT_ER_2010_HPP
+#include <boost/typeof/typeof.hpp>
+#include <boost/range.hpp>
+#include <boost/range/chain.hpp>
+#include <boost/assign/chain/pair_traits.hpp>
+#include <boost/assign/chain/converter.hpp>
+
+namespace boost{
+namespace assign{
+namespace detail{
+namespace result_of{
+namespace chain_auto_convert{
+
+ template<typename Conv,typename R1,typename R2>
+ struct generic{
+ typedef typename boost::range_reference<R1>::type r1_;
+ typedef typename boost::range_reference<R2>::type r2_;
+ typedef typename Conv::template apply<r1_,r2_>::type to_;
+ typedef result_of::convert_range<to_,R1> caller1_;
+ typedef result_of::convert_range<to_,R2> caller2_;
+ typedef typename caller1_::type conv_r1_;
+ typedef typename caller2_::type conv_r2_;
+ static conv_r1_& conv_r1;
+ static conv_r2_& conv_r2;
+ typedef BOOST_TYPEOF_TPL(
+ boost::chain(
+ conv_r1,
+ conv_r2
+ )
+ ) type;
+
+ // MSVC:
+ //typedef BOOST_TYPEOF_NESTED_TYPEDEF_TPL(
+ // nested,
+ // boost::chain(conv1,conv22)
+ //);
+ //typedef typename nested::type type;
+
+ typedef detail::functional::converter<to_> converter_;
+ static type call(R1& r1, R2& r2){
+ conv_r1_ conv_r1 = caller1_::call(r1);
+ conv_r2_ conv_r2 = caller2_::call(r2);
+ return boost::chain(conv_r1,conv_r2);
+ // boost::chain(caller1_::call(r1),caller2_::call(r2)); // Not!
+ }
+ };
+
+ template<typename R1,typename R2>
+ struct ignore_wrapper
+ : chain_auto_convert::generic<pair_traits::meta::ignore_wrapper,R1,R2>
+ {};
+
+ template<typename R1,typename R2>
+ struct filter_wrapper
+ : chain_auto_convert::generic<pair_traits::meta::filter_wrapper,R1,R2>
+ {};
+
+}// chain_auto_convert
+}// result_of
+
+ // generic
+ template<typename Conv,typename R1,typename R2>
+ typename result_of::chain_auto_convert::generic<Conv,R1,R2>::type
+ chain_auto_convert(R1& r1, R2& r2){
+ typedef result_of::chain_auto_convert::generic<Conv,R1,R2> g_;
+ return g_::call(r1,r2);
+ }
+
+ // ignore_wrapper
+ template<typename R1,typename R2>
+ typename result_of::chain_auto_convert::ignore_wrapper<R1,R2>::type
+ chain_auto_convert_ignore_wrapper(R1& r1,R2& r2){
+ typedef result_of::chain_auto_convert::ignore_wrapper<R1,R2> g_;
+ return g_::call(r1,r2);
+ }
+
+ // filter_wrapper
+ template<typename R1,typename R2>
+ typename result_of::chain_auto_convert::filter_wrapper<R1,R2>::type
+ chain_auto_convert_filter_wrapper(R1& r1,R2& r2){
+ typedef result_of::chain_auto_convert::filter_wrapper<R1,R2> g_;
+ return g_::call(r1,r2);
+ }
+
+ // default
+ template<typename R1,typename R2>
+ typename result_of::chain_auto_convert::filter_wrapper<R1,R2>::type
+ chain_auto_convert(R1& r1,R2& r2){
+ typedef result_of::chain_auto_convert::filter_wrapper<R1,R2> g_;
+ return g_::call(r1,r2);
+ }
+
+}// detail
+}// assign
+}// boost
+
+#endif

Added: sandbox/statistics/detail/assign/boost/assign/chain/converter.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/chain/converter.hpp 2010-03-12 01:52:19 EST (Fri, 12 Mar 2010)
@@ -0,0 +1,81 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::converter.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
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/range/adaptor/transformed.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+
+namespace boost{
+namespace assign{
+namespace detail{
+namespace functional{
+
+template<typename T>
+struct converter{
+
+ converter(){}
+
+ 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; }
+
+};
+
+}// functional
+
+namespace result_of{
+
+ template<typename T,typename Rng,
+ typename U = typename boost::range_reference<Rng>::type>
+ struct convert_range
+ {
+
+ BOOST_MPL_ASSERT((
+ boost::is_convertible<U,T>
+ ));
+ typedef functional::converter<T> adaptor_;
+ typedef boost::transform_range<adaptor_,Rng> type;
+ static type call(Rng& r){
+ return type(adaptor_(),r);
+ }
+ };
+
+}
+
+ // This seems to take care of const Rng. Overloads with const Rng have
+ // compile deficiencies. TODO verify this.
+
+ template<typename T,typename Rng>
+ typename detail::result_of::convert_range<T,Rng>::type
+ convert_range( Rng& r)
+ {
+ typedef detail::result_of::convert_range<T,Rng> caller_;
+ return caller_::call( r );
+ }
+
+ template<typename T,typename Rng>
+ inline typename detail::result_of
+ ::convert_range<T,Rng>::type
+ operator|( Rng& r, const detail::functional::converter<T>& f )
+ {
+ return convert_range<T>(r);
+ }
+
+
+}// detail
+}// assign
+}// boost
+
+#endif

Added: sandbox/statistics/detail/assign/boost/assign/chain/is_reference_wrapper.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/chain/is_reference_wrapper.hpp 2010-03-12 01:52:19 EST (Fri, 12 Mar 2010)
@@ -0,0 +1,25 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::is_ref_wrapper.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_CHAIN_IS_REFERENCE_WRAPPER_IS_ER_2010_HPP
+#define BOOST_ASSIGN_DETAIL_CHAIN_IS_REFERENCE_WRAPPER_IS_ER_2010_HPP
+#include <boost/mpl/bool.hpp>
+
+namespace boost{
+namespace assign{
+namespace detail{
+
+ // specialize on T
+ template<typename T>
+ struct is_ref_wrapper : boost::mpl::bool_<false>{};
+
+}// detail
+}// assign
+}// boost
+
+#endif

Added: sandbox/statistics/detail/assign/boost/assign/chain/pair_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/chain/pair_traits.hpp 2010-03-12 01:52:19 EST (Fri, 12 Mar 2010)
@@ -0,0 +1,97 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::pair_auto_convert.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_PAIR_AUTO_CONVERT_ER_2010_HPP
+#define BOOST_ASSIGN_DETAIL_PAIR_AUTO_CONVERT_ER_2010_HPP
+#include <utility>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/assign/chain/reference_traits.hpp>
+
+// The purpose of these traits is, given T and U, to find V such that
+// V v1 = t; V v2 = u;
+// is a valid expression. U and T may be references or reference wrappers
+
+namespace boost{
+namespace assign{
+namespace detail{
+namespace pair_traits{
+
+ template<typename T,typename U>
+ struct use_const : boost::mpl::or_<
+ typename reference_traits::is_const<T>::type,
+ typename reference_traits::is_const<U>::type
+ >{};
+
+ template<typename T,typename U>
+ struct use_reference : boost::mpl::and_<
+ typename boost::is_reference<T>::type,
+ typename boost::is_reference<U>::type
+ >{};
+
+ template<typename T,typename U>
+ struct filter_ref_const{
+ typedef typename pair_traits::use_reference<T,U>::type use_ref_;
+ typedef typename pair_traits::use_const<T,U>::type use_const_;
+ template<typename F,typename S>
+ struct pair{
+ typedef F first_type;
+ typedef S second_type;
+ };
+ template<typename V>
+ struct local
+ : reference_traits::filter_ref_const<
+ use_ref_::value,use_const_::value,V>{};
+ typedef typename local<T>::type first_;
+ typedef typename local<U>::type second_;
+ typedef pair<first_,second_> type;
+ };
+
+ template<typename T,typename U>
+ struct ignore_wrapper
+ {
+ typedef typename pair_traits::filter_ref_const<T,U>::type traits_;
+ typedef typename traits_::first_type first_;
+ typedef typename traits_::second_type second_;
+ typedef
+ typename boost::is_convertible<first_,second_>::type use_second_;
+ typedef typename
+ boost::mpl::if_c<use_second_::value,second_,first_>::type type;
+ BOOST_MPL_ASSERT((boost::is_convertible<first_,type>));
+ BOOST_MPL_ASSERT((boost::is_convertible<second_,type>));
+ };
+
+ template<typename T,typename U>
+ struct filter_wrapper : pair_traits::ignore_wrapper<
+ typename reference_traits::filter_wrapper<T>::type,
+ typename reference_traits::filter_wrapper<U>::type
+ >{};
+
+ namespace meta{
+
+ template<template<typename,typename> class M>
+ struct helper{
+ template<typename T,typename U>
+ struct apply : M<T,U>{};
+ };
+ struct ignore_wrapper : meta::helper<pair_traits::ignore_wrapper>{};
+ struct filter_wrapper : meta::helper<pair_traits::filter_wrapper>{};
+ }
+
+}// pair_traits
+}// detail
+}// assign
+}// boost
+
+#endif

Added: sandbox/statistics/detail/assign/boost/assign/chain/reference_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/chain/reference_traits.hpp 2010-03-12 01:52:19 EST (Fri, 12 Mar 2010)
@@ -0,0 +1,136 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::reference_traits.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_REFERENCE_TRAITS_ER_2010_HPP
+#define BOOST_ASSIGN_DETAIL_REFERENCE_TRAITS_ER_2010_HPP
+#include <utility>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/assign/chain/is_reference_wrapper.hpp>
+#include <boost/assign/chain/reference_wrapper_traits.hpp>
+
+// Maps U to a convertible type where U can be a reference_wrapper or a ref.
+
+namespace boost{
+namespace assign{
+namespace detail{
+namespace reference_traits{
+
+ template<typename T>
+ struct remove_cref : boost::remove_const<
+ typename boost::remove_reference<T>::type
+ >{};
+
+ template<typename T>
+ struct is_const : boost::is_const<
+ typename boost::remove_reference<T>::type
+ >{};
+
+ template<bool use_ref,bool use_const,typename T>
+ struct filter_ref_const{
+ typedef typename reference_traits::remove_cref<T>::type value_;
+ typedef typename boost::mpl::eval_if_c<
+ use_const,
+ boost::add_const<value_>,
+ boost::mpl::identity<value_>
+ >::type const_;
+ typedef typename boost::mpl::eval_if_c<
+ use_ref,
+ boost::add_reference<const_>,
+ boost::mpl::identity<const_>
+ >::type type;
+ };
+
+ template<typename T>
+ struct filter_wrapper{
+ typedef typename reference_traits::remove_cref<T>::type value_;
+ typedef typename detail::is_ref_wrapper<value_>::type is_rw_;
+ typedef typename boost::mpl::eval_if_c<
+ is_rw_::value,
+ ref_wrapper_traits::convertible_to<value_>,
+ boost::mpl::identity<T>
+ >::type type;
+ };
+
+namespace pair{
+
+ template<typename T,typename U>
+ struct use_const : boost::mpl::or_<
+ typename reference_traits::is_const<T>::type,
+ typename reference_traits::is_const<U>::type
+ >{};
+
+ template<typename T,typename U>
+ struct use_reference : boost::mpl::and_<
+ typename boost::is_reference<T>::type,
+ typename boost::is_reference<U>::type
+ >{};
+
+ template<typename T,typename U>
+ struct filter_ref_const{
+ typedef typename pair::use_reference<T,U>::type use_ref_;
+ typedef typename pair::use_const<T,U>::type use_const_;
+ template<typename V>
+ struct local
+ : reference_traits::filter_ref_const<
+ use_ref_::value,use_const_::value,V>{};
+ typedef typename local<T>::type first_;
+ typedef typename local<U>::type second_;
+ typedef std::pair<first_,second_> type;
+ };
+}// pair
+namespace convertible_to{
+
+ template<typename T,typename U>
+ struct ignore_wrapper
+ {
+ typedef typename pair::filter_ref_const<T,U>::type pair_;
+ typedef typename pair_::first first_;
+ typedef typename pair_::second second_;
+ typedef typename boost::is_convertible<
+ first_, // from
+ second_ // to
+ >::type use_second_;
+ typedef typename boost::mpl::if_c<
+ use_second_::value,
+ second_,
+ first_
+ >::type type;
+ BOOST_MPL_ASSERT((boost::is_convertible<first_,type>));
+ BOOST_MPL_ASSERT((boost::is_convertible<second_,type>));
+ };
+
+ template<typename T,typename U>
+ struct filter_wrapper : convertible_to::ignore_wrapper<
+ typename reference_traits::filter_wrapper<T>::type,
+ typename reference_traits::filter_wrapper<U>::type
+ >{};
+
+ namespace meta{
+
+ template<template<typename,typename> class M>
+ struct helper{
+ template<typename T,typename U>
+ struct apply : boost::mpl::identity< M<T,U> >{};
+ };
+ struct ignore_wrapper : meta::helper<convertible_to::ignore_wrapper>{};
+ struct filter_wrapper : meta::helper<convertible_to::filter_wrapper>{};
+ }
+
+}// convertible_to
+}// reference_traits
+}// detail
+}// assign
+}// boost
+
+#endif

Added: sandbox/statistics/detail/assign/boost/assign/chain/reference_wrapper_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/chain/reference_wrapper_traits.hpp 2010-03-12 01:52:19 EST (Fri, 12 Mar 2010)
@@ -0,0 +1,77 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::ref_wrapper_traits.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_REFERENCE_WRAPPER_TRAITS_ER_2010_HPP
+#define BOOST_ASSIGN_DETAIL_REFERENCE_WRAPPER_TRAITS_ER_2010_HPP
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits.hpp>
+
+namespace boost{
+namespace assign{
+namespace detail{
+namespace ref_wrapper_traits{
+
+ namespace tag{
+ struct default_{};
+ }
+
+ // specialize for each T
+ template<typename T>
+ struct tag_of{};
+
+ template<typename T,template<typename> class M>
+ struct helper : M<typename ref_wrapper_traits::tag_of<T>::type>
+ ::template apply<T>{};
+
+ namespace meta{
+ template<typename Tag>
+ struct value_of{
+ // define template<typename T> struct apply;
+ };
+
+ template<typename T> struct default_value_of{};
+ template<typename T,template<typename> class W>
+ struct default_value_of<W<T> >{ typedef T type; };
+
+ template<>
+ struct value_of<ref_wrapper_traits::tag::default_>
+ {
+ template<typename T>
+ struct apply : default_value_of<T>{};
+ };
+ }
+
+ template<typename T>
+ struct value_of
+ : ref_wrapper_traits::helper<T,meta::value_of>{};
+
+ namespace meta{
+ template<typename Tag>
+ struct convertible_to{
+ template<typename T> struct apply{};
+ };
+ template<>
+ template<typename T>
+ struct convertible_to<tag::default_>::apply<T>
+ : boost::add_reference<
+ typename ref_wrapper_traits::value_of<T>::type
+ >
+ {};
+ }
+
+ template<typename T>
+ struct convertible_to
+ : ref_wrapper_traits::helper<T,meta::convertible_to>{};
+
+}// ref_wrapper_traits
+}// detail
+}// assign
+}// boost
+
+#endif


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