Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58955 - in sandbox/statistics/detail/range_ex: . boost boost/statistics boost/statistics/detail boost/statistics/detail/range_ex boost/statistics/detail/range_ex/chain boost/statistics/detail/range_ex/chain/detail libs libs/statistics libs/statistics/detail libs/statistics/detail/range_ex libs/statistics/detail/range_ex/example libs/statistics/detail/range_ex/src
From: erwann.rogard_at_[hidden]
Date: 2010-01-12 16:44:55


Author: e_r
Date: 2010-01-12 16:44:55 EST (Tue, 12 Jan 2010)
New Revision: 58955
URL: http://svn.boost.org/trac/boost/changeset/58955

Log:
adding range::nested_chain
Added:
   sandbox/statistics/detail/range_ex/
   sandbox/statistics/detail/range_ex/boost/
   sandbox/statistics/detail/range_ex/boost/statistics/
   sandbox/statistics/detail/range_ex/boost/statistics/detail/
   sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/
   sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/
   sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/
   sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/nest.hpp (contents, props changed)
   sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/nest.hpp (contents, props changed)
   sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/result_of.hpp (contents, props changed)
   sandbox/statistics/detail/range_ex/libs/
   sandbox/statistics/detail/range_ex/libs/statistics/
   sandbox/statistics/detail/range_ex/libs/statistics/detail/
   sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/
   sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/
   sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.cpp (contents, props changed)
   sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.h (contents, props changed)
   sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/src/
   sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/src/main.cpp (contents, props changed)

Added: sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/nest.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/detail/nest.hpp 2010-01-12 16:44:55 EST (Tue, 12 Jan 2010)
@@ -0,0 +1,140 @@
+///////////////////////////////////////////////////////////////////////////////
+// range_ex::chain::detail::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_NEST_HPP_ER_2010
+#define BOOST_STATISTICS_DETAIL_RANGE_EX_CHAIN_DETAIL_NEST_HPP_ER_2010
+#include <boost/mpl/equal_to.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/greater.hpp>
+
+#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/result_of.hpp>
+#include <boost/statistics/detail/range_ex/chain/detail/nest.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace range{
+
+namespace impl{
+
+ template<
+ typename Most,
+ typename Rhs,
+ bool exit = boost::mpl::equal_to<
+ typename boost::fusion::result_of::size<Most>::type,
+ boost::mpl::int_<1>
+ >::value
+ >
+ struct nest_chain{
+ // exit = Most has size one
+ };
+
+ template<typename Most,typename Rhs>
+ struct nest_chain<Most,Rhs,true>
+ {
+
+ BOOST_MPL_ASSERT_NOT((boost::is_reference<Most>));
+ BOOST_MPL_ASSERT_NOT((boost::is_reference<Rhs>));
+
+ typedef Most most_;
+
+ typedef
+ typename boost::fusion::result_of::back<most_>::type cref_back_;
+
+ typedef typename boost::remove_const<
+ typename boost::remove_reference<
+ cref_back_
+ >::type
+ >::type back_;
+
+ typedef typename statistics::detail::range::result_of::chain<
+ back_,
+ Rhs
+ >::type type;
+
+ template<typename Most1>
+ static type call(const Most1& most, const Rhs& rhs)
+ {
+ return boost::chain(
+ boost::fusion::back(most),rhs
+ );
+ }
+ };
+
+ template<typename Most,typename Rhs>
+ struct nest_chain<Most,Rhs,false>
+ {
+ BOOST_MPL_ASSERT_NOT((boost::is_reference<Most>));
+ BOOST_MPL_ASSERT_NOT((boost::is_reference<Rhs>));
+ typedef boost::mpl::int_<1> int1_;
+ typedef typename boost::fusion::result_of::size<Most>::type size_most_;
+ BOOST_MPL_ASSERT((
+ boost::mpl::greater<
+ size_most_,
+ int1_
+ >
+ ));
+
+ typedef
+ typename boost::fusion::result_of::pop_back<Most>::type
+ cref_next_most_;
+
+ typedef typename boost::remove_const<
+ typename boost::remove_reference<
+ cref_next_most_
+ >::type
+ >::type next_most_;
+
+ typedef
+ typename boost::fusion::result_of::back<Most>::type cref_back_;
+ typedef typename boost::remove_const<
+ typename boost::remove_reference<cref_back_>::type
+ >::type back_;
+
+ typedef typename statistics::detail::range::result_of::chain<
+ back_,
+ Rhs
+ >::type next_rhs_;
+
+ typedef
+ range::impl::nest_chain<next_most_,next_rhs_>
+ next_impl;
+
+ typedef typename next_impl::type type;
+
+ template<typename Most1>
+ static type call(const Most1& most, const Rhs& rhs)
+ {
+
+ return next_impl::call(
+ boost::fusion::pop_back(most),
+ boost::chain(
+ boost::fusion::back(most),
+ rhs
+ )
+ );
+ }
+ };
+
+}// impl
+
+}// range
+}// detail
+}// statistics
+}// boost
+
+#endif
+
+

Added: sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/nest.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/nest.hpp 2010-01-12 16:44:55 EST (Tue, 12 Jan 2010)
@@ -0,0 +1,101 @@
+///////////////////////////////////////////////////////////////////////////////
+// range_ex::chain::nest.hpp //
+// //
+// Copyright 2010 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_NEST_HPP_ER_2010
+#define BOOST_STATISTICS_DETAIL_RANGE_EX_CHAIN_NEST_HPP_ER_2010
+#include <boost/mpl/equal_to.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/greater.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/result_of.hpp>
+#include <boost/statistics/detail/range_ex/chain/detail/nest.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace range{
+
+namespace result_of{
+
+ // TODO :
+ // case size(seq) = 1 ?
+ // Why Most1!= Most
+
+ 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
+ >{};
+
+
+ // Alternatively?
+ // template<typename Seq>
+ // struct nest_chain{
+ // typedef typename statistics::detail::mpl::most<Seq>::type most_;
+ // typedef typename boost::mpl::back<Seq>::type back_;
+ //
+ // typedef typename boost::mpl::reverse_fold<
+ // most_,
+ // back_,
+ // statistics::detail::range::result_of
+ // ::chain<boost::mpl::_2,boost::mpl::_1>
+ // >::type
+ // >{};
+
+
+}
+
+ // Possible Usage:
+ // nest_chain(fusion::make_vector(vec1,vec2,vec3,...));
+ template<typename Seq>
+ typename range::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_;
+
+ BOOST_MPL_ASSERT(( boost::mpl::greater<size_,int1_>));
+
+ typedef typename
+ boost::fusion::result_of::pop_back<Seq>::type cref_most_;
+ typedef typename boost::remove_const<
+ typename boost::remove_reference<
+ cref_most_
+ >::type
+ >::type most_;
+ typedef typename boost::fusion::result_of::back<Seq>::type cref_back_;
+ typedef typename boost::remove_const<
+ typename boost::remove_reference<
+ cref_back_
+ >::type
+ >::type back_;
+
+ typedef range::impl::nest_chain<most_,back_> meta_;
+ return meta_::call(
+ boost::fusion::pop_back(seq),
+ boost::fusion::back(seq)
+ );
+ }
+
+}// range
+}// detail
+}// statistics
+}// boost
+
+#endif

Added: sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/result_of.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/range_ex/boost/statistics/detail/range_ex/chain/result_of.hpp 2010-01-12 16:44:55 EST (Tue, 12 Jan 2010)
@@ -0,0 +1,38 @@
+///////////////////////////////////////////////////////////////////////////////
+// range_ex::chain::result_of.hpp //
+// //
+// Copyright 2010 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_RESULT_OF_HPP_ER_2010
+#define BOOST_STATISTICS_DETAIL_RANGE_EX_CHAIN_RESULT_OF_HPP_ER_2010
+#include <boost/typeof/typeof.hpp>
+#include <boost/range/chain.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace range{
+
+ namespace result_of{
+
+ template<typename R1,typename R2>
+ struct chain{
+
+ typedef BOOST_TYPEOF_TPL(
+ boost::chain(
+ R1(),
+ R2()
+ )
+ ) type;
+ };
+
+ }
+
+}// range
+}// detail
+}// statistics
+}// boost
+
+#endif
\ No newline at end of file

Added: sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.cpp 2010-01-12 16:44:55 EST (Tue, 12 Jan 2010)
@@ -0,0 +1,65 @@
+//////////////////////////////////////////////////////////////////////////////
+// range_ex::example::nested_chain.cpp //
+// //
+// (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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <algorithm>
+#include <iterator>
+#include <vector>
+#include <list>
+
+#include <boost/typeof/typeof.hpp>
+#include <boost/assign/std/vector.hpp>
+#include <boost/assign/list_of.hpp>
+#include <boost/range/algorithm/copy.hpp>
+#include <boost/range/algorithm/equal.hpp>
+
+#include <boost/fusion/include/make_vector.hpp>
+#include <boost/fusion/include/at_c.hpp>
+#include <boost/fusion/include/vector.hpp>
+#include <boost/statistics/detail/range_ex/chain/nest.hpp>
+#include <libs/statistics/detail/range_ex/example/nest_chain.h>
+
+void example_nest_chain(std::ostream& os)
+{
+
+ namespace range = boost::statistics::detail::range;
+
+ typedef int val_;
+ typedef std::vector<val_> vec_;
+ typedef std::list<val_> list_;
+
+ using namespace boost::assign;
+
+ typedef boost::fusion::vector<vec_,list_,vec_> seq_;
+
+ seq_ seq;
+
+ 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;
+
+ 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

Added: sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.h 2010-01-12 16:44:55 EST (Tue, 12 Jan 2010)
@@ -0,0 +1,15 @@
+///////////////////////////////////////////////////////////////////////////////
+// example::range_ex::nest_chain.h //
+// //
+// Copyright 2010 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 LIBS_STATISTICS_DETAIL_RANGE_EX_NEST_CHAIN_H_ER_2010
+#define LIBS_STATISTICS_DETAIL_RANGE_EX_NEST_CHAIN_H_ER_2010
+
+#include <iostream>
+
+void example_nest_chain(std::ostream& os);
+
+#endif
\ No newline at end of file

Added: sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/src/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/src/main.cpp 2010-01-12 16:44:55 EST (Tue, 12 Jan 2010)
@@ -0,0 +1,17 @@
+//////////////////////////////////////////////////////////////////////////////
+// range_ex::src::main.cpp //
+// //
+// (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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include <libs/statistics/detail/range_ex/example/nest_chain.h>
+
+int main(){
+
+ example_nest_chain(std::cout);
+
+ return 0;
+}
\ No newline at end of file


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