Boost logo

Boost-Commit :

From: srajko_at_[hidden]
Date: 2007-07-23 19:56:29


Author: srajko
Date: 2007-07-23 19:56:28 EDT (Mon, 23 Jul 2007)
New Revision: 7517
URL: http://svn.boost.org/trac/boost/changeset/7517

Log:
add int_, static_producer

Text files modified:
   sandbox/SOC/2007/signals/boost/dataflow/phoenix/component/producer.hpp | 41 +++++++++++-
   sandbox/SOC/2007/signals/boost/dataflow/phoenix/connection/iterator_relative.hpp | 33 +++++++--
   sandbox/SOC/2007/signals/boost/dataflow/phoenix/static_value.hpp | 6 +
   sandbox/SOC/2007/signals/libs/signal_network/example/Jamfile.v2 | 4
   sandbox/SOC/2007/signals/libs/signal_network/example/example.cpp | 130 +++++++++++++++++++--------------------
   sandbox/SOC/2007/signals/libs/signal_network/example/fibonacci.cpp | 8 +-
   6 files changed, 135 insertions(+), 87 deletions(-)

Modified: sandbox/SOC/2007/signals/boost/dataflow/phoenix/component/producer.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/phoenix/component/producer.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/phoenix/component/producer.hpp 2007-07-23 19:56:28 EDT (Mon, 23 Jul 2007)
@@ -9,13 +9,14 @@
 #include <boost/dataflow/phoenix/support.hpp>
 
 namespace boost { namespace phoenix {
-
+
     template<typename T, typename Function>
     class producer : public Function
     {
     public:
         typedef boost::dataflow::phoenix_producer producer_category;
         typedef T produced_type;
+ typedef T value_type;
         
         producer(const Function &f) : Function(f) {}
         producer() {}
@@ -25,19 +26,50 @@
             value = Function::operator()();
         }
 
+ template<typename T1>
+ void operator()(T1 &t1)
+ {
+ value = Function::operator()(t1);
+ }
+
         T value;
     };
     
+ template<typename T, typename Function>
+ const producer<T, Function> *operator&(const producer<T, Function> &op2)
+ {
+ return boost::addressof(op2);
+ }
+
+ template<typename T, typename Function>
+ producer<T, Function> *operator&(producer<T, Function> &op2)
+ {
+ return boost::addressof(op2);
+ }
+
+ template<typename T, typename Function>
+ volatile producer<T, Function> *operator&(volatile producer<T, Function> &op2)
+ {
+ return boost::addressof(op2);
+ }
+
+ template<typename T, typename Function>
+ const volatile producer<T, Function> *operator&(const volatile producer<T, Function> &op2)
+ {
+ return boost::addressof(op2);
+ }
+
     template<typename T, typename Function>
- class producer2
+ class static_producer
     {
     public:
         typedef boost::dataflow::phoenix_producer producer_category;
         typedef T produced_type;
+ typedef T value_type;
         
         void operator()()
         {
- value = Function()();
+ value = Function::operator()();
         }
         
         template<typename T1>
@@ -47,9 +79,8 @@
         }
         
         T value;
-
- operator T&(){return value;}
     };
+
 
 } } // namespace boost::phoenix
 

Modified: sandbox/SOC/2007/signals/boost/dataflow/phoenix/connection/iterator_relative.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/phoenix/connection/iterator_relative.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/phoenix/connection/iterator_relative.hpp 2007-07-23 19:56:28 EDT (Mon, 23 Jul 2007)
@@ -7,8 +7,8 @@
 #define BOOST_DATAFLOW_PHOENIX_CONNECTION_ITERATOR_RELATIVE_HPP
 
 #include <boost/dataflow/phoenix/static_value.hpp>
+#include <boost/dataflow/phoenix/static_function.hpp>
 
-#include <boost/mpl/int.hpp>
 #include <boost/spirit/phoenix/core/argument.hpp>
 #include <boost/spirit/phoenix/operator/arithmetic.hpp>
 #include <boost/spirit/phoenix/operator/self.hpp>
@@ -18,14 +18,31 @@
 
 namespace iterator_relative
 {
-// function<boost::phoenix::impl::copy_advance_c<-1> > prev;
-// function<boost::phoenix::impl::copy_advance_c<-2> > prev2;
- BOOST_TYPEOF(*(boost::phoenix::arg_names::arg1-
- boost::phoenix::actor<boost::phoenix::static_value<boost::mpl::int_<2> > >())) const prev2;
- BOOST_TYPEOF(*(boost::phoenix::arg_names::arg1-
- boost::phoenix::actor<boost::phoenix::static_value<boost::mpl::int_<2> > >())) const prev1;
+ namespace impl
+ {
+ struct get_value
+ {
+ template<class T>
+ struct result
+ {
+ typedef const typename T::value_type & type;
+ };
+
+ template<class T>
+ typename result<T>::type operator()(const T &t) const
+ {
+ return t.value;
+ }
+ };
+
+ }
+
+ static_function<impl::get_value> const get_value = static_function<impl::get_value>();
+
+ BOOST_TYPEOF(get_value(*(boost::phoenix::arg_names::arg1-actor<int_<2> >()))) const prev2;
+ BOOST_TYPEOF(get_value(*(boost::phoenix::arg_names::arg1-actor<int_<1> >()))) const prev1;
 }
 
 } } // namespace boost::phoenix
 
-#endif // BOOST_DATAFLOW_PHOENIX_CONNECTION_ITERATOR_RELATIVE_HPP
\ No newline at end of file
+#endif // BOOST_DATAFLOW_PHOENIX_CONNECTION_ITERATOR_RELATIVE_HPP

Modified: sandbox/SOC/2007/signals/boost/dataflow/phoenix/static_value.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/phoenix/static_value.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/phoenix/static_value.hpp 2007-07-23 19:56:28 EDT (Mon, 23 Jul 2007)
@@ -7,6 +7,7 @@
 #ifndef BOOST_DATAFLOW_PHOENIX_STATIC_VALUE_HPP
 #define BOOST_DATAFLOW_PHOENIX_STATIC_VALUE_HPP
 
+#include <boost/mpl/int.hpp>
 #include <boost/spirit/phoenix/core/actor.hpp>
 
 namespace boost { namespace phoenix {
@@ -29,6 +30,9 @@
     }
 };
 
+template<int N>
+struct int_ : static_value<boost::mpl::int_<N> > {};
+
 } } // namespace boost::phoenix
 
-#endif // BOOST_DATAFLOW_PHOENIX_STATIC_VALUE_HPP
\ No newline at end of file
+#endif // BOOST_DATAFLOW_PHOENIX_STATIC_VALUE_HPP

Modified: sandbox/SOC/2007/signals/libs/signal_network/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/example/Jamfile.v2 2007-07-23 19:56:28 EDT (Mon, 23 Jul 2007)
@@ -11,7 +11,7 @@
       <define>BOOST_ALL_NO_LIB=1
     ;
 
-# exe example : example.cpp ;
+exe example : example.cpp ;
 # exe timing_example : timing_example.cpp ;
 # exe edit_distance : edit_distance.cpp ;
-exe fibonacci : fibonacci.cpp ;
\ No newline at end of file
+exe fibonacci : fibonacci.cpp ;

Modified: sandbox/SOC/2007/signals/libs/signal_network/example/example.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/example/example.cpp (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/example/example.cpp 2007-07-23 19:56:28 EDT (Mon, 23 Jul 2007)
@@ -1,85 +1,81 @@
-// Copyright Stjepan Rajko 2007. Use, modification and
-// distribution is subject to the Boost Software License, Version
-// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// Copyright 2007 Stjepan Rajko.
+// 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)
 
-//#include <boost/signal_network/function.hpp>
-//#include <boost/signal_network/storage.hpp>
+#include <boost/dataflow/phoenix/support.hpp>
+#include <boost/spirit/phoenix/operator/self.hpp>
+#include <boost/spirit/phoenix/core/composite.hpp>
+#include <boost/spirit/phoenix/core/compose.hpp>
+#include <boost/spirit/phoenix/detail/type_deduction.hpp>
+#include <boost/spirit/phoenix/operator/detail/unary_eval.hpp>
+#include <boost/spirit/phoenix/operator/detail/unary_compose.hpp>
+#include <boost/spirit/phoenix/operator/detail/binary_eval.hpp>
+#include <boost/spirit/phoenix/operator/detail/binary_compose.hpp>
 
-#include <boost/fusion/sequence/container/map.hpp>
-#include <iostream>
+#include <boost/utility/addressof.hpp>
 
 #include <boost/fusion/sequence/container/vector.hpp>
-#include <boost/fusion/sequence/view/transform_view.hpp>
-#include <boost/fusion/sequence/intrinsic.hpp>
-#include <boost/fusion/sequence/io.hpp>
-
-#include <boost/type_traits/add_reference.hpp>
+#include <boost/spirit/phoenix/core.hpp>
+#include <boost/typeof/typeof.hpp>
 
-namespace fusion = boost::fusion;
+#include <iostream>
+#include <vector>
 
-//using namespace boost;
+template<typename T>
+class wrapper : public T
+{
+ public:
+ void operator()()
+ {
+ }
+
+};
 
-float DoublerFunc(float x)
+template<typename T>
+wrapper<T> *operator & (wrapper<T> &t)
 {
- return x*2;
+ return boost::addressof(t);
 }
 
-namespace dataflow
+struct test
 {
- template<typename X>
- struct print;
 };
 
-namespace dataflow
-{
- template<>
- struct print<int>
- {
- void operator()(int x)
- {
- std::cout << x << std::endl;
- }
- };
-}
+struct test2 : public test {int x;};
 
-namespace specific
+struct test3
 {
- struct print : public dataflow::print<int> {};
-}
+ int x;
+ test t;
+};
 
-int main(int, char* [])
+using namespace boost;
+
+int main()
 {
- specific::print()(3);
-
- /*
- signals::storage<void (), signals::unfused> banger;
- signals::function<void (float), float(float), signals::unfused> double_fun1(&DoublerFunc);
- signals::function<void (float), float(float), signals::unfused> double_fun2(&DoublerFunc);
- signals::storage<void (float), signals::unfused> floater(1.0f);
- signals::storage<void (float), signals::unfused> collector(0.0f);*/
-
-/* floater >>= double_fun1 >>= double_fun2 >>= collector;
- floater.send();
-
- assert(collector.at<0>() == 4.0f);
-
- floater.disconnect_all_slots();*/
-
-/* banger >>= boost::fusion::at_key<void()> (floater.send_slot());
- typedef
- boost::fusion::map<
- boost::fusion::pair<void(), slot_selector_t<signals::storage<void (float), signals::unfused>, void()> >,
- boost::fusion::pair<void(const boost::fusion::vector<> &), slot_selector_t<signals::storage<void (float), signals::unfused>, void (const boost::fusion::vector<> &)> >
- > map_type;
-
- map_type m = floater.send_slot();
-
-// int x = default_slot<map_type, void()>()(m);
- floater >>= collector;
-// banger.send();
- floater.send();
- assert(collector.at<0>() == 1.0f);*/
-
- return 0;
-} // int main(int, char* [])
\ No newline at end of file
+ test t;
+ test2 t2;
+ test3 t3;
+
+ std::cout << sizeof(test) << std::endl;
+ std::cout << sizeof(test2) << std::endl;
+ std::cout << sizeof(test3) << std::endl;
+
+ std::cout << sizeof(t) << std::endl;
+ std::cout << sizeof(t2) << std::endl;
+ std::cout << sizeof(t3) << std::endl;
+
+ fusion::vector<int, int> vec;
+ fusion::vector2<int, int> vec2;
+
+ std::cout << sizeof(vec) << std::endl;
+ std::cout << sizeof(vec2) << std::endl;
+
+ wrapper<BOOST_TYPEOF(phoenix::arg_names::arg1)> wrap;
+ std::cout << sizeof(wrap) << std::endl;
+
+ //std::vector<BOOST_TYPEOF(phoenix::arg_names::arg1)> unwrap_vec(100);
+ std::vector<wrapper<BOOST_TYPEOF(phoenix::arg_names::arg1)> > wrap_vec(100);
+ (*wrap_vec.begin())();
+}

Modified: sandbox/SOC/2007/signals/libs/signal_network/example/fibonacci.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/example/fibonacci.cpp (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/example/fibonacci.cpp 2007-07-23 19:56:28 EDT (Mon, 23 Jul 2007)
@@ -145,11 +145,11 @@
     // each element of the vector contains relative links to the
     // previous two elements
     typedef std::vector<
- phoenix::producer2<fib_type, BOOST_TYPEOF(prev2 + prev1) >
+ phoenix::static_producer<fib_type, BOOST_TYPEOF(prev2 + prev1) >
> cells_type;
     
- std::cout << sizeof(phoenix::producer2<fib_type, BOOST_TYPEOF(prev2 + prev1)>) << std::endl;
-
+ std::cout << sizeof(phoenix::static_producer<fib_type, BOOST_TYPEOF(prev2 + prev1)>) << std::endl;
+
     cells_type cells(n);
     
     {
@@ -180,7 +180,7 @@
 int main (int argc, char * const argv[])
 {
     // never mind the overflow
- int len = 50000000;
+ int len = 5000000;
     
     // display the cell sizes and times...
     // most of the time comes from memory access (cell size)


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