$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r65580 - in sandbox/variadic_templates/boost/composite_storage: buffers layout pack
From: cppljevans_at_[hidden]
Date: 2010-09-24 14:47:38
Author: cppljevans
Date: 2010-09-24 14:47:37 EDT (Fri, 24 Sep 2010)
New Revision: 65580
URL: http://svn.boost.org/trac/boost/changeset/65580
Log:
use layout_buf with all_of container to do empty member space optimization.
Text files modified: 
   sandbox/variadic_templates/boost/composite_storage/buffers/char_buf.hpp              |    73 ++++++++++++++++++++++++++------------- 
   sandbox/variadic_templates/boost/composite_storage/layout/layout_of.hpp              |    25 +------------                           
   sandbox/variadic_templates/boost/composite_storage/pack/container_all_of_aligned.hpp |    46 ++++++++++--------------                
   3 files changed, 70 insertions(+), 74 deletions(-)
Modified: sandbox/variadic_templates/boost/composite_storage/buffers/char_buf.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/buffers/char_buf.hpp	(original)
+++ sandbox/variadic_templates/boost/composite_storage/buffers/char_buf.hpp	2010-09-24 14:47:37 EDT (Fri, 24 Sep 2010)
@@ -18,19 +18,22 @@
 namespace buffers
 {
 
-enum is_aligned
-{ yes_aligned
-, not_aligned
-};
-  
   template
   < std::size_t Size
-  , std::size_t Align
-  , is_aligned IsAligned=yes_aligned
+  , std::size_t Align=1
   >
   struct
 char_buf
-{
+;
+  template
+  < std::size_t Align
+  >
+  struct
+char_buf
+  < 0
+  , Align
+  >
+{  
     char_buf( void)
     {}
     char_buf( char_buf const&)
@@ -41,35 +44,23 @@
       char const*
     address(void)const
     {
-        void const*p=buffer.address();
-        return static_cast<char const*>(p);
+        return reinterpret_cast<char const*>(this);
     }
       char*
     address(void)
     {
-        void*p=buffer.address();
-        return static_cast<char*>(p);
+        return reinterpret_cast<char*>(this);
     }
- private:    
-      ::boost::aligned_storage
-      < Size?Size:1
-      , Align
-      >
-    buffer
-    ;
 };
-  
   template
   < std::size_t Size
-  , std::size_t Align //only used by specialization of layout::alignment_of
   >
   struct
 char_buf
   < Size
-  , Align
-  , not_aligned
+  , 0
   >
-{
+{  
     char_buf( void)
     {}
     char_buf( char_buf const&)
@@ -91,6 +82,40 @@
     char buffer[Size]
     ;
 };
+  template
+  < std::size_t Size
+  , std::size_t Align
+  >
+  struct
+char_buf
+{
+    char_buf( void)
+    {}
+    char_buf( char_buf const&)
+    {}
+      void
+    operator=( char_buf const&)
+    {}
+      char const*
+    address(void)const
+    {
+        void const*p=buffer.address();
+        return static_cast<char const*>(p);
+    }
+      char*
+    address(void)
+    {
+        void*p=buffer.address();
+        return static_cast<char*>(p);
+    }
+ private:    
+      ::boost::aligned_storage
+      < Size
+      , Align
+      >
+    buffer
+    ;
+};
 
 }//exit buffers namespace
 
Modified: sandbox/variadic_templates/boost/composite_storage/layout/layout_of.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/layout/layout_of.hpp	(original)
+++ sandbox/variadic_templates/boost/composite_storage/layout/layout_of.hpp	2010-09-24 14:47:37 EDT (Fri, 24 Sep 2010)
@@ -8,10 +8,11 @@
 //  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/buffers/char_buf.hpp>
+//#include <boost/composite_storage/buffers/char_buf.hpp>
 #include <boost/mpl/integral_c.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/type_traits/is_empty.hpp>
+#include <boost/type_traits/alignment_of.hpp>
 
 namespace boost
 {
@@ -39,21 +40,6 @@
 : public ::boost::alignment_of<T>
 {
 };
-  template
-  < std::size_t Size
-  , std::size_t Align
-  , buffers::is_aligned IsAligned
-  >
-struct alignment_of
-  < buffers::char_buf<Size,Align,IsAligned>
-  >
-{
-        static
-      std::size_t const
-    value
-    =Align
-    ;
-};    
 
   template
   < typename T
@@ -66,13 +52,6 @@
   , mpl::integral_c<std::size_t,sizeof(T)>
   >::type
 {
-  #if 0
-        static
-      std::size_t const
-    value
-    =sizeof(T)
-    ;
-  #endif
 };
 
 struct components_aligned_yes
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	2010-09-24 14:47:37 EDT (Fri, 24 Sep 2010)
@@ -13,6 +13,7 @@
 #include <boost/mpl/arg.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,10 +31,12 @@
   , Index0
   , Components...
   >
-: layout_composite
-  < tags::all_of_aligned
-  , Index0
-  , Components...
+: buffers::layout_buf
+  < layout_composite
+    < tags::all_of_aligned
+    , Index0
+    , Components...
+    >
   >
 {
         typedef
@@ -64,27 +67,16 @@
       methods::all_of<scanned,Index0>
     methods_all
     ;
- private:
-        typedef
-      buffers::char_buf
-      < scanned::comp_part::size
-      , scanned::comp_part::align
-      >
-    buffer_type
-    ;
-      buffer_type
-    buffer
-    ;
  public:
     container(void)
     {
-        char*to_buf=buffer.address();
+        char*to_buf=this->address();
         methods_all::ctor_default_all(to_buf);
     }
     container( container& from)
     {
-        char      *to_buf=buffer.address();
-        char const*fr_buf=from.buffer.address();
+        char      *to_buf=this->address();
+        char const*fr_buf=from.address();
           methods_all::
         ctor_copy_all
         ( to_buf
@@ -93,8 +85,8 @@
     }
     container( container&& from)
     {
-        char      *to_buf=buffer.address();
-        char      *fr_buf=from.buffer.address();
+        char      *to_buf=this->address();
+        char      *fr_buf=from.address();
           methods_all::
         ctor_copy_all
         ( to_buf
@@ -104,8 +96,8 @@
       container const&
     operator=(container const& from)
     {
-        char      *to_buf=buffer.address();
-        char const*fr_buf=from.buffer.address();
+        char      *to_buf=this->address();
+        char const*fr_buf=from.address();
           methods_all::
         assign_all
         ( to_buf
@@ -116,8 +108,8 @@
       container const&
     operator=(container&& from)
     {
-        char      *to_buf=buffer.address();
-        buffers::rval_ref_buf fr_buf(from.buffer.address());
+        char      *to_buf=this->address();
+        buffers::rval_ref_buf fr_buf(from.address());
           methods_all::
         assign_all
         ( to_buf
@@ -127,7 +119,7 @@
     }
     ~container(void)
     {
-        scanned::destroy( buffer.address());
+        scanned::destroy( this->address());
     }   
  
       template
@@ -147,7 +139,7 @@
     project(void)const
     {
         mpl::integral_c<index_base,IndexValu> index;
-        return scanned::project(index,buffer.address());
+        return scanned::project(index,this->address());
     }        
       template
       < index_type IndexValu
@@ -156,7 +148,7 @@
     project(void)
     {
         mpl::integral_c<index_base,IndexValu> index;
-        return scanned::project(index,buffer.address());
+        return scanned::project(index,this->address());
     }        
 };