|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74556 - sandbox/variadic_templates/sandbox/stepper/libs/array_stepper/examples
From: cppljevans_at_[hidden]
Date: 2011-09-24 14:33:51
Author: cppljevans
Date: 2011-09-24 14:33:51 EDT (Sat, 24 Sep 2011)
New Revision: 74556
URL: http://svn.boost.org/trac/boost/changeset/74556
Log:
Demonstrates index_stack_length_stride_crtp_indices<>
Added:
sandbox/variadic_templates/sandbox/stepper/libs/array_stepper/examples/index_stack_length_stride_crtp~demo.cpp (contents, props changed)
Added: sandbox/variadic_templates/sandbox/stepper/libs/array_stepper/examples/index_stack_length_stride_crtp~demo.cpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/sandbox/stepper/libs/array_stepper/examples/index_stack_length_stride_crtp~demo.cpp 2011-09-24 14:33:51 EDT (Sat, 24 Sep 2011)
@@ -0,0 +1,69 @@
+#include <boost/array_stepper/index_stack_length_stride_crtp.hpp>
+
+#include <boost/utility/trace_scope.hpp>
+#include <iomanip>
+#include <boost/array_stepper/length_strides_offset_print.hpp>
+#include <boost/array_stepper/vector_print.hpp>
+
+using namespace boost::array_stepper;
+
+typedef index_stack_length_stride_crtp_types<>::indices_bounds_strides ibs_t;
+
+typedef index_stack_length_stride_crtp_indices<> lsos_t;
+
+char const*id_names[dec_ator+1]={"inc_ator","dec_ator"};
+template<inc_dec_enum ID>
+void test_inc_dec(lsos_t& lsos_v)
+{
+ ::boost::trace_scope ts("test_inc_dec:");
+ std::cout<<"ID="<<id_names[ID]<<"\n";
+ unsigned space=lsos_v.space();
+ {
+ for(unsigned node=0; node<space; ++node, ++lsos_v)
+ {
+ std::cout<<"node["<<std::setw(2)<<node<<"]=";
+ std::cout<<lsos_v<<"\n";
+ }
+ }
+}
+
+int main()
+{
+ boost::iostreams::indent_scoped_ostreambuf<char> indent_outbuf(std::cout,2);
+ typedef index_stack_length_stride_crtp_types<> types_t;
+ typedef length_strides_offset<> lso_t;
+ typedef std::vector<lso_t::length_dir_t> lengths_t;
+ typedef types_t::index_t index_t;
+ typedef long unsigned offset_t;
+ lengths_t lengths_v={2,3,4};
+ std::cout<<"lengths_v="<<lengths_v<<"\n";
+ lso_t lso_v( lengths_v);
+ std::cout<<"length_strides_offset=\n"<<lso_v<<"\n";
+ lso_t::length_strides_t lss_v=lso_v.length_strides();
+ lsos_t lsos_v( lss_v.begin(), lss_v.end());
+ test_inc_dec<inc_ator>(lsos_v);
+ #if 1
+ typedef types_t::axis_t axis_t;
+ axis_t axis_v=2;
+ index_t offset_v=1;
+ lsos_v.axis_offset_put(axis_v,offset_v,offset_v);
+ std::cout<<"axis_offset_put("<<axis_v<<","<<offset_v<<","<<offset_v<<"):\n";
+ lsos_v.axis_index_put(axis_v,lsos_v[axis_v].get<index_bound_lower>());
+ std::cout<<"axis_index_put("<<axis_v<<",index_bound_lower["<<axis_v<<"]):\n";
+ test_inc_dec<inc_ator>(lsos_v);
+ offset_v=0;
+ lsos_v.axis_offset_put(axis_v,offset_v,offset_v);
+ std::cout<<"axis_offset_put("<<axis_v<<","<<offset_v<<","<<offset_v<<"):\n";
+ lsos_v.axis_index_put(axis_v,lsos_v[axis_v].get<index_bound_lower>());
+ std::cout<<"axis_index_put("<<axis_v<<",index_bound_lower["<<axis_v<<"]):\n";
+ test_inc_dec<inc_ator>(lsos_v);
+ auto offset_l=lsos_v[axis_v].length_val()-1;
+ lsos_v.axis_offset_put(axis_v,offset_l,offset_v);
+ std::cout<<"axis_offset_put("<<axis_v<<","<<offset_l<<","<<offset_v<<"):\n";
+ lsos_v.axis_index_put(axis_v,lsos_v[axis_v].get<index_bound_lower>());
+ std::cout<<"axis_index_put("<<axis_v<<",index_bound_lower["<<axis_v<<"]):\n";
+ test_inc_dec<inc_ator>(lsos_v);
+ #endif
+ 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