Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58009 - in sandbox/variadic_templates: boost libs/composite_tagged libs/composite_tagged/sandbox
From: cppljevans_at_[hidden]
Date: 2009-11-28 12:15:56


Author: cppljevans
Date: 2009-11-28 12:15:55 EST (Sat, 28 Nov 2009)
New Revision: 58009
URL: http://svn.boost.org/trac/boost/changeset/58009

Log:
Added composite_tagged files.
These files supersede those in the boost vault
which were mentioned in the spirit general post:

http://sourceforge.net/mailarchive/message.php?msg_name=he6hdk%24f9t%241%40ger.gmane.org

which had headers:

Re: [Spirit-general] another case for tagged variants (was Re: Look mom! No semantic actions.
From: Larry Evans <cppljevans_at_su...> - 2009-11-20 16:51

Added:
   sandbox/variadic_templates/boost/composite_tagged.hpp (contents, props changed)
   sandbox/variadic_templates/libs/composite_tagged/
   sandbox/variadic_templates/libs/composite_tagged/sandbox/
   sandbox/variadic_templates/libs/composite_tagged/sandbox/composite_tagged.leaf.test.cpp (contents, props changed)

Added: sandbox/variadic_templates/boost/composite_tagged.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/boost/composite_tagged.hpp 2009-11-28 12:15:55 EST (Sat, 28 Nov 2009)
@@ -0,0 +1,931 @@
+#ifndef BOOST_COMPOSITE_TAGGED_INCLUDED//if#BOOST_COMPOSITE_TAGGED_INCLUDED
+#define BOOST_COMPOSITE_TAGGED_INCLUDED
+// (C) Copyright Larry Evans 2009.
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+#include <cstddef>
+#include <boost/math/common_factor_ct.hpp>
+#include <boost/aligned_storage.hpp>
+#include <boost/mpl/for_each.hpp>
+
+#include <boost/mpl/fold_assoc_pack.hpp>
+#include <boost/mpl/package_range_c.hpp>
+#include <boost/mpl/mk_indexed_pairs.hpp>
+
+#include <iostream>
+
+namespace boost
+{
+namespace composite_tags
+{
+ struct one_of
+ //composite contains an instance of 'one of' template arguments.
+ ;
+ struct all_of_aligned
+ //composite contains instances of 'all of' template arguments, properly 'aligned'.
+ ;
+ struct all_of_packed
+ //composite contains instances of 'all of' template arguments, 'packed' together.
+ ;
+
+};
+
+ template
+ < class CompositeTag//possibly something from namespace composite_tags.
+ , class IndexType
+ , typename... Components
+ >
+ struct
+composite_tagged
+;
+
+namespace detail_composite_tagged//general
+{
+
+ typedef
+ int
+index_type
+;
+ static
+ index_type const
+index_undefined
+=-1
+;
+ template
+ < index_type Index=index_undefined
+ >
+ struct
+index_wrap
+/**@brief
+ * Used as argument to overloaded functions.
+ * Instances of this type are used to select
+ * which function to call.
+ */
+{
+};
+
+ template
+ < std::size_t Left
+ , std::size_t Right
+ >
+ struct
+compatible_alignment
+/**@brief
+ * "Metafunction" returning alignment which is compatible with the
+ * metafunction argument alignments, Left and Right.
+ *
+ * The real reason why this template was created instead of directly using
+ * static_lcm was to provide the documentation shown below which justifies
+ * static_lcm use.
+ */
+{
+ static
+ std::size_t const
+ value
+ = ::boost::math::static_lcm
+ < (unsigned long)Left
+ , (unsigned long)Right
+ >::value
+ //The use of static_lcm is based on the statement:
+ //
+ // N is the least common multiple of all Alignments
+ //
+ //in paragraph 1 on page 10 of:
+ //
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2165.pdf
+ //
+ //AFAICT, the reason lcm is used instead of just taking the
+ //maximum:
+ //
+ // Left>Right?Left:Right
+ //
+ //is to account for "Extended alignments" mentioned in paragraph 3
+ //on page 3 of the n2165 reference mentioned above. OTOH, if only
+ //"Fundamental alignments" are used (which, I assume, are the
+ //"static alignments;powers of 2" in paragraph 4 on page 5 of:
+ //
+ // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2006/n2140.pdf
+ //
+ //) then simply using max instead of lcm would work.
+ ;
+};
+
+ template
+ < std::size_t Size
+ , std::size_t Align
+ >
+ struct
+aligned_char_storage
+: private ::boost::aligned_storage<Size,Align>
+{
+ typedef
+ ::boost::aligned_storage<Size,Align>
+ super_type
+ ;
+ char const*
+ address(void)const
+ {
+ void const*p=this->super_type::address();
+ return static_cast<char const*>(p);
+ }
+ char*
+ address(void)
+ {
+ void*p=this->super_type::address();
+ return static_cast<char*>(p);
+ }
+
+};
+
+ template
+ < class CompositeTag
+ >
+ struct
+layout_make
+/**@brief
+ * Member template:
+ * push_back
+ * is used to calculate various "layout" traits of a composite.
+ * These traits include at least the size
+ * and possibly the offsets and alignments
+ * of the composite's components.
+ * Also a layout contains injection and projection
+ * functions for creating components of the composite
+ * in a memory buffer and retrieving the components
+ * from that memory buffer.
+ */
+{
+ template
+ < typename HeadLayout //layout of some Composite
+ , typename TailComponent//Type to be appended to some Composite
+ >
+ struct
+ push_back
+ /**@brief
+ * Calculate the layout of composite with component, TailComponent,
+ * appended to a Composite with layout, HeadLayout, and return
+ * layout result in push_back<HeadLayout,TailComponent>::type.
+ */
+ ;
+ struct
+ layout0
+ /**@brief
+ * layout of a composite with 0 components.
+ */
+ ;
+};
+
+}//exit detail_composite_tagged//general
+
+namespace detail_composite_tagged//composite_tags::one_of
+{
+ template
+ <
+ >
+ struct
+layout_make
+ < composite_tags::one_of
+ >
+{
+ struct
+ layout0
+ {
+ static
+ index_type const
+ index_part
+ =index_undefined
+ ;
+ static
+ std::size_t const
+ size_part
+ =0
+ ;
+ static
+ std::size_t const
+ align_part
+ =1
+ ;
+ static
+ void
+ result(index_wrap<index_part>)
+ ;
+ static
+ void
+ inject(index_wrap<index_part> index_arg, char*buffer_composite,...)
+ {
+ }
+ static
+ void const*
+ project(index_wrap<index_part> index_arg, char const*buffer_composite)
+ {
+ return 0;
+ }
+ static
+ void*
+ project(index_wrap<index_part> index_arg, char*buffer_composite)
+ {
+ return 0;
+ }
+ };
+ template
+ < typename HeadLayout
+ , typename TailComponent
+ >
+ struct
+ push_back
+ {
+ struct
+ type
+ : private HeadLayout
+ {
+ static
+ index_type const
+ index_part
+ =HeadLayout::index_part+1
+ ;
+ static
+ std::size_t const
+ size_part
+ =HeadLayout::size_part+sizeof(TailComponent)
+ ;
+ static
+ std::size_t const
+ align_part
+ =compatible_alignment
+ < HeadLayout::align_part
+ , ::boost::alignment_of<TailComponent>::value
+ >::value
+ ;
+ using HeadLayout::
+ result
+ ;
+ static
+ TailComponent
+ result(index_wrap<index_part>)
+ ;
+ using HeadLayout::
+ inject
+ ;
+ static
+ void
+ inject
+ ( index_wrap<index_part> index_arg
+ , char*buffer_composite
+ , TailComponent const& tail_component
+ )
+ {
+ char*buffer_tail=buffer_composite;
+ new(buffer_tail) TailComponent(tail_component);
+ }
+ using HeadLayout::
+ project
+ ;
+ static
+ TailComponent const*
+ project(index_wrap<index_part> index_arg, char const*buffer_composite)
+ {
+ void const*buffer_tail=buffer_composite;
+ TailComponent const*p=static_cast<TailComponent const*>(buffer_tail);
+ return p;
+ }
+ static
+ TailComponent*
+ project(index_wrap<index_part> index_arg, char*buffer_composite)
+ {
+ void*buffer_tail=buffer_composite;
+ TailComponent*p=static_cast<TailComponent*>(buffer_tail);
+ return p;
+ }
+ };
+ };
+
+};
+
+}//exit detail_composite_tagged//composite_tags::one_of
+
+ template
+ < class IndexType
+ , typename... Components
+ >
+ struct
+composite_tagged
+ < composite_tags::one_of
+ , IndexType
+ , Components...
+ >
+{
+ typedef
+ detail_composite_tagged::layout_make<composite_tags::one_of>
+ appender_type
+ ;
+ typedef
+ detail_composite_tagged::index_type
+ index_type
+ ;
+ typedef
+ typename mpl::fold_assoc_pack
+ < mpl::assoc_left
+ , appender_type::template push_back
+ , typename appender_type::layout0
+ , Components...
+ >::type
+ layout_type
+ ;
+ private:
+ detail_composite_tagged::aligned_char_storage
+ < layout_type::size_part
+ , layout_type::align_part
+ >
+ buffer
+ ;
+ index_type
+ my_index
+ ;
+ public:
+ index_type
+ which(void)const
+ {
+ return my_index;
+ }
+ composite_tagged(void)
+ : my_index(detail_composite_tagged::index_undefined)
+ {}
+ template
+ < index_type Index
+ >
+ struct
+ result_type
+ {
+ typedef
+ decltype
+ ( layout_type::result
+ ( detail_composite_tagged::index_wrap<Index>()
+ )
+ )
+ type
+ ;
+ };
+
+ template
+ < IndexType indexValu
+ >
+ void
+ inject
+ ( typename result_type<indexValu>::type const& tail_component
+ )
+ {
+ detail_composite_tagged::index_wrap<indexValu> index;
+ layout_type::inject(index,buffer.address(),tail_component);
+ my_index=indexValu;
+ }
+ template
+ < IndexType indexValu
+ >
+ typename result_type<indexValu>::type const*
+ project(void)const
+ {
+ if(indexValu == my_index)
+ {
+ detail_composite_tagged::index_wrap<indexValu> index;
+ return layout_type::project(index,buffer.address());
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ template
+ < IndexType indexValu
+ >
+ typename result_type<indexValu>::type*
+ project(void)
+ {
+ if(indexValu == my_index)
+ {
+ detail_composite_tagged::index_wrap<indexValu> index;
+ return layout_type::project(index,buffer.address());
+ }
+ else
+ {
+ return 0;
+ }
+ }
+};
+
+#if 1 //if#composite_tags::all_of_packed
+namespace detail_composite_tagged//composite_tags::all_of_packed
+{
+ template
+ <// class CompositeTag
+ >
+ struct
+layout_make
+ < composite_tags::all_of_packed
+ >
+{
+ struct
+ layout0
+ {
+ static
+ index_type const
+ index_part
+ =index_undefined
+ ;
+ static
+ std::size_t const
+ size_part
+ =0
+ ;
+ static
+ std::size_t
+ offset(index_wrap<index_part+1>)
+ {
+ return size_part;
+ }
+ static
+ void
+ result(index_wrap<index_part>)
+ ;
+ static
+ void
+ inject(index_wrap<index_part> index_arg, char*buffer_composite,...)
+ {
+ }
+ static
+ void
+ project(index_wrap<index_part> index_arg, char const*buffer_composite)
+ {
+ }
+ static
+ void
+ project(index_wrap<index_part> index_arg, char*buffer_composite)
+ {
+ }
+ };
+ template
+ < typename HeadLayout
+ , typename TailComponent
+ >
+ struct
+ push_back
+ {
+ struct
+ type
+ : private HeadLayout
+ {
+ static
+ index_type const
+ index_part
+ =HeadLayout::index_part+1
+ ;
+ static
+ std::size_t const
+ size_part
+ =HeadLayout::size_part+sizeof(TailComponent)
+ ;
+ using HeadLayout::
+ offset
+ ;
+ static
+ std::size_t
+ offset(index_wrap<index_part+1>)
+ {
+ return size_part;
+ }
+ using HeadLayout::
+ result
+ ;
+ static
+ TailComponent
+ result(index_wrap<index_part>)
+ ;
+ using HeadLayout::
+ inject
+ ;
+ static
+ void
+ inject
+ ( index_wrap<index_part> index_arg
+ , char*buffer_composite
+ , TailComponent const& tail_component
+ )
+
+ {
+ void*buffer_tail=buffer_composite+HeadLayout::size_part;
+ new(buffer_tail) TailComponent(tail_component);
+ }
+ using HeadLayout::
+ project
+ ;
+ static
+ TailComponent const&
+ project(index_wrap<index_part> index_arg, char const*buffer_composite)
+ {
+ void const*buffer_tail=buffer_composite+HeadLayout::size_part;
+ TailComponent const*p=static_cast<TailComponent const*>(buffer_tail);
+ return *p;
+ }
+ static
+ TailComponent&
+ project(index_wrap<index_part> index_arg, char*buffer_composite)
+ {
+ void*buffer_tail=buffer_composite+HeadLayout::size_part;
+ TailComponent*p=static_cast<TailComponent*>(buffer_tail);
+ return *p;
+ }
+
+ };//end type struct
+ };//end push_back struct
+};//end layout_make struct
+
+ template
+ < typename Layout
+ , typename... Components
+ >
+ struct
+construct_all
+{
+ typedef typename
+ mpl::package_range_c
+ < int
+ , 0
+ , sizeof...(Components)
+ >::type
+ indices
+ ;
+ typedef typename
+ mpl::mk_indexed_pairs
+ < indices
+ , Components...
+ >::type
+ ndx_pairs
+ ;
+ struct
+ initialize_one
+ {
+
+ char*
+ my_buffer
+ ;
+ initialize_one(char* a_buffer)
+ : my_buffer(a_buffer)
+ {}
+ template
+ < class IndexPair
+ >
+ void
+ operator()(IndexPair)const
+ {
+ int const index_part=IndexPair::first::value;
+ index_wrap<index_part> index;
+ typedef typename IndexPair::second value_type;
+ value_type value_val;
+ Layout::inject(index,my_buffer,value_val);
+ }
+
+ };
+ static
+ void
+ initialize_all(char*buffer)
+ {
+ initialize_one initializer(buffer);
+ mpl::for_each<ndx_pairs>(initializer);
+ };
+};
+
+}//exit detail_composite_tagged//composite_tags::all_of_packed
+
+ template
+ < class IndexType
+ , typename... Components
+ >
+ struct
+composite_tagged
+ < composite_tags::all_of_packed
+ , IndexType
+ , Components...
+ >
+{
+ typedef
+ detail_composite_tagged::layout_make<composite_tags::all_of_packed>
+ appender_type
+ ;
+ typedef
+ detail_composite_tagged::index_type
+ index_type
+ ;
+ typedef
+ typename mpl::fold_assoc_pack
+ < mpl::assoc_left
+ , appender_type::template push_back
+ , typename appender_type::layout0
+ , Components...
+ >::type
+ layout_type
+ ;
+ private:
+ char
+ buffer[layout_type::size_part]
+ ;
+ public:
+ composite_tagged(void)
+ {
+ detail_composite_tagged::construct_all<layout_type,Components...>::initialize_all(buffer);
+ }
+
+ template
+ < index_type IndexValu
+ >
+ struct
+ result_type
+ {
+ typedef
+ decltype
+ ( layout_type::result
+ ( detail_composite_tagged::index_wrap<IndexValu>()
+ )
+ )
+ type
+ ;
+ };
+ template
+ < IndexType IndexValu
+ >
+ typename result_type<IndexValu>::type const&
+ project(void)const
+ {
+ detail_composite_tagged::index_wrap<IndexValu> index;
+ return layout_type::project(index,buffer);
+ }
+ template
+ < IndexType IndexValu
+ >
+ typename result_type<IndexValu>::type &
+ project(void)
+ {
+ detail_composite_tagged::index_wrap<IndexValu> index;
+ return layout_type::project(index,buffer);
+ }
+};
+#endif //endif#composite_tags::all_of_packed
+
+#if 1 //if#composite_tags::all_of_aligned
+namespace detail_composite_tagged//composite_tags::all_of_aligned
+{
+ template
+ <// class CompositeTag
+ >
+ struct
+layout_make
+ < composite_tags::all_of_aligned
+ >
+{
+ template
+ < std::size_t Offset
+ , std::size_t Alignment
+ >
+ struct
+ next_aligned_offset
+ {
+ static
+ std::size_t const
+ remainder
+ = Offset%Alignment
+ ;
+ static
+ std::size_t const
+ value
+ = remainder == 0
+ ? Offset
+ : Offset+(Alignment-remainder)
+ //value is minimum value > Offset such that
+ //value%Alignment == 0
+ ;
+
+ };
+
+ struct
+ layout0
+ {
+ static
+ index_type const
+ index_part
+ =index_undefined
+ ;
+ static
+ std::size_t const
+ size_part
+ =0
+ ;
+ static
+ std::size_t const
+ align_part
+ =1
+ ;
+ static
+ std::size_t
+ offset(index_wrap<index_part+1>)
+ {
+ return size_part;
+ }
+ static
+ void
+ result(index_wrap<index_part>)
+ ;
+ static
+ void
+ inject(index_wrap<index_part> index_arg, char*buffer_composite,...)
+ {
+ }
+ static
+ void
+ project(index_wrap<index_part> index_arg, char const*buffer_composite)
+ {
+ }
+ static
+ void
+ project(index_wrap<index_part> index_arg, char*buffer_composite)
+ {
+ }
+ };
+
+ template
+ < typename HeadLayout
+ , typename TailComponent
+ >
+ struct
+ push_back
+ {
+ struct
+ type
+ : private HeadLayout
+ {
+ static
+ index_type const
+ index_part
+ =HeadLayout::index_part+1
+ ;
+ static
+ std::size_t const
+ align_one
+ = ::boost::alignment_of<TailComponent>::value
+ ;
+ static
+ std::size_t const
+ align_part
+ = compatible_alignment
+ < HeadLayout::align_part
+ , align_one
+ >::value
+ ;
+ static
+ std::size_t const
+ size_part
+ = next_aligned_offset
+ < HeadLayout::size_part
+ + sizeof(TailComponent)
+ , align_one
+ >::value
+ ;
+
+ using HeadLayout::
+ offset
+ ;
+ static
+ std::size_t
+ offset(index_wrap<index_part+1>)
+ {
+ return size_part;
+ }
+ using HeadLayout::
+ result
+ ;
+ static
+ TailComponent
+ result(index_wrap<index_part>)
+ ;
+ using HeadLayout::
+ inject
+ ;
+ static
+ void
+ inject
+ ( index_wrap<index_part> index_arg
+ , char*buffer_composite
+ , TailComponent const& tail_component
+ )
+ {
+ void*buffer_tail=buffer_composite+HeadLayout::size_part;
+ new(buffer_tail) TailComponent(tail_component);
+ }
+ using HeadLayout::
+ project
+ ;
+ static
+ TailComponent const&
+ project(index_wrap<index_part> index_arg, char const*buffer_composite)
+ {
+ void const*buffer_tail=buffer_composite+HeadLayout::size_part;
+ TailComponent const*p=static_cast<TailComponent const*>(buffer_tail);
+ return *p;
+ }
+ static
+ TailComponent&
+ project(index_wrap<index_part> index_arg, char*buffer_composite)
+ {
+ void*buffer_tail=buffer_composite+HeadLayout::size_part;
+ TailComponent*p=static_cast<TailComponent*>(buffer_tail);
+ return *p;
+ }
+
+ };//end type struct
+ };//end push_back struct
+};//end layout_make struct
+
+}//exit detail_composite_tagged namespace//composite_tags::all_of_aligned
+
+ template
+ < class IndexType
+ , typename... Components
+ >
+ struct
+composite_tagged
+ < composite_tags::all_of_aligned
+ , IndexType
+ , Components...
+ >
+{
+ typedef
+ detail_composite_tagged::layout_make<composite_tags::all_of_aligned>
+ appender_type
+ ;
+ typedef
+ detail_composite_tagged::index_type
+ index_type
+ ;
+ typedef
+ typename mpl::fold_assoc_pack
+ < mpl::assoc_left
+ , appender_type::template push_back
+ , typename appender_type::layout0
+ , Components...
+ >::type
+ layout_type
+ ;
+ private:
+ detail_composite_tagged::aligned_char_storage
+ < layout_type::size_part
+ , layout_type::align_part
+ >
+ buffer
+ ;
+ public:
+ composite_tagged(void)
+ {
+ char*memory=buffer.address();
+ detail_composite_tagged::construct_all<layout_type,Components...>::initialize_all(memory);
+ }
+
+ template
+ < index_type Index
+ >
+ struct
+ result_type
+ {
+ typedef
+ decltype
+ ( layout_type::result
+ ( detail_composite_tagged::index_wrap<Index>()
+ )
+ )
+ type
+ ;
+ };
+ template
+ < IndexType IndexValu
+ >
+ typename result_type<IndexValu>::type const&
+ project(void)const
+ {
+ detail_composite_tagged::index_wrap<IndexValu> index;
+ return layout_type::project(index,buffer.address());
+ }
+ template
+ < IndexType IndexValu
+ >
+ typename result_type<IndexValu>::type &
+ project(void)
+ {
+ detail_composite_tagged::index_wrap<IndexValu> index;
+ return layout_type::project(index,buffer.address());
+ }
+};
+#endif //endif#composite_tags::all_of_aligned
+
+}//exit boost namespace
+#endif //endif#BOOST_COMPOSITE_TAGGED_INCLUDED

Added: sandbox/variadic_templates/libs/composite_tagged/sandbox/composite_tagged.leaf.test.cpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/libs/composite_tagged/sandbox/composite_tagged.leaf.test.cpp 2009-11-28 12:15:55 EST (Sat, 28 Nov 2009)
@@ -0,0 +1,261 @@
+
+#include <boost/composite_tagged.hpp>
+
+#include <iostream>
+namespace boost
+{
+namespace composite_tagged_leaf
+{
+ template
+ < unsigned I
+ >
+ struct
+charvec_u
+{
+ char v[2*(I+1)];
+ unsigned tag(void)const
+ {
+ return I;
+ }
+ charvec_u(void)
+ {
+ v[0]='a';
+ v[1]='\0';
+ }
+};
+
+ enum
+index_numerals
+{ index_0
+, index_1
+, index_2
+, index_3
+, index_4
+};
+
+void test(void)
+{
+#if 0
+ {
+ typedef
+ detail::layout_make
+ < composite_tags::one_of
+ >::push_back
+ < detail::size_alignment<>
+ , detail::size_alignment<2,9>
+ >::type
+ tp_type
+ ;
+ std::cout
+ <<"***layout_make<one_of>::push_back<<>,<2,9>>\n"
+ <<":size="<<tp_type::size_part<<"\n"
+ <<":alignment="<<tp_type::align_part<<"\n"
+ ;
+ }
+#endif
+#if 1
+ {
+ typedef
+ composite_tagged
+ < composite_tags::one_of
+ , index_numerals
+ , charvec_u<0>
+ , charvec_u<1>
+ >
+ tagged_type
+ ;
+ typedef
+ tagged_type::layout_type
+ layout_type
+ ;
+ std::cout
+ <<"***composite_tagged<one_of>:\n"
+ <<":size="<<layout_type::size_part<<"\n"
+ <<":alignment="<<layout_type::align_part<<"\n"
+ ;
+ tagged_type
+ tagged_values
+ ;
+ charvec_u<0>*
+ t0
+ ;
+ charvec_u<1>*
+ t1
+ ;
+ std::cout
+ <<"which="<<tagged_values.which()<<"\n";
+ t0=tagged_values.project<index_0>();
+ std::cout
+ <<"t0="<<t0<<"\n";
+ t1=tagged_values.project<index_1>();
+ std::cout
+ <<"t1="<<t1<<"\n";
+
+ tagged_values.inject<index_0>(charvec_u<0>());
+ std::cout
+ <<"which="<<tagged_values.which()<<"\n";
+ t0=tagged_values.project<index_0>();
+ std::cout
+ <<"t0="<<t0<<"\n";
+ t1=tagged_values.project<index_1>();
+ std::cout
+ <<"t1="<<t1<<"\n";
+
+ tagged_values.inject<index_1>(charvec_u<1>());
+ std::cout
+ <<"which="<<tagged_values.which()<<"\n";
+ t0=tagged_values.project<index_0>();
+ std::cout
+ <<"t0="<<t0<<"\n";
+ t1=tagged_values.project<index_1>();
+ std::cout
+ <<"t1="<<t1<<"\n";
+ }
+#endif
+#if 0
+ {
+ std::cout
+ <<"sizeof(charvec_u<0>)="<<sizeof(charvec_u<0>)<<"\n"
+ <<"sizeof(charvec_u<1>)="<<sizeof(charvec_u<1>)<<"\n"
+ <<"sizeof(charvec_u<2>)="<<sizeof(charvec_u<2>)<<"\n"
+ ;
+ typedef
+ detail::layout_make
+ < composite_tags::all_of_packed
+ >::layout0
+ tp0_type
+ ;
+ typedef
+ detail::layout_make
+ < composite_tags::all_of_packed
+ >::push_back
+ < tp0_type
+ , charvec_u<0>
+ >::type
+ tp1_type
+ ;
+ std::cout
+ <<"***layout_make<all_of_packed>::push_back<tp0_type,charvec_u<0> >\n"
+ <<":size="<<tp1_type::size_part<<"\n"
+ <<":index="<<tp1_type::index_part<<"\n"
+ <<":offset(0)="<<tp1_type::offset(index_wrap<0>())<<"\n"
+ ;
+ typedef
+ detail::layout_make
+ < composite_tags::all_of_packed
+ >::push_back
+ < tp1_type
+ , charvec_u<1>
+ >::type
+ tp2_type
+ ;
+ std::cout
+ <<"***layout_make<all_of_packed>::push_back<tp1_type,charvec_u<1> >\n"
+ <<":size="<<tp2_type::size_part<<"\n"
+ <<":index="<<tp2_type::index_part<<"\n"
+ <<":offset(1)="<<tp2_type::offset(index_wrap<1>())<<"\n"
+ ;
+ typedef
+ detail::layout_make
+ < composite_tags::all_of_packed
+ >::push_back
+ < tp2_type
+ , charvec_u<2>
+ >::type
+ tp3_type
+ ;
+ std::cout
+ <<"***layout_make<all_of_packed>::push_back<tp2_type,charvec_u<2> >\n"
+ <<":size="<<tp3_type::size_part<<"\n"
+ <<":index="<<tp3_type::index_part<<"\n"
+ <<":offset(2)="<<tp3_type::offset(index_wrap<2>())<<"\n"
+ ;
+ std::cout
+ <<":offset(3)="<<tp3_type::offset(index_wrap<3>())<<"\n"
+ ;
+ }
+#endif
+#if 1
+ {
+ typedef
+ composite_tagged
+ < composite_tags::all_of_packed
+ , index_numerals
+ , charvec_u<0>
+ , charvec_u<1>
+ , charvec_u<2>
+ >
+ tagged_type
+ ;
+ typedef
+ tagged_type::layout_type
+ layout_type
+ ;
+ tagged_type
+ tagged_valu
+ ;
+ std::cout
+ <<"***composite_tagged<all_of_packed>:\n"
+ <<":size="<<layout_type::size_part<<"\n"
+ <<":offset<0>="<<layout_type::offset(detail_composite_tagged::index_wrap<0>())<<"\n"
+ <<":offset<1>="<<layout_type::offset(detail_composite_tagged::index_wrap<1>())<<"\n"
+ <<":offset<2>="<<layout_type::offset(detail_composite_tagged::index_wrap<2>())<<"\n"
+ <<":offset<3>="<<layout_type::offset(detail_composite_tagged::index_wrap<3>())<<"\n"
+ <<":project<index_0>="<<tagged_valu.project<index_0>().v<<"\n"
+ <<":project<index_1>="<<tagged_valu.project<index_1>().v<<"\n"
+ ;
+ tagged_valu.project<index_1>().v[0]='b';
+ std::cout
+ <<"***composite_tagged<all_of_packed>:\n"
+ <<" (after project<index_1>='b')\n"
+ <<":project<index_1>="<<tagged_valu.project<index_1>().v<<"\n"
+ ;
+ }
+#endif
+#if 1
+ {
+ typedef
+ composite_tagged
+ < composite_tags::all_of_aligned
+ , index_numerals
+ , charvec_u<0>
+ , charvec_u<1>
+ , charvec_u<2>
+ >
+ tagged_type
+ ;
+ typedef
+ tagged_type::layout_type
+ layout_type
+ ;
+ tagged_type
+ tagged_valu
+ ;
+ std::cout
+ <<"***composite_tagged<all_of_aligned>:\n"
+ <<":size="<<layout_type::size_part<<"\n"
+ <<":offset<0>="<<layout_type::offset(detail_composite_tagged::index_wrap<0>())<<"\n"
+ <<":offset<1>="<<layout_type::offset(detail_composite_tagged::index_wrap<1>())<<"\n"
+ <<":offset<2>="<<layout_type::offset(detail_composite_tagged::index_wrap<2>())<<"\n"
+ <<":offset<3>="<<layout_type::offset(detail_composite_tagged::index_wrap<3>())<<"\n"
+ <<":project<index_0>="<<tagged_valu.project<index_0>().v<<"\n"
+ <<":project<index_1>="<<tagged_valu.project<index_1>().v<<"\n"
+ ;
+ tagged_valu.project<index_1>().v[0]='b';
+ std::cout
+ <<"***composite_tagged<all_of_packed>:\n"
+ <<" (after project<index_1>='b')\n"
+ <<":project<index_1>="<<tagged_valu.project<index_1>().v<<"\n"
+ ;
+ }
+#endif
+}
+
+}//exit composite_tagged_leaf namespace
+}//exit boost namespace
+
+int main(void)
+{
+ boost::composite_tagged_leaf::test();
+ 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