Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65858 - sandbox/variadic_templates/libs/composite_storage/sandbox
From: cppljevans_at_[hidden]
Date: 2010-10-09 09:00:20


Author: cppljevans
Date: 2010-10-09 09:00:18 EDT (Sat, 09 Oct 2010)
New Revision: 65858
URL: http://svn.boost.org/trac/boost/changeset/65858

Log:
Using new show_layout_all_of_aligned.hpp give output:

A_type
===========
***components***
----------------
num size align sum_size
  1 4 4 4
  2 8 8 12
  3 8 8 20
  4 8 8 28
***composite***
---------------
num size align pad sum_pad offset
  5 32 8 0 0 _
  4 32 8 0 0 24
  3 24 8 0 0 16
  2 16 8 4 4 8
  1 4 4 0 4 0
  0 0 1 _ _ _
A_bools_type
===========
***components***
----------------
num size align sum_size
  1 4 4 4
  2 8 8 12
  3 8 8 20
  4 8 8 28
  5 1 1 29
  6 1 1 30
  7 1 1 31
  8 1 1 32
***composite***
---------------
num size align pad sum_pad offset
  9 40 8 4 4 _
  8 36 8 0 4 35
  7 35 8 0 4 34
  6 34 8 0 4 33
  5 33 8 0 4 32
  4 32 8 0 4 24
  3 24 8 0 4 16
  2 16 8 4 8 8
  1 4 4 0 8 0
  0 0 1 _ _ _
bools_A_type
===========
***components***
----------------
num size align sum_size
  1 1 1 1
  2 1 1 2
  3 1 1 3
  4 1 1 4
  5 4 4 8
  6 8 8 16
  7 8 8 24
  8 8 8 32
***composite***
---------------
num size align pad sum_pad offset
  9 32 8 0 0 _
  8 32 8 0 0 24
  7 24 8 0 0 16
  6 16 8 0 0 8
  5 8 4 0 0 4
  4 4 1 0 0 3
  3 3 1 0 0 2
  2 2 1 0 0 1
  1 1 1 0 0 0
  0 0 1 _ _ _

Text files modified:
   sandbox/variadic_templates/libs/composite_storage/sandbox/layout_all.1.cpp | 241 +++++----------------------------------
   1 files changed, 35 insertions(+), 206 deletions(-)

Modified: sandbox/variadic_templates/libs/composite_storage/sandbox/layout_all.1.cpp
==============================================================================
--- sandbox/variadic_templates/libs/composite_storage/sandbox/layout_all.1.cpp (original)
+++ sandbox/variadic_templates/libs/composite_storage/sandbox/layout_all.1.cpp 2010-10-09 09:00:18 EDT (Sat, 09 Oct 2010)
@@ -7,216 +7,45 @@
 // From: Rutger ter Borg (rutger_at_[hidden])
 // Date: 2010-10-06 14:33:43
 //
-#include <boost/composite_storage/layout/operators_all_of_aligned.hpp>
-#include <boost/mpl/package.hpp>
-#include <boost/mpl/fold_assoc_seq.hpp>
-
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/for_each.hpp>
-#include <iostream>
-
-namespace boost
-{
-namespace composite_storage
-{
-namespace layout
-{
- template
- < typename Pack
- >
-struct size_align_all
-;
- template
- < typename... T
- >
-struct size_align_all
- < mpl::package<T...>
- >
-{
- typedef
- mpl::package
- < typename components_aligned_yes::layout_of<T>...
- >
- type
- ;
-};
+#include <boost/composite_storage/utility/show_layout_all_of_aligned.hpp>
+using namespace boost::composite_storage::layout;
 
-struct print_layout_one
+int main(void)
 {
- template
- < std::size_t Size
- , std::size_t Align
+ typedef
+ boost::mpl::package
+ < int
+ , double
+ , double
+ , std::string
>
- void
- operator()(typename components_aligned_yes::template layout_data<Size,Align>)
- {
- std::cout<<"( size="<<Size<<", align="<<Align<<")\n";
- }
-};
-
- template
- < typename Pack
- >
-struct layout_all
-;
- template
- < typename... T
- >
-struct layout_all
- < mpl::package<T...>
- >
-{
- typedef
- typename size_align_all<mpl::package<T...> >::type
- layouts
- ;
- typedef
- components_aligned_yes::layout_data<>
- layout0
- ;
- typedef
- typename mpl::fold_assoc_seq
- < mpl::assoc_left
- , operators<tags::all_of_aligned>::template
- compose_layout
- < mpl::arg<1>
- , mpl::arg<2>
- >
- , layout0
- , layouts
- >::type
- type
- ;
-};
-
-struct print_layout_all
-{
- std::size_t
- padding_all
- ;
- print_layout_all(std::size_t a_padding=0)
- : padding_all(a_padding)
- {}
- typedef
- components_aligned_yes::layout_data<>
- layout0
- ;
- void
- operator()(layout0)
- {
- std::cout<<"layout0"
- <<"\n< size="<<layout0::size
- <<"\n, align="<<layout0::align
- <<"\n>\n";
- padding_all=0;
- }
- template
- < typename HeadComposed
- , typename TailLayout
+ A_type;
+ show_layout_all_of_aligned<A_type>("A_type");
+ typedef
+ boost::mpl::package
+ < int
+ , double
+ , double
+ , std::string
+ , bool
+ , bool
+ , bool
+ , bool
>
- void
- operator()
- ( operators<tags::all_of_aligned>::template
- compose_layout
- < HeadComposed
- , TailLayout
- >
- )
- {
- typedef
- operators<tags::all_of_aligned>::template
- compose_layout
- < HeadComposed
- , TailLayout
- >
- composition
- ;
- std::cout<<"composition"
- <<"\n< offset="<<composition::offset
- <<"\n, size="<<composition::size
- <<"\n, align="<<composition::align
- <<"\n>\n";
- std::size_t const padding_one=composition::offset-HeadComposed::size;
- std::cout<<"padding_one="<<padding_one<<"\n";
- padding_all+=padding_one;
- std::cout<<"padding_all="<<padding_all<<"\n";
- HeadComposed head;
- this->operator()(head);
- }
-
- template
- < typename Composed
+ A_bools_type;
+ show_layout_all_of_aligned<A_bools_type>("A_bools_type");
+ typedef
+ boost::mpl::package
+ < bool
+ , bool
+ , bool
+ , bool
+ , int
+ , double
+ , double
+ , std::string
>
- static
- void
- _(void)
- {
- typedef
- alignment::aligned_offset
- < Composed::size
- , Composed::align
- >
- aligned_offset
- /* aligned_offset::value is the size required
- * to assure that when two elements of composite
- * are in a vector, the 2nd would be aligned
- * properly.
- */
- ;
- std::cout
- <<"aligned size="
- <<aligned_offset::value
- <<"\n";
- print_layout_all pla(aligned_offset::value-Composed::size);
- Composed composed;
- pla(composed);
- }
-};
-
- template
- < typename Pack
- >
- void
-show_layout(char const*title)
-{
- std::cout<<title<<"\n";
- std::cout<<"===========\n";
- typedef
- typename size_align_all<Pack>::type
- size_align_result;
- print_layout_one plo;
- boost::mpl::for_each<size_align_result>(plo);
- typedef
- typename layout_all<Pack>::type
- layout_result;
- print_layout_all::_<layout_result>();
-}
-
-}//exit layout namespace
-}//exit composite_storage namespace
-}//exit boost namespace
-
-using namespace boost::composite_storage::layout;
-
-int main(void)
-{
- struct tagPs
- {
- char c;
- short s;
- char d;
- short t;
- };
- std::cout<<"sizeof(tagPs)="<<sizeof(tagPs)<<"\n";
- show_layout<boost::mpl::package<char,short,char,short> >("tagPs");
- struct Ptags
- {
- short s;
- char c;
- short t;
- char d;
- };
- std::cout<<"sizeof(Ptags)="<<sizeof(Ptags)<<"\n";
- show_layout<boost::mpl::package<short,char,short,char> >("Ptags");
+ bools_A_type;
+ show_layout_all_of_aligned<bools_A_type>("bools_A_type");
     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