|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59215 - in sandbox/statistics/detail/range_ex: boost/statistics/detail/range_ex/chain boost/statistics/detail/range_ex/chain/detail libs/statistics/detail/range_ex/example libs/statistics/detail/range_ex/src
From: erwann.rogard_at_[hidden]
Date: 2010-01-21 19:42:12
Author: e_r
Date: 2010-01-21 19:42:11 EST (Thu, 21 Jan 2010)
New Revision: 59215
URL: http://svn.boost.org/trac/boost/changeset/59215
Log:
m
Added:
sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/dont_nest.hpp (contents, props changed)
sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/result_of_nest.hpp (contents, props changed)
Text files modified:
sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/nest.hpp | 51 +++++++++++++++++++++----------
sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.cpp | 64 ++++++++++++++++++++++++++-------------
sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/src/main.cpp | 3 +
3 files changed, 79 insertions(+), 39 deletions(-)
Added: sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/dont_nest.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/dont_nest.hpp 2010-01-21 19:42:11 EST (Thu, 21 Jan 2010)
@@ -0,0 +1,52 @@
+///////////////////////////////////////////////////////////////////////////////
+// range_ex::chain::detail::dont_nest.hpp //
+// //
+// Copyright 2008 Erwann Rogard. Distributed under 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_STATISTICS_DETAIL_RANGE_EX_CHAIN_DETAIL_DONT_NEST_HPP_ER_2010
+#define BOOST_STATISTICS_DETAIL_RANGE_EX_CHAIN_DETAIL_DONT_NEST_HPP_ER_2010
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/equal_to.hpp>
+
+#include <boost/type_traits.hpp>
+#include <boost/range.hpp>
+
+#include <boost/fusion/include/at_c.hpp>
+#include <boost/fusion/include/size.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace range{
+namespace impl{
+
+ template<typename Seq>
+ struct dont_nest :
+ boost::mpl::equal_to<
+ typename boost::fusion::result_of::size<Seq>::type,
+ boost::mpl::int_<1>
+ >{};
+
+namespace result_of{
+
+ // Case dont_nest
+ template<typename Seq>
+ struct first{
+ typedef typename boost::fusion::result_of::at_c<const Seq,0>::type type;
+ type static call(const Seq& seq){
+ return boost::fusion::at_c<0>(seq);
+ }
+ };
+
+}// result_of
+
+}// impl
+}// range
+}// detail
+}// statistics
+}// boost
+
+#endif
+
\ No newline at end of file
Added: sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/result_of_nest.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/result_of_nest.hpp 2010-01-21 19:42:11 EST (Thu, 21 Jan 2010)
@@ -0,0 +1,47 @@
+///////////////////////////////////////////////////////////////////////////////
+// range_ex::chain::detail::result_of_nest.hpp //
+// //
+// Copyright 2008 Erwann Rogard. Distributed under 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_STATISTICS_DETAIL_RANGE_EX_CHAIN_DETAIL_RESULT_OF_NEST_HPP_ER_2010
+#define BOOST_STATISTICS_DETAIL_RANGE_EX_CHAIN_DETAIL_RESULT_OF_NEST_HPP_ER_2010
+#include <boost/type_traits.hpp>
+
+#include <boost/fusion/include/back.hpp>
+#include <boost/fusion/include/pop_back.hpp>
+#include <boost/fusion/include/size.hpp>
+
+#include <boost/statistics/detail/range_ex/chain/detail/nest.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace range{
+namespace impl{
+namespace result_of{
+
+ // Case size(seq) > 1
+ template<typename Seq>
+ struct nest_chain : range::impl::nest_chain<
+ typename boost::remove_const<
+ typename boost::remove_reference<
+ typename boost::fusion::result_of::pop_back<Seq>::type
+ >::type
+ >::type,
+ typename boost::remove_const<
+ typename boost::remove_reference<
+ typename boost::fusion::result_of::back<Seq>::type
+ >::type
+ >::type
+ >{};
+
+}// result_of
+}// impl
+}// range
+}// detail
+}// statistics
+}// boost
+
+#endif
Modified: sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/nest.hpp
==============================================================================
--- sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/nest.hpp (original)
+++ sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/nest.hpp 2010-01-21 19:42:11 EST (Thu, 21 Jan 2010)
@@ -11,6 +11,13 @@
#include <boost/mpl/assert.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/greater.hpp>
+#include <boost/mpl/eval_if.hpp>
+
+#include <boost/utility/enable_if.hpp>
+
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/range.hpp>
#include <boost/fusion/include/back.hpp>
#include <boost/fusion/include/pop_back.hpp>
@@ -18,6 +25,8 @@
#include <boost/statistics/detail/range_ex/chain/result_of.hpp>
#include <boost/statistics/detail/range_ex/chain/detail/nest.hpp>
+#include <boost/statistics/detail/range_ex/chain/detail/dont_nest.hpp>
+#include <boost/statistics/detail/range_ex/chain/detail/result_of_nest.hpp>
namespace boost{
namespace statistics{
@@ -25,28 +34,36 @@
namespace range{
namespace result_of{
-
+
template<typename Seq>
- struct nest_chain : range::impl::nest_chain<
- typename boost::remove_const<
- typename boost::remove_reference<
- typename boost::fusion::result_of::pop_back<Seq>::type
- >::type
- >::type,
- typename boost::remove_const<
- typename boost::remove_reference<
- typename boost::fusion::result_of::back<Seq>::type
- >::type
- >::type
+ struct nest_chain : boost::mpl::eval_if<
+ range::impl::dont_nest<Seq>,
+ range::impl::result_of::first<Seq>,
+ range::impl::result_of::nest_chain<Seq>
>{};
-}
+}// result_of
+
+
+ // Usage for n=1
+ // nest_chain(fusion::make_vector(vec1));
+ template<typename Seq>
+ typename boost::lazy_enable_if<
+ range::impl::dont_nest<Seq>,
+ range::impl::result_of::first<Seq>
+ >::type
+ nest_chain(const Seq& seq){
+ typedef range::impl::result_of::first<Seq> meta_;
+ return meta_::call(seq);
+ }
- // Possible Usage:
- // nest_chain(fusion::make_vector(vec1,vec2,vec3,...));
- // TODO case size(seq) = 1 ?
+ // Usage for n>1
+ // nest_chain(fusion::make_vector(vec1,vec2,vec3,...vec_n));
template<typename Seq>
- typename range::result_of::nest_chain<Seq>::type
+ typename boost::lazy_disable_if<
+ range::impl::dont_nest<Seq>,
+ range::impl::result_of::nest_chain<Seq>
+ >::type
nest_chain(const Seq& seq){
typedef typename boost::fusion::result_of::size<Seq>::type size_;
typedef boost::mpl::int_<1> int1_;
Modified: sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.cpp
==============================================================================
--- sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.cpp (original)
+++ sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.cpp 2010-01-21 19:42:11 EST (Thu, 21 Jan 2010)
@@ -34,32 +34,52 @@
using namespace boost::assign;
+ typedef boost::fusion::vector<vec_> seq1_;
typedef boost::fusion::vector<vec_,list_,vec_> seq_;
-
+
+ BOOST_MPL_ASSERT((
+ range::impl::dont_nest<seq1_>
+ ));
+ seq1_ seq1;
seq_ seq;
-
- boost::fusion::at_c<0>(seq) += 0,1,2,3,4,5,6,7,8,9;
+ boost::fusion::at_c<0>(seq1) += 0,1,2,3,4,5,6,7,8,9;
+ boost::fusion::at_c<0>(seq) += 0,1,2,3,4,5,6,7,8,9;
boost::fusion::at_c<1>(seq) = list_of(10)(11)(12)(13)(14)(15)(16)(17)(18)(19);
boost::fusion::at_c<2>(seq) += 20, 21, 22, 23, 24, 25, 26, 27, 28, 29;
-
- typedef range::result_of::nest_chain<seq_>::type chained_;
-
- chained_ chained = range::nest_chain( seq );
- vec_ vec;
+
+ {
+ typedef range::result_of::nest_chain<seq1_>::type chained_;
+ chained_ chained = range::nest_chain( seq1 );
+ vec_ vec;
- boost::copy(
- boost::fusion::at_c<2>(seq),
- boost::copy(boost::fusion::at_c<1>(seq),
- boost::copy(boost::fusion::at_c<0>(seq), std::back_inserter(vec))
- )
- );
-
- std::copy(
- boost::begin(chained),
- boost::end(chained),
- std::ostream_iterator<val_>(std::cout," ")
- );
-
- BOOST_ASSERT(boost::equal(chained,vec));
+ boost::copy(
+ boost::fusion::at_c<0>(seq), std::back_inserter(vec)
+ );
+ std::copy(
+ boost::begin(chained),
+ boost::end(chained),
+ std::ostream_iterator<val_>(std::cout," ")
+ );
+ BOOST_ASSERT(boost::equal(chained,vec));
+ }
+ os << std::endl;
+ {
+ typedef range::result_of::nest_chain<seq_>::type chained_;
+ chained_ chained = range::nest_chain( seq );
+ vec_ vec;
+
+ boost::copy(
+ boost::fusion::at_c<2>(seq),
+ boost::copy(boost::fusion::at_c<1>(seq),
+ boost::copy(boost::fusion::at_c<0>(seq), std::back_inserter(vec))
+ )
+ );
+ std::copy(
+ boost::begin(chained),
+ boost::end(chained),
+ std::ostream_iterator<val_>(std::cout," ")
+ );
+ BOOST_ASSERT(boost::equal(chained,vec));
+ }
}
\ No newline at end of file
Modified: sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/src/main.cpp
==============================================================================
--- sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/src/main.cpp (original)
+++ sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/src/main.cpp 2010-01-21 19:42:11 EST (Thu, 21 Jan 2010)
@@ -11,6 +11,9 @@
int main(){
+ // Don't forget for your search paths that
+ // As of January 2010, /boost/range_ex is in the Vault.
+
example_nest_chain(std::cout);
return 0;
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