Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56886 - sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example
From: erwann.rogard_at_[hidden]
Date: 2009-10-16 00:13:46


Author: e_r
Date: 2009-10-16 00:13:45 EDT (Fri, 16 Oct 2009)
New Revision: 56886
URL: http://svn.boost.org/trac/boost/changeset/56886

Log:
a
Added:
   sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/at_key.cpp (contents, props changed)
   sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/at_key.h (contents, props changed)

Added: sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/at_key.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/at_key.cpp 2009-10-16 00:13:45 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,102 @@
+///////////////////////////////////////////////////////////////////////////////
+// statistics::detail::fusion::example::at_key_iterator.cpp //
+// //
+// Copyright 2009 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) //
+///////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <boost/mpl/int.hpp>
+#include <boost/utility/result_of.hpp>
+#include <boost/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/include/at_key.hpp>
+#include <boost/fusion/container/map.hpp>
+#include <boost/fusion/include/map.hpp>
+#include <boost/fusion/include/map_fwd.hpp>
+#include <boost/statistics/detail/fusion/at_key/functor.hpp>
+#include <boost/statistics/detail/fusion/at_key/iterator.hpp>
+
+#include <boost/iterator/iterator_traits.hpp>
+
+#include <libs/statistics/detail/fusion/example/iterator_at_key.h>
+
+void example_at_key_iterator(std::ostream& os){
+
+ os << "example_at_key_iterator -> ";
+
+ using namespace boost;
+ namespace stat = boost::statistics::detail;
+
+ typedef mpl::int_<0> key_0_;
+ typedef mpl::int_<1> key_1_;
+
+ typedef fusion::pair<key_0_,int> p_0_;
+ typedef fusion::pair<key_1_,int> p_1_;
+ typedef fusion::map<p_0_,p_1_> map_;
+ typedef stat::fusion::at_key::functor<key_0_> get_0_;
+ typedef stat::fusion::at_key::functor<key_1_> get_1_;
+ typedef std::vector<map_> vec_map_;
+ typedef range_iterator<const vec_map_>::type it_cvec_map_;
+ typedef stat::fusion::at_key::meta_iterator<it_cvec_map_,key_0_> m_0_;
+ typedef m_0_::type it_0_;
+ typedef stat::fusion::at_key::meta_iterator<it_cvec_map_,key_1_> m_1_;
+ typedef m_1_::type it_1_;
+
+ const unsigned n = 10;
+
+ vec_map_ vec_map; vec_map.reserve(n);
+ for(unsigned i = 0; i<n; i++){
+ map_ map(
+ fusion::make_pair<key_0_>( i ),
+ fusion::make_pair<key_1_>( i+1 )
+ );
+ vec_map.push_back(map);
+ }
+
+ {
+ typedef it_0_ it_;
+ typedef key_0_ key_;
+
+ it_ b = stat::fusion::at_key::make_iterator<key_>(
+ boost::begin(vec_map)
+ );
+ it_ e = stat::fusion::at_key::make_iterator<key_>(
+ boost::end(vec_map)
+ );
+ unsigned j = 0;
+ b<e;
+ for(it_ i = b; i<e; i++,j++)
+ {
+ BOOST_ASSERT(
+ *i == fusion::at_key<key_>(
+ vec_map[j]
+ )
+ );
+ }
+ }
+ {
+ typedef it_1_ it_;
+ typedef key_1_ key_;
+
+ it_ b = stat::fusion::at_key::make_iterator<key_>(
+ boost::begin(vec_map)
+ );
+ it_ e = stat::fusion::at_key::make_iterator<key_>(
+ boost::end(vec_map)
+ );
+ unsigned j = 0;
+ for(it_ i = b; i<e; i++,j++)
+ {
+ BOOST_ASSERT(
+ *i == fusion::at_key<key_>(
+ vec_map[j]
+ )
+ );
+ }
+ }
+
+ os << "<-" << std::endl;
+
+}
\ No newline at end of file

Added: sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/at_key.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/at_key.h 2009-10-16 00:13:45 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,14 @@
+///////////////////////////////////////////////////////////////////////////////
+// statistics::detail::fusion::example::at_key_iterator.h //
+// //
+// Copyright 2009 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_FUSION_EXAMPLE_AT_KEY_ITERATOR_HPP_ER_2009
+#define LIBS_STATISTICS_DETAIL_FUSION_EXAMPLE_AT_KEY_ITERATOR_HPP_ER_2009
+#include <iostream>
+
+void example_at_key_iterator(std::ostream&);
+
+#endif
\ 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