$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r70969 - in sandbox/variadic_templates/boost/composite_storage: . layout methods pack pack/multiple_dispatch
From: cppljevans_at_[hidden]
Date: 2011-04-04 13:43:40
Author: cppljevans
Date: 2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
New Revision: 70969
URL: http://svn.boost.org/trac/boost/changeset/70969
Log:
Added: index_commponent.hpp
To: generalize the index_component that was in container_one_of_maybe.hpp
Added: index.hpp
To: produce index_component<,,> instances and enable 
  index_component arg CTOR in all containers.
Added: ctor_protected_all_of_aligned.hpp, ctor_protected_fwd.hpp
Why: see comments.
Modified:
  container_all_of_aligned:
    To: CTOR with index_component args.
        change superclass to ctor_protected...
  container_one_of_maybe:
    To: use new index_component<,,>.
Otherwise:
  Can't remember :(
Added:
   sandbox/variadic_templates/boost/composite_storage/index.hpp   (contents, props changed)
   sandbox/variadic_templates/boost/composite_storage/index_component.hpp   (contents, props changed)
   sandbox/variadic_templates/boost/composite_storage/pack/ctor_protected_all_of_aligned.hpp   (contents, props changed)
   sandbox/variadic_templates/boost/composite_storage/pack/ctor_protected_fwd.hpp   (contents, props changed)
Text files modified: 
   sandbox/variadic_templates/boost/composite_storage/layout/operators_all_of_aligned.hpp                       |    23 +++++++++                               
   sandbox/variadic_templates/boost/composite_storage/methods/all_of.hpp                                        |    16 ++++++                                  
   sandbox/variadic_templates/boost/composite_storage/pack/container_all_of_aligned.hpp                         |    93 +++------------------------------------ 
   sandbox/variadic_templates/boost/composite_storage/pack/container_one_of_maybe.hpp                           |    84 +++---------------------------------    
   sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reify_apply.hpp                    |    13 ++++-                                   
   sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/replace_source_with_target_ptr.hpp |    13 ++---                                   
   6 files changed, 68 insertions(+), 174 deletions(-)
Added: sandbox/variadic_templates/boost/composite_storage/index.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/boost/composite_storage/index.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -0,0 +1,46 @@
+//ustility for associating a single component with its index or key.
+#ifndef BOOST_COMPOSITE_STORAGE_INDEX_HPP_INCLUDED
+#define BOOST_COMPOSITE_STORAGE_INDEX_HPP_INCLUDED
+//  (C) Copyright Larry Evans 2010.
+//
+//  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/composite_storage/index_component.hpp>
+namespace boost
+{
+namespace composite_storage
+{
+      template
+      < typename IndexType
+      , IndexType IndexValue
+      >
+    struct index
+    /**@brief
+     *  See operator=.
+     */
+    {
+        template
+        < typename Component
+        >
+          index_component
+          < IndexType
+          , IndexValue
+          , Component
+          >
+        operator=(Component a_comp)const
+          /**@brief
+           *  Produce an association between IndexValue and a_comp.
+           */
+          {
+            return index_component<IndexType,IndexValue,Component>(a_comp);
+          }
+    };
+    
+}//exit composite_storage namespace
+}//exit boost namespace
+
+#endif
Added: sandbox/variadic_templates/boost/composite_storage/index_component.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/boost/composite_storage/index_component.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -0,0 +1,68 @@
+//ustility for associating a single component with its index or key.
+#ifndef BOOST_COMPOSITE_STORAGE_INDEX_COMPONENT_HPP_INCLUDED
+#define BOOST_COMPOSITE_STORAGE_INDEX_COMPONENT_HPP_INCLUDED
+//  (C) Copyright Larry Evans 2010.
+//
+//  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.
+//
+//====================================================================
+namespace boost
+{
+namespace composite_storage
+{
+      template
+      < typename IndexType
+      , IndexType IndexValue
+      , typename Component
+      >
+    struct index_component
+    /**@brief
+     *  Associate IndexValue with a value of type, Component.
+     *  Could be used in some sort of dictionary for retrieving
+     *  a value of type Component from the key, IndexValue.
+     **@MAINTENANCE_NOTE:
+     *  Did not use fusion::pair because:
+     *  1) fusion::pair has operator<< already defined
+     *    which just prints the 2nd component of the pair.
+     *    With this class, which is intended for something
+     *    like a dictionary, printing the first value in the
+     *    pair is also important.
+     *  2) fusion::pair had many more operations defined
+     *    on it than were needed for the intended application
+     *    of this class.
+     *  3) fusion::pair has a default CTOR.  Since instances
+     *    of this class are intended to created from a Component
+     *    by a index<IndexType,IndexValue> instance, using fusion::pair
+     *    would provide more ways to create the needed value
+     *    than are absolutely necessary.
+     */
+    {
+        Component my_comp;
+        
+        index_component(index_component const& a_comp)
+          : my_comp(a_comp.my_comp)
+          {
+            //std::cout<<"(index_component const&):a_comp="<<a_comp.my_comp<<"\n";
+          }
+          
+        index_component(Component const& a_comp)
+          : my_comp(a_comp)
+          {
+            //std::cout<<"(Component a_comp):a_comp="<<a_comp<<"\n";
+          }
+        
+     private:
+        index_component()
+          /**@brief
+           *  Force Component value to be provided during construction.
+           */
+          ;
+    };
+          
+}//exit composite_storage namespace
+}//exit boost namespace
+
+#endif
Modified: sandbox/variadic_templates/boost/composite_storage/layout/operators_all_of_aligned.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/layout/operators_all_of_aligned.hpp	(original)
+++ sandbox/variadic_templates/boost/composite_storage/layout/operators_all_of_aligned.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -126,6 +126,24 @@
               using HeadLayout::
             inject
             ;
+            
+         #define VARIADIC_INJECT
+         #ifdef VARIADIC_INJECT
+              template
+              < typename... InjArgs
+              >
+                static
+              void
+            inject
+              ( index_part index_arg
+              , char*buffer_composite
+              , InjArgs&&... inj_args
+              )
+            {
+                void*tail_buffer=buffer_composite+comp_part::offset;
+                new(tail_buffer) TailComponent(std::forward<InjArgs>(inj_args)...);
+            }
+         #else
                 static
               void
             inject
@@ -148,6 +166,7 @@
                 void*tail_buffer=buffer_composite+comp_part::offset;
                 new(tail_buffer) TailComponent(tail_component);
             }
+         #endif
               using HeadLayout::
             inject_default
             ;
@@ -159,8 +178,8 @@
               )
             
             {
-                TailComponent tail_component;
-                inject(index_arg,buffer_composite,std::move(tail_component));
+                void*tail_buffer=buffer_composite+comp_part::offset;
+                new(tail_buffer) TailComponent;
             }
               using HeadLayout::
             project
Modified: sandbox/variadic_templates/boost/composite_storage/methods/all_of.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/methods/all_of.hpp	(original)
+++ sandbox/variadic_templates/boost/composite_storage/methods/all_of.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -26,8 +26,10 @@
   , typename IndexBegin
   >
   struct
-all_of
+layout_indices
+: Layout
 {
+
         typedef
       IndexBegin
     index_begin
@@ -48,6 +50,18 @@
       >::type
     indices
     ;
+};
+
+  template
+  < typename Layout
+  >
+  struct
+all_of
+{
+        typedef
+      typename Layout::indices
+    indices
+    ;
       template
       < typename FrBuffer
       >
Modified: sandbox/variadic_templates/boost/composite_storage/pack/container_all_of_aligned.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/container_all_of_aligned.hpp	(original)
+++ sandbox/variadic_templates/boost/composite_storage/pack/container_all_of_aligned.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -8,11 +8,8 @@
 //  This software is provided "as is" without express or implied
 //  warranty, and with no claim as to its suitability for any purpose.
 //====================================================================
-#include <boost/composite_storage/layout/operators_all_of_aligned.hpp>
-#include <boost/composite_storage/pack/layout_composite.hpp>
+#include <boost/composite_storage/pack/ctor_protected_all_of_aligned.hpp>
 #include <boost/composite_storage/pack/container_fwd.hpp>
-#include <boost/composite_storage/methods/all_of.hpp>
-#include <boost/composite_storage/buffers/layout_buf.hpp>
 
 namespace boost
 {
@@ -30,40 +27,23 @@
   , Index0
   , Components...
   >
-: buffers::layout_buf
-  < layout_composite
-    < tags::all_of_aligned
-    , Index0
-    , Components...
-    >
+: ctor_protected
+  < tags::all_of_aligned
+  , Index0
+  , Components...
   >
 {
+
         typedef
-      layout_composite
+      ctor_protected
       < tags::all_of_aligned
       , Index0
       , Components...
       >
-    layout_comp
+    ctor_prot
     ;
         typedef
-      typename layout_comp::scanned
-    scanned
-    ;
-        typedef
-      typename layout_comp::index_base
-    index_base
-    ;
-        typedef
-      typename layout_comp::index_undefined
-    index_undefined
-    ;
-        typedef
-      typename layout_comp::index_type
-    index_type
-    ;
-        typedef
-      methods::all_of<scanned,Index0>
+      typename ctor_prot::methods_all
     methods_all
     ;
  public:
@@ -92,61 +72,6 @@
         , fr_buf
         );
     }
-      container const&
-    operator=(container const& from)
-    {
-        char      *to_buf=this->address();
-        char const*fr_buf=from.address();
-          methods_all::
-        assign_all
-        ( to_buf
-        , fr_buf
-        );
-        return *this;
-    }
-      container const&
-    operator=(container&& from)
-    {
-        char      *to_buf=this->address();
-        buffers::rval_ref_buf fr_buf(from.address());
-          methods_all::
-        assign_all
-        ( to_buf
-        , fr_buf
-        );
-        return *this;
-    }
-    ~container(void)
-    {
-        scanned::destroy( this->address());
-    }   
- 
-      template
-      < index_type IndexValu
-      >
-    struct result_type
-    : layout_comp::template result_type<IndexValu>
-    {
-    };
-    
-      template
-      < index_type IndexValu
-      >
-      typename result_type<IndexValu>::type const&
-    project(void)const
-    {
-        mpl::integral_c<index_base,IndexValu> index;
-        return scanned::project(index,this->address());
-    }        
-      template
-      < index_type IndexValu
-      >
-      typename result_type<IndexValu>::type &
-    project(void)
-    {
-        mpl::integral_c<index_base,IndexValu> index;
-        return scanned::project(index,this->address());
-    }        
 };
 
 }//exit pack namespace
Modified: sandbox/variadic_templates/boost/composite_storage/pack/container_one_of_maybe.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/container_one_of_maybe.hpp	(original)
+++ sandbox/variadic_templates/boost/composite_storage/pack/container_one_of_maybe.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -9,6 +9,7 @@
 //  warranty, and with no claim as to its suitability for any purpose.
 //====================================================================
 #include <boost/composite_storage/functor_indexed.hpp>
+#include <boost/composite_storage/index_component.hpp>
 
 namespace boost
 {
@@ -330,62 +331,26 @@
       >
     container
       ( mpl::integral_c<index_type,IndexValu>
-      , Component index_component
+      , Component a_component
       )
     {
         mpl::integral_c<index_base,IndexValu> index;
-        scanned::inject( index, buffer.address(), std::forward<Component>(index_component));
+        scanned::inject( index, buffer.address(), std::forward<Component>(a_component));
         which_put(IndexValu);
     }
       template
       < index_type IndexValu
       , typename Component
       >
-    struct index_component
-    : fusion::pair
-      < mpl::integral_c< index_type, IndexValu>
-      , Component
-      >
-    {
-            typedef
-          fusion::pair
-          < mpl::integral_c< index_type, IndexValu>
-          , Component
-          >
-        super_type
-        ;
-            typedef
-          typename utility::remove_cv_ref
-          < Component
-          >::type
-        comp_type
-        ;
-        index_component(void)
-        : super_type(comp_type())
-        {}
-        index_component(Component a_comp)
-        : super_type(a_comp)
-        {}
-            static
-          index_component
-        _(void)
-        {
-            return index_component();
-        }
-    };
-      template
-      < index_type IndexValu
-      , typename Component
-      >
     container
-      ( index_component<IndexValu,Component const&> index_component
+      ( index_component<index_type,IndexValu,Component> a_component
       )
     {
         mpl::integral_c<index_base,IndexValu> index;
         scanned::inject
           ( index
           , buffer.address()
-          , index_component.second
+          , a_component.my_comp
           );
         which_put(IndexValu);
     }
@@ -393,44 +358,9 @@
       < index_type IndexValu
       , typename Component
       >
-    container
-      ( index_component<IndexValu,Component&&> index_component
-      )
-    {
-        mpl::integral_c<index_base,IndexValu> index;
-        scanned::inject
-          ( index
-          , buffer.address()
-          , std::move(index_component.second)
-          );
-        which_put(IndexValu);
-    }
-      template
-      < index_type IndexValu
-      , typename Component
-      >
-      container const&
-    operator=
-      ( index_component<IndexValu,Component const&> index_component
-      )
-    {
-        destroy();
-        mpl::integral_c<index_base,IndexValu> index;
-        scanned::inject
-          ( index
-          , buffer.address()
-          , index_component.second
-          );
-        which_put(IndexValu);
-        return *this;
-    }
-      template
-      < index_type IndexValu
-      , typename Component
-      >
       container const&
     operator=
-      ( index_component<IndexValu,Component&&> index_component
+      ( index_component<index_type,IndexValu,Component> a_component
       )
     {
         destroy();
@@ -438,7 +368,7 @@
         scanned::inject
           ( index
           , buffer.address()
-          , std::move(index_component.second)
+          , a_component.my_comp
           );
         which_put(IndexValu);
         return *this;
Added: sandbox/variadic_templates/boost/composite_storage/pack/ctor_protected_all_of_aligned.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/boost/composite_storage/pack/ctor_protected_all_of_aligned.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -0,0 +1,156 @@
+//container template provided all public functions but constructors.
+#ifndef BOOST_COMPOSITE_STORAGE_CTOR_PROTECTED_ALL_OF_ALIGNED_HPP_INCLUDED
+#define BOOST_COMPOSITE_STORAGE_CTOR_PROTECTED_ALL_OF_ALIGNED_HPP_INCLUDED
+//  (C) Copyright Larry Evans 2011.
+//
+//  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/composite_storage/layout/operators_all_of_aligned.hpp>
+#include <boost/composite_storage/pack/layout_composite.hpp>
+#include <boost/composite_storage/pack/ctor_protected_fwd.hpp>
+#include <boost/composite_storage/methods/all_of.hpp>
+#include <boost/composite_storage/buffers/layout_buf.hpp>
+
+namespace boost
+{
+namespace composite_storage
+{
+namespace pack
+{
+  template
+  < class Index0
+  , typename... Components
+  >
+  struct
+ctor_protected
+  < tags::all_of_aligned
+  , Index0
+  , Components...
+  >
+: buffers::layout_buf
+  < layout_composite
+    < tags::all_of_aligned
+    , Index0
+    , Components...
+    >
+  >
+{
+        typedef
+      layout_composite
+      < tags::all_of_aligned
+      , Index0
+      , Components...
+      >
+    layout_comp
+    ;
+        typedef
+      typename layout_comp::scanned
+    scanned
+    ;
+        typedef
+      typename layout_comp::index_base
+    index_base
+    ;
+        typedef
+      typename layout_comp::index_undefined
+    index_undefined
+    ;
+        typedef
+      typename layout_comp::index_type
+    index_type
+    ;
+        typedef
+      methods::layout_indices
+      < scanned
+      , Index0
+      >
+    layout_indices
+    ;
+        typedef
+      methods::all_of
+      < layout_indices
+      >
+    methods_all
+    ;
+      ctor_protected const&
+    operator=(ctor_protected const& from)
+    {
+        char      *to_buf=this->address();
+        char const*fr_buf=from.address();
+          methods_all::
+        assign_all
+        ( to_buf
+        , fr_buf
+        );
+        return *this;
+    }
+      ctor_protected const&
+    operator=(ctor_protected&& from)
+    {
+        char      *to_buf=this->address();
+        buffers::rval_ref_buf fr_buf(from.address());
+          methods_all::
+        assign_all
+        ( to_buf
+        , fr_buf
+        );
+        return *this;
+    }
+    ~ctor_protected(void)
+    {
+        scanned::destroy( this->address());
+    }   
+ 
+      template
+      < index_type IndexValu
+      >
+    struct result_type
+    : layout_comp::template result_type<IndexValu>
+    {
+    };
+    
+      template
+      < index_type IndexValu
+      >
+      typename result_type<IndexValu>::type const&
+    project(void)const
+    {
+        mpl::integral_c<index_base,IndexValu> index;
+        return scanned::project(index,this->address());
+    }        
+      template
+      < index_type IndexValu
+      >
+      typename result_type<IndexValu>::type &
+    project(void)
+    {
+        mpl::integral_c<index_base,IndexValu> index;
+        return scanned::project(index,this->address());
+    }
+    
+ protected:
+      template
+      < index_type IndexValu
+      , typename... Args
+      >
+      void
+    inject(Args&&... args)
+    {
+        mpl::integral_c<index_base,IndexValu> index;
+        scanned::inject(index,this->address(),args...);
+    }
+    
+    ctor_protected(void)
+    {}
+    ctor_protected( ctor_protected const& from)
+    {}
+};
+
+}//exit pack namespace
+}//exit composite_storage namespace
+}//exit boost namespace
+
+#endif
Added: sandbox/variadic_templates/boost/composite_storage/pack/ctor_protected_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/boost/composite_storage/pack/ctor_protected_fwd.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -0,0 +1,35 @@
+//forward declare all ctor_protected templates whose components specified with parameter packs.
+#ifndef BOOST_COMPOSITE_STORAGE_PACK_CTOR_PROTECTED_FWD_HPP_INCLUDED
+#define BOOST_COMPOSITE_STORAGE_PWCK_CTOR_PROTECTED_FWD_HPP_INCLUDED
+#include <boost/composite_storage/tags.hpp>
+namespace boost
+{
+namespace composite_storage
+{
+namespace pack
+{
+  template
+  < class CompositeTag
+  , class Index0
+  , typename... Components
+  >
+  struct
+ctor_protected
+  /**@brief
+   *  Specializations provide all member functions
+   *  except constructors.  Constructors must be
+   *  provided by derived classes.
+   **@rationale
+   *  Since Components... may be anything, it's unknown, here,
+   *  what the requirements are for contruction of those components.  
+   *  For instance, there may not be a default CTOR for
+   *  one component, and no copy CTOR for another.
+   *  Only at the actual instantiation will these
+   *  be known; hence, only a derived class should
+   *  specify the public CTOR's for this composite.
+   */
+;
+}//exit pack namespace
+}//exit composite_storage namespace
+}//exit boost namespace
+#endif
Modified: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reify_apply.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reify_apply.hpp	(original)
+++ sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/reify_apply.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -4,6 +4,7 @@
 //#include <boost/mpl/assert.hpp>
 #include <boost/composite_storage/pack/multiple_dispatch/replace_source_with_target_ptr.hpp>
 #include <boost/composite_storage/pack/multiple_dispatch/apply_unpack.hpp>
+#include <boost/type_traits/remove_reference.hpp>
 
 namespace boost
 {
@@ -109,8 +110,14 @@
   >
   typename Functor::result_type
 reify_apply
-  ( Functor & a_functor
-  , ArgsAbstract&&... a_args_abstract
+  ( Functor& a_functor
+  ,   ArgsAbstract
+  #if 0
+      &&
+  #else
+      &
+  #endif
+    ... a_args_abstract
   )
   /**@brief
    *  Applies Reifier to each argument in a_args_abstract 
@@ -119,7 +126,7 @@
    */  
 {
       typename ptrs_target0_source
-      < ArgsAbstract...
+      < typename remove_reference<ArgsAbstract>::type...
       >::type
     ptrs_target_src_v(a_args_abstract...)
     //creates container of void pointers to a_args_abstract...
Modified: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/replace_source_with_target_ptr.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/replace_source_with_target_ptr.hpp	(original)
+++ sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/replace_source_with_target_ptr.hpp	2011-04-04 13:43:38 EDT (Mon, 04 Apr 2011)
@@ -74,8 +74,8 @@
         ptr_type
       my_ptrs[size]
         ;
-    //#define VOID_PTR_ARRAY_NO_INIT_LIST defined(__clang__)
-    #define VOID_PTR_ARRAY_NO_INIT_LIST 1
+    #define VOID_PTR_ARRAY_NO_INIT_LIST defined(__clang__)
+    //#define VOID_PTR_ARRAY_NO_INIT_LIST 1
     #if VOID_PTR_ARRAY_NO_INIT_LIST
         template
         < typename... Refs
@@ -95,7 +95,8 @@
         , RefsTail&... refs_tail
         )
       {
-          my_ptrs[sizeof...(Types)-sizeof...(RefsTail)-1]=remove_cv_ptr(ref_head);
+          const unsigned ndx=sizeof...(Types)-sizeof...(RefsTail)-1;
+          my_ptrs[ndx]=remove_cv_ptr(ref_head);
           assign_ptrs(refs_tail...);
       }
         void
@@ -249,11 +250,9 @@
         >
       super_type
       ;
-      
-      ptrs_target_source(void)
+      ptrs_target_source()
         {}
   };
-
   
   template
   < typename... ArgsSource
@@ -266,7 +265,7 @@
 {
         typedef
       ptrs_target_source
-      < mpl::package<>
+      < mpl::package<> //empty targets
       , ArgsSource...
       >
     type