Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63340 - in sandbox/variadic_templates: boost/mpl libs/composite_storage/sandbox/pack libs/composite_storage/utility libs/composite_tagged/sandbox
From: cppljevans_at_[hidden]
Date: 2010-06-26 07:23:32


Author: cppljevans
Date: 2010-06-26 07:23:30 EDT (Sat, 26 Jun 2010)
New Revision: 63340
URL: http://svn.boost.org/trac/boost/changeset/63340

Log:
add Jamfile & hopefully, rest of needed files
Added:
   sandbox/variadic_templates/boost/mpl/while.hpp (contents, props changed)
   sandbox/variadic_templates/libs/composite_storage/sandbox/pack/Jamfile (contents, props changed)
   sandbox/variadic_templates/libs/composite_storage/utility/
   sandbox/variadic_templates/libs/composite_storage/utility/curried_offset.hpp (contents, props changed)
   sandbox/variadic_templates/libs/composite_storage/utility/layout_at.hpp (contents, props changed)
Text files modified:
   sandbox/variadic_templates/libs/composite_tagged/sandbox/composite_tagged.leaf.test.cpp | 121 +++++++++++++++++++++------------------
   1 files changed, 65 insertions(+), 56 deletions(-)

Added: sandbox/variadic_templates/boost/mpl/while.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/boost/mpl/while.hpp 2010-06-26 07:23:30 EDT (Sat, 26 Jun 2010)
@@ -0,0 +1,34 @@
+#ifndef BOOST_MPL_WHILE_HPP_INCLUDED
+#define BOOST_MPL_WHILE_HPP_INCLUDED
+// 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 <boost/mpl/eval_if.hpp>
+
+namespace boost
+{
+namespace mpl
+{
+ template
+ < class State //nullary metafunction returning current state.
+ , class IfOps //contains nested unary metafunctions, if_, then_.
+ >
+ struct while_
+ : eval_if
+ < typename IfOps::template if_<typename State::type>::type
+ , while_
+ < typename IfOps::template then_<typename State::type>
+ , IfOps
+ >
+ , State
+ >
+ {
+ };
+
+}//exit mpl namespace
+}//exit boost namespace
+#endif

Added: sandbox/variadic_templates/libs/composite_storage/sandbox/pack/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/libs/composite_storage/sandbox/pack/Jamfile 2010-06-26 07:23:30 EDT (Sat, 26 Jun 2010)
@@ -0,0 +1,18 @@
+
+project libs/composite_storage/sandbox/pack
+ :
+ : default-build debug
+ <include>../../../../../../ro/switch
+ #^for:
+ # http://svn.boost.org/svn/boost/sandbox/switch
+ <include>../../../..
+ #^for:
+ # boost/composite_storage/*
+ # boost/iostreams/utility/*
+ ;
+run composite_storage.leaf.test.cpp
+ ;
+
+run one_of_multiple_dispatch.test.cpp
+ ;
+

Added: sandbox/variadic_templates/libs/composite_storage/utility/curried_offset.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/libs/composite_storage/utility/curried_offset.hpp 2010-06-26 07:23:30 EDT (Sat, 26 Jun 2010)
@@ -0,0 +1,45 @@
+#ifndef LIBS_COMPOSITE_STORAGE_UTILITY_CURRIED_OFFSET_INCLUDED
+#define LIBS_COMPOSITE_STORAGE_UTILITY_CURRIED_OFFSET_INCLUDED
+#include "layout_at.hpp"
+namespace libs
+{
+namespace composite_storage
+{
+namespace utility
+{
+ template
+ < typename Composite
+ >
+struct curried_offset
+{
+ typedef
+ typename Composite::index_type
+ index_type
+ ;
+ template
+ < index_type Index
+ >
+ struct offset_at
+ /**@brief
+ * Find offset at given Index within Composite.
+ */
+ {
+ typedef
+ typename
+ layout_at
+ < Composite
+ , boost::mpl::integral_c<index_type,Index>
+ >::type
+ layout_type
+ ;
+ static
+ std::size_t const
+ value
+ =layout_type::comp_part::offset
+ ;
+ };
+};
+
+}}}
+#endif
+

Added: sandbox/variadic_templates/libs/composite_storage/utility/layout_at.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/libs/composite_storage/utility/layout_at.hpp 2010-06-26 07:23:30 EDT (Sat, 26 Jun 2010)
@@ -0,0 +1,88 @@
+#ifndef LIBS_COMPOSITE_STORAGE_UTILITY_LAYOUT_AT_INCLUDED
+#define LIBS_COMPOSITE_STORAGE_UTILITY_LAYOUT_AT_INCLUDED
+#include <boost/mpl/while.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/integral_c.hpp>
+namespace libs
+{
+namespace composite_storage
+{
+namespace utility
+{
+
+
+ template
+ < typename IndexUndefined
+ , typename IndexType
+ >
+ struct layout_if
+ /**@brief
+ * Arg to while_ template.
+ */
+ {
+ typedef
+ typename IndexUndefined::value_type
+ index_base
+ ;
+ typedef
+ boost::mpl::integral_c
+ < index_base
+ , index_base(IndexType::value)
+ >
+ index2base
+ /**@brief
+ * Converts IndexType to
+ * integral_c having index_base as type argument.
+ */
+ ;
+ template
+ < typename Layout
+ >
+ struct if_
+ : boost::mpl::not_
+ < boost::mpl::or_
+ < boost::is_same<typename Layout::index_part, index2base>
+ , boost::is_same<typename Layout::index_part, IndexUndefined>
+ >
+ >
+ /**@brief
+ * Terminate while_ loop if
+ * either: IndexUndefined is found
+ * or: IndexType is found
+ */
+ {};
+
+ template
+ < typename Layout
+ >
+ struct then_
+ /**@brief
+ * Return next layout.
+ */
+ {
+ typedef typename Layout::head_layout type;
+ };
+ };
+
+ template
+ < typename Composite
+ , typename Index
+ >
+ struct layout_at
+ /**@brief
+ * Returns Layout at given Index in Composite, if it exists,
+ * Otherwise, returns layout at undefined Index.
+ */
+ : boost::mpl::while_
+ < typename Composite::scanned
+ , layout_if
+ < typename Composite::index_undefined
+ , Index
+ >
+ >
+ {
+ };
+
+}}}
+#endif

Modified: sandbox/variadic_templates/libs/composite_tagged/sandbox/composite_tagged.leaf.test.cpp
==============================================================================
--- sandbox/variadic_templates/libs/composite_tagged/sandbox/composite_tagged.leaf.test.cpp (original)
+++ sandbox/variadic_templates/libs/composite_tagged/sandbox/composite_tagged.leaf.test.cpp 2010-06-26 07:23:30 EDT (Sat, 26 Jun 2010)
@@ -69,45 +69,26 @@
 
 void test(void)
 {
-#if 0
- std::cout<<"object_number="<<object_number<<"\n";
- {
- 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
     std::cout<<"object_number="<<object_number<<"\n";
     {
             typedef
           composite_tagged
           < composite_tags::one_of
- , index_numerals
+ , mpl::integral_c<index_numerals,index_0>
           , charvec_u<0>
           , charvec_u<1>
>
         tagged_type
         ;
             typedef
- tagged_type::layout_type
- layout_type
+ tagged_type::layout_scanned
+ layout_scanned
         ;
         std::cout
           <<"***composite_tagged<one_of>:\n"
- <<":size="<<layout_type::size_part<<"\n"
- <<":alignment="<<layout_type::align_part<<"\n"
+ <<":size="<<layout_scanned::size_part<<"\n"
+ <<":alignment="<<layout_scanned::align_part<<"\n"
         ;
           tagged_type
         tagged_values
@@ -146,9 +127,24 @@
         t1=tagged_values.project<index_1>();
         std::cout
           <<"t1="<<t1<<"\n";
+ std::cout
+ <<"assign_test:\n";
+ tagged_type
+ tagged_from
+ ;
+ tagged_values=tagged_from;
+ 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
+#if 1
     std::cout<<"object_number="<<object_number<<"\n";
     {
         std::cout
@@ -157,13 +153,18 @@
           <<"sizeof(charvec_u<2>)="<<sizeof(charvec_u<2>)<<"\n"
         ;
             typedef
- detail::layout_make
+ detail_composite_tagged::layout_operators
           < composite_tags::all_of_packed
- >::layout0
+ >::layout0<mpl::integral_c<int,-1> >
         tp0_type
         ;
+ std::cout
+ <<"***layout_operators<all_of_packed>::layout0<integral_c<int,-1>\n"
+ <<":size="<<tp0_type::size_part<<"\n"
+ <<":index="<<tp0_type::index_part::value<<"\n"
+ ;
             typedef
- detail::layout_make
+ detail_composite_tagged::layout_operators
           < composite_tags::all_of_packed
>::push_back
           < tp0_type
@@ -172,13 +173,13 @@
         tp1_type
         ;
         std::cout
- <<"***layout_make<all_of_packed>::push_back<tp0_type,charvec_u<0> >\n"
+ <<"***layout_operators<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"
+ <<":index="<<tp1_type::index_part::value<<"\n"
+ <<":offset(0)="<<tp1_type::offset(mpl::integral_c<int,0>())<<"\n"
         ;
             typedef
- detail::layout_make
+ detail_composite_tagged::layout_operators
           < composite_tags::all_of_packed
>::push_back
           < tp1_type
@@ -187,13 +188,13 @@
         tp2_type
         ;
         std::cout
- <<"***layout_make<all_of_packed>::push_back<tp1_type,charvec_u<1> >\n"
+ <<"***layout_operators<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"
+ <<":index="<<tp2_type::index_part::value<<"\n"
+ <<":offset(1)="<<tp2_type::offset(mpl::integral_c<int,1>())<<"\n"
         ;
             typedef
- detail::layout_make
+ detail_composite_tagged::layout_operators
           < composite_tags::all_of_packed
>::push_back
           < tp2_type
@@ -202,13 +203,13 @@
         tp3_type
         ;
         std::cout
- <<"***layout_make<all_of_packed>::push_back<tp2_type,charvec_u<2> >\n"
+ <<"***layout_operators<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"
+ <<":index="<<tp3_type::index_part::value<<"\n"
+ <<":offset(2)="<<tp3_type::offset(mpl::integral_c<int,2>())<<"\n"
         ;
         std::cout
- <<":offset(3)="<<tp3_type::offset(index_wrap<3>())<<"\n"
+ <<":offset(3)="<<tp3_type::offset(mpl::integral_c<int,3>())<<"\n"
         ;
     }
 #endif
@@ -218,7 +219,7 @@
             typedef
           composite_tagged
           < composite_tags::all_of_packed
- , index_numerals
+ , mpl::integral_c<index_numerals,index_0>
           , charvec_u<0>
           , charvec_u<1>
           , charvec_u<2>
@@ -226,19 +227,23 @@
         tagged_type
         ;
             typedef
- tagged_type::layout_type
- layout_type
+ tagged_type::layout_scanned
+ layout_scanned
+ ;
+ typedef
+ tagged_type::index_base
+ index_base
         ;
           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"
+ <<":size="<<layout_scanned::size_part<<"\n"
+ <<":offset<0>="<<layout_scanned::offset(mpl::integral_c<index_base,index_0>())<<"\n"
+ <<":offset<1>="<<layout_scanned::offset(mpl::integral_c<index_base,index_1>())<<"\n"
+ <<":offset<2>="<<layout_scanned::offset(mpl::integral_c<index_base,index_2>())<<"\n"
+ <<":offset<3>="<<layout_scanned::offset(mpl::integral_c<index_base,index_3>())<<"\n"
         ;
         
         charvec_u<index_1> c_1;
@@ -295,7 +300,7 @@
             typedef
           composite_tagged
           < composite_tags::all_of_aligned
- , index_numerals
+ , mpl::integral_c<index_numerals,index_0>
           , charvec_u<0>
           , charvec_u<1>
           , charvec_u<2>
@@ -303,19 +308,23 @@
         tagged_type
         ;
             typedef
- tagged_type::layout_type
- layout_type
+ tagged_type::layout_scanned
+ layout_scanned
+ ;
+ typedef
+ tagged_type::index_base
+ index_base
         ;
           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"
+ <<":size="<<layout_scanned::size_part<<"\n"
+ <<":offset<0>="<<layout_scanned::offset(mpl::integral_c<index_base,index_0>())<<"\n"
+ <<":offset<1>="<<layout_scanned::offset(mpl::integral_c<index_base,index_1>())<<"\n"
+ <<":offset<2>="<<layout_scanned::offset(mpl::integral_c<index_base,index_2>())<<"\n"
+ <<":offset<3>="<<layout_scanned::offset(mpl::integral_c<index_base,index_3>())<<"\n"
           <<":project<index_0>="<<tagged_valu.project<index_0>().v<<"\n"
           <<":project<index_1>="<<tagged_valu.project<index_1>().v<<"\n"
         ;


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