Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59444 - in sandbox/statistics/detail: assign assign/boost assign/boost/assign assign/libs assign/libs/assign assign/libs/assign/example assign/libs/assign/src fusion/libs/statistics/detail/fusion/src range_ex/libs/statistics/detail/range_ex/doc range_ex/libs/statistics/detail/range_ex/example
From: erwann.rogard_at_[hidden]
Date: 2010-02-03 14:50:37


Author: e_r
Date: 2010-02-03 14:50:36 EST (Wed, 03 Feb 2010)
New Revision: 59444
URL: http://svn.boost.org/trac/boost/changeset/59444

Log:
add
Added:
   sandbox/statistics/detail/assign/
   sandbox/statistics/detail/assign/boost/
   sandbox/statistics/detail/assign/boost/assign/
   sandbox/statistics/detail/assign/boost/assign/cref_list_of2.hpp (contents, props changed)
   sandbox/statistics/detail/assign/libs/
   sandbox/statistics/detail/assign/libs/assign/
   sandbox/statistics/detail/assign/libs/assign/example/
   sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp (contents, props changed)
   sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.h (contents, props changed)
   sandbox/statistics/detail/assign/libs/assign/src/
   sandbox/statistics/detail/assign/libs/assign/src/main.cpp (contents, props changed)
Text files modified:
   sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/src/main.cpp | 2 ++
   sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/doc/readme.txt | 1 -
   sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/example/nest_chain.cpp | 9 +++++++++
   3 files changed, 11 insertions(+), 1 deletions(-)

Added: sandbox/statistics/detail/assign/boost/assign/cref_list_of2.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/cref_list_of2.hpp 2010-02-03 14:50:36 EST (Wed, 03 Feb 2010)
@@ -0,0 +1,127 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::cref_list_of2.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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_CREF_LIST_OF2_ER_2010_HPP
+#define BOOST_ASSIGN_CREF_LIST_OF2_ER_2010_HPP
+#include <boost/mpl/empty_base.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/mpl/plus.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/assign/list_of.hpp>
+#include <boost/type_traits.hpp>
+#include <boost/ref.hpp>
+#include <boost/array.hpp>
+#include <boost/range.hpp>
+
+namespace boost{
+namespace assign{
+
+// Usage : vec = cref_list2_of(a)(b)(c)
+
+template<
+ typename T,
+ int N,
+ typename B
+>
+class cref_impl : B{
+
+ typedef boost::reference_wrapper<const T> ref_;
+
+ typedef cref_impl<T,N,B> this_;
+
+ typedef typename boost::mpl::plus<
+ boost::mpl::int_<N>,
+ boost::mpl::int_<1>
+ >::type incr_n_;
+
+ template<typename T1>
+ struct next{ typedef cref_impl<T1,incr_n_::value,this_> type; };
+
+ typedef boost::mpl::bool_<false> false_;
+ typedef boost::mpl::bool_<true> true_;
+
+ template<typename T1>
+ struct array{ typedef boost::array<T1,N+1> type; };
+
+ typedef typename boost::is_same<
+ boost::mpl::int_<N>,
+ boost::mpl::int_<0>
+ >::type exit_impl_;
+
+ public:
+
+ typedef boost::mpl::bool_<exit_impl_::value> exit_;
+
+
+ cref_impl(const T& t):ref(t){}
+
+ cref_impl(const B& b,const T& t):B(b),ref(t){}
+
+ template<typename S>
+ struct result{};
+
+ template<typename F,typename T1>
+ struct result<F(const T1&)> : next<T1>{};
+
+ template<typename T1>
+ typename next<T1>::type
+ operator()(const T1& t)const{
+ typedef typename next<T1>::type next_;
+ return next_(*this,t);
+ }
+
+ template<typename T1>
+ operator typename array<T1>::type(){
+ typedef typename array<T1>::type ar_;
+ ar_ ar;
+ this->write_to_array(ar,exit_());
+ return ar;
+ }
+
+ // Requirement: C(begin,end) constructor
+ template<typename C>
+ operator C(){
+ typedef typename boost::range_value<C>::type val_;
+ typedef typename array<val_>::type ar_;
+ ar_ ar;
+ this->write_to_array(ar,exit_());
+ return C(boost::begin(ar),boost::end(ar));
+ }
+
+ template<typename A>
+ void write_to_array(A& ar,true_)const{
+ ar[N] = this->ref;
+ }
+
+ template<typename A>
+ void write_to_array(A& ar,false_)const{
+ ar[N] = this->ref;
+ return forward(*this,ar);
+ }
+
+ template<typename A>
+ static void forward(const B& b,A& ar){
+ typedef typename B::exit_ exit_;
+ return b.write_to_array(ar,exit_());
+ }
+
+ ref_ ref;
+};
+
+
+template<typename T>
+cref_impl<T,0,boost::mpl::empty_base>
+cref_list_of2(const T& t){
+ typedef cref_impl<T,0,boost::mpl::empty_base> res_;
+ return res_(t);
+}
+
+}// assign
+}// boost
+
+#endif

Added: sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp 2010-02-03 14:50:36 EST (Wed, 03 Feb 2010)
@@ -0,0 +1,30 @@
+#include <iostream>
+#include <vector>
+#include <boost/assign/list_of.hpp>
+#include <boost/assign/cref_list_of2.hpp>
+#include <libs/assign/example/cref_list_of2.h>
+
+void example_cref_list_of2(std::ostream& os)
+{
+ os << "-> example_cref_listof2 : " << std::endl;
+ using namespace boost::assign;
+
+ typedef std::vector<int> ints_;
+
+ int a=1,b=2;
+
+ ints_ ints;
+
+ ints = cref_list_of<3>(a)(b)(3);
+ BOOST_ASSERT(ints[0] == a);
+ BOOST_ASSERT(ints[1] == b);
+ BOOST_ASSERT(ints[2] == 3);
+ ints.clear();
+ ints = cref_list_of2(a)(b)(3); //(b);
+ BOOST_ASSERT(ints[0] == a);
+ BOOST_ASSERT(ints[1] == b);
+ BOOST_ASSERT(ints[2] == 3);
+
+ os << "<- " << std::endl;
+
+};

Added: sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.h 2010-02-03 14:50:36 EST (Wed, 03 Feb 2010)
@@ -0,0 +1,15 @@
+//////////////////////////////////////////////////////////////////////////////
+// example::list_of2.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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef LIBS_ASSIGN_EXAMPLE_CREF_LIST_OF2_ER_2010_HPP
+#define LIBS_ASSIGN_EXAMPLE_CREF_LIST_OF2_ER_2010_HPP
+#include <ostream>
+
+void example_cref_list_of2(std::ostream&);
+
+#endif
\ No newline at end of file

Added: sandbox/statistics/detail/assign/libs/assign/src/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/libs/assign/src/main.cpp 2010-02-03 14:50:36 EST (Wed, 03 Feb 2010)
@@ -0,0 +1,9 @@
+#include <iostream>
+#include <libs/assign/example/cref_list_of2.h>
+
+int main (int argc, char * const argv[]) {
+
+ example_cref_list_of2(std::cout);
+
+ return 0;
+}

Modified: sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/src/main.cpp
==============================================================================
--- sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/src/main.cpp (original)
+++ sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/src/main.cpp 2010-02-03 14:50:36 EST (Wed, 03 Feb 2010)
@@ -9,12 +9,14 @@
 #include <libs/statistics/detail/fusion/example/at_key.h>
 #include <libs/statistics/detail/fusion/example/serialize.h>
 #include <libs/statistics/detail/fusion/example/joint_view_binder.h>
+#include <libs/statistics/detail/fusion/example/joint_view_flatten_bind_range.h>
 
 int main(){
 
     example_at_key_iterator(std::cout);
     example_serialize(std::cout);
     example_joint_view_binder(std::cout);
+ example_joint_view_flatten_bind_range(std::cout);
 
     return 0;
 }

Modified: sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/doc/readme.txt
==============================================================================
--- sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/doc/readme.txt (original)
+++ sandbox/statistics/detail/range_ex/libs/statistics/detail/range_ex/doc/readme.txt 2010-02-03 14:50:36 EST (Wed, 03 Feb 2010)
@@ -29,7 +29,6 @@
 
 [ History ]
 
-
 January 25, 2010: MSVC workaround in /chain/result_of.hpp
 Januray 12, 2010 Added nest_chain
 

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-02-03 14:50:36 EST (Wed, 03 Feb 2010)
@@ -21,6 +21,7 @@
 #include <boost/fusion/include/at_c.hpp>
 #include <boost/fusion/include/vector.hpp>
 #include <boost/statistics/detail/range_ex/chain/nest.hpp>
+#include <boost/statistics/detail/range_ex/chain/chain2.hpp>
 #include <libs/statistics/detail/range_ex/example/nest_chain.h>
 
 void example_nest_chain(std::ostream& os)
@@ -81,5 +82,13 @@
             );
                 BOOST_ASSERT(boost::equal(chained,vec));
         }
+
+ range::chain2(
+ boost::fusion::at_c<0>(seq)
+ )(
+ boost::fusion::at_c<1>(seq)
+ )(
+ boost::fusion::at_c<2>(seq)
+ );
     
 }
\ 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