From f84bc30bd352a2ea385f84d01ee0c60c24341243 Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Mon, 22 Feb 2010 22:55:54 +0000 Subject: [PATCH] adapt template classes/structs [SVN r59846] --- include/boost/fusion/adapted/class.hpp | 25 +-- .../adapted/class/adapt_assoc_class.hpp | 144 ++++++--------- .../adapted/class/adapt_assoc_class_named.hpp | 28 +++ .../fusion/adapted/class/adapt_class.hpp | 151 ++++------------ .../adapted/class/adapt_class_named.hpp | 162 ++--------------- .../fusion/adapted/class/class_iterator.hpp | 105 ----------- .../adapted/class/detail/adapt_base.hpp | 83 +++++++++ .../fusion/adapted/class/detail/at_impl.hpp | 95 +++++----- .../adapted/class/detail/at_key_impl.hpp | 54 ------ .../adapted/class/detail/begin_impl.hpp | 75 +++++--- .../adapted/class/detail/category_of_impl.hpp | 29 ++- .../adapted/class/detail/deref_data_impl.hpp | 22 +++ .../adapted/class/detail/deref_impl.hpp | 55 ++++++ .../fusion/adapted/class/detail/end_impl.hpp | 84 +++++---- .../fusion/adapted/class/detail/extension.hpp | 23 +++ .../adapted/class/detail/has_key_impl.hpp | 40 ----- .../adapted/class/detail/is_sequence_impl.hpp | 36 ++-- .../adapted/class/detail/is_view_impl.hpp | 37 ++-- .../adapted/class/detail/key_of_impl.hpp | 24 +++ .../fusion/adapted/class/detail/size_impl.hpp | 42 ++--- .../adapted/class/detail/value_at_impl.hpp | 52 ++---- .../class/detail/value_at_key_impl.hpp | 39 ---- .../class/detail/value_of_data_impl.hpp | 24 +++ .../adapted/class/detail/value_of_impl.hpp | 29 +++ .../boost/fusion/adapted/class/extension.hpp | 61 ------- include/boost/fusion/adapted/std_pair.hpp | 87 ++------- .../adapted/std_pair/detail/at_impl.hpp | 71 -------- .../adapted/std_pair/detail/begin_impl.hpp | 40 ----- .../std_pair/detail/category_of_impl.hpp | 35 ---- .../adapted/std_pair/detail/end_impl.hpp | 40 ----- .../std_pair/detail/is_sequence_impl.hpp | 31 ---- .../adapted/std_pair/detail/is_view_impl.hpp | 32 ---- .../adapted/std_pair/detail/size_impl.hpp | 31 ---- .../adapted/std_pair/detail/value_at_impl.hpp | 43 ----- .../adapted/std_pair/std_pair_iterator.hpp | 127 ------------- .../boost/fusion/adapted/std_pair/tag_of.hpp | 48 ----- include/boost/fusion/adapted/struct.hpp | 25 +-- .../adapted/struct/adapt_assoc_struct.hpp | 149 ++++++--------- .../struct/adapt_assoc_struct_named.hpp | 38 ++++ .../fusion/adapted/struct/adapt_struct.hpp | 113 ++++-------- .../adapted/struct/adapt_struct_named.hpp | 141 +++------------ .../adapted/struct/detail/adapt_base.hpp | 169 ++++++++++++++++++ .../fusion/adapted/struct/detail/at_impl.hpp | 85 +++++---- .../adapted/struct/detail/at_key_impl.hpp | 54 ------ .../adapted/struct/detail/begin_impl.hpp | 73 +++++--- .../struct/detail/category_of_impl.hpp | 23 ++- .../adapted/struct/detail/deref_data_impl.hpp | 22 +++ .../adapted/struct/detail/deref_impl.hpp | 56 ++++++ .../fusion/adapted/struct/detail/end_impl.hpp | 82 +++++---- .../adapted/struct/detail/extension.hpp | 42 +++++ .../adapted/struct/detail/has_key_impl.hpp | 40 ----- .../struct/detail/is_sequence_impl.hpp | 33 ++-- .../adapted/struct/detail/is_view_impl.hpp | 34 ++-- .../adapted/struct/detail/key_of_impl.hpp | 34 ++++ .../adapted/struct/detail/proxy_type.hpp | 60 +++++++ .../adapted/struct/detail/size_impl.hpp | 43 +++-- .../adapted/struct/detail/value_at_impl.hpp | 51 ++---- .../struct/detail/value_at_key_impl.hpp | 39 ---- .../struct/detail/value_of_data_impl.hpp | 22 +++ .../adapted/struct/detail/value_of_impl.hpp | 39 ++++ .../boost/fusion/adapted/struct/extension.hpp | 73 -------- .../fusion/adapted/struct/struct_iterator.hpp | 107 ----------- .../fusion/include/adapt_assoc_class.hpp | 13 ++ .../include/adapt_assoc_class_named.hpp | 13 ++ .../fusion/include/adapt_assoc_struct.hpp | 13 ++ .../include/adapt_assoc_struct_named.hpp | 13 ++ include/boost/fusion/include/adapt_class.hpp | 7 +- .../fusion/include/adapt_class_named.hpp | 13 ++ include/boost/fusion/include/adapt_struct.hpp | 5 +- .../fusion/include/adapt_struct_named.hpp | 7 +- include/boost/fusion/support/is_sequence.hpp | 5 +- test/Jamfile | 15 +- test/sequence/adapt_assoc_class.cpp | 136 ++++++++++++++ test/sequence/adapt_assoc_class_named.cpp | 142 +++++++++++++++ test/sequence/adapt_assoc_struct_named.cpp | 121 +++++++++++++ test/sequence/adapt_assoc_tpl_class.cpp | 140 +++++++++++++++ test/sequence/adapt_assoc_tpl_struct.cpp | 133 ++++++++++++++ test/sequence/adapt_tpl_class.cpp | 133 ++++++++++++++ test/sequence/adapt_tpl_struct.cpp | 122 +++++++++++++ 79 files changed, 2489 insertions(+), 2293 deletions(-) create mode 100644 include/boost/fusion/adapted/class/adapt_assoc_class_named.hpp delete mode 100644 include/boost/fusion/adapted/class/class_iterator.hpp create mode 100644 include/boost/fusion/adapted/class/detail/adapt_base.hpp delete mode 100644 include/boost/fusion/adapted/class/detail/at_key_impl.hpp create mode 100644 include/boost/fusion/adapted/class/detail/deref_data_impl.hpp create mode 100644 include/boost/fusion/adapted/class/detail/deref_impl.hpp create mode 100644 include/boost/fusion/adapted/class/detail/extension.hpp delete mode 100644 include/boost/fusion/adapted/class/detail/has_key_impl.hpp create mode 100644 include/boost/fusion/adapted/class/detail/key_of_impl.hpp delete mode 100644 include/boost/fusion/adapted/class/detail/value_at_key_impl.hpp create mode 100644 include/boost/fusion/adapted/class/detail/value_of_data_impl.hpp create mode 100644 include/boost/fusion/adapted/class/detail/value_of_impl.hpp delete mode 100644 include/boost/fusion/adapted/class/extension.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/detail/at_impl.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/detail/begin_impl.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/detail/category_of_impl.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/detail/end_impl.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/detail/is_sequence_impl.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/detail/is_view_impl.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/detail/size_impl.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/detail/value_at_impl.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/std_pair_iterator.hpp delete mode 100644 include/boost/fusion/adapted/std_pair/tag_of.hpp create mode 100644 include/boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp create mode 100644 include/boost/fusion/adapted/struct/detail/adapt_base.hpp delete mode 100644 include/boost/fusion/adapted/struct/detail/at_key_impl.hpp create mode 100644 include/boost/fusion/adapted/struct/detail/deref_data_impl.hpp create mode 100644 include/boost/fusion/adapted/struct/detail/deref_impl.hpp create mode 100644 include/boost/fusion/adapted/struct/detail/extension.hpp delete mode 100644 include/boost/fusion/adapted/struct/detail/has_key_impl.hpp create mode 100644 include/boost/fusion/adapted/struct/detail/key_of_impl.hpp create mode 100644 include/boost/fusion/adapted/struct/detail/proxy_type.hpp delete mode 100644 include/boost/fusion/adapted/struct/detail/value_at_key_impl.hpp create mode 100644 include/boost/fusion/adapted/struct/detail/value_of_data_impl.hpp create mode 100644 include/boost/fusion/adapted/struct/detail/value_of_impl.hpp delete mode 100644 include/boost/fusion/adapted/struct/extension.hpp delete mode 100644 include/boost/fusion/adapted/struct/struct_iterator.hpp create mode 100644 include/boost/fusion/include/adapt_assoc_class.hpp create mode 100644 include/boost/fusion/include/adapt_assoc_class_named.hpp create mode 100644 include/boost/fusion/include/adapt_assoc_struct.hpp create mode 100644 include/boost/fusion/include/adapt_assoc_struct_named.hpp create mode 100644 include/boost/fusion/include/adapt_class_named.hpp create mode 100644 test/sequence/adapt_assoc_class.cpp create mode 100644 test/sequence/adapt_assoc_class_named.cpp create mode 100644 test/sequence/adapt_assoc_struct_named.cpp create mode 100644 test/sequence/adapt_assoc_tpl_class.cpp create mode 100644 test/sequence/adapt_assoc_tpl_struct.cpp create mode 100644 test/sequence/adapt_tpl_class.cpp create mode 100644 test/sequence/adapt_tpl_struct.cpp diff --git a/include/boost/fusion/adapted/class.hpp b/include/boost/fusion/adapted/class.hpp index 37ee27ab..75150942 100644 --- a/include/boost/fusion/adapted/class.hpp +++ b/include/boost/fusion/adapted/class.hpp @@ -1,29 +1,18 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_CLASS_OCTOBER_4_2009_839PM) -#define BOOST_FUSION_CLASS_OCTOBER_4_2009_839PM -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_CLASS_HPP +#define BOOST_FUSION_ADAPTED_CLASS_HPP + +#include #include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #endif diff --git a/include/boost/fusion/adapted/class/adapt_assoc_class.hpp b/include/boost/fusion/adapted/class/adapt_assoc_class.hpp index 3dbf4284..676f0fb0 100644 --- a/include/boost/fusion/adapted/class/adapt_assoc_class.hpp +++ b/include/boost/fusion/adapted/class/adapt_assoc_class.hpp @@ -1,113 +1,69 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2007 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_ADAPT_ASSOC_CLASS_OCTOBER_4_2009_840PM) -#define BOOST_FUSION_ADAPT_ASSOC_CLASS_OCTOBER_4_2009_840PM -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_CLASS_ADAPT_ASSOC_CLASS_HPP +#define BOOST_FUSION_ADAPTED_CLASS_ADAPT_ASSOC_CLASS_HPP + +#include +#include +#include + +#include +#include +#include #include #include +#include #include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#define BOOST_FUSION_ADAPT_ASSOC_CLASS_FILLER_0(A, B, C, D, E)\ + ((A, B, C, D, E)) BOOST_FUSION_ADAPT_ASSOC_CLASS_FILLER_1 +#define BOOST_FUSION_ADAPT_ASSOC_CLASS_FILLER_1(A, B, C, D, E)\ + ((A, B, C, D, E)) BOOST_FUSION_ADAPT_ASSOC_CLASS_FILLER_0 +#define BOOST_FUSION_ADAPT_ASSOC_CLASS_FILLER_0_END +#define BOOST_FUSION_ADAPT_ASSOC_CLASS_FILLER_1_END -namespace boost { namespace fusion { namespace extension { - template - struct class_assoc_member; -}}} - - -#define BOOST_FUSION_ADAPT_ASSOC_CLASS(name, bseq) \ - BOOST_FUSION_ADAPT_ASSOC_CLASS_I( \ - name, BOOST_PP_CAT(BOOST_FUSION_ADAPT_ASSOC_CLASS_X bseq, 0)) \ - /***/ - -#define BOOST_FUSION_ADAPT_ASSOC_CLASS_X(x, y, z) ((x, y, z)) BOOST_FUSION_ADAPT_ASSOC_CLASS_Y -#define BOOST_FUSION_ADAPT_ASSOC_CLASS_Y(x, y, z) ((x, y, z)) BOOST_FUSION_ADAPT_ASSOC_CLASS_X -#define BOOST_FUSION_ADAPT_ASSOC_CLASS_X0 -#define BOOST_FUSION_ADAPT_ASSOC_CLASS_Y0 - -// BOOST_FUSION_ADAPT_ASSOC_CLASS_I generates the overarching structure and uses -// SEQ_FOR_EACH_I to generate the "linear" substructures. -// Thanks to Paul Mensonides for the PP macro help - -#define BOOST_FUSION_ADAPT_ASSOC_CLASS_I(name, seq) \ - namespace boost { namespace fusion { namespace traits \ - { \ - template <> \ - struct tag_of \ - { \ - typedef class_tag type; \ - }; \ - }}} \ +#define BOOST_FUSION_ADAPT_ASSOC_CLASS_C( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE) \ \ - namespace boost { namespace mpl \ - { \ - template \ - struct sequence_tag; \ + BOOST_FUSION_ADAPT_CLASS_C_BASE(TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,ATTRIBUTE,5) \ \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - }} \ - \ - namespace boost { namespace fusion { namespace extension \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_assoc_key \ { \ - template <> \ - struct class_size : mpl::int_ {}; \ - BOOST_PP_SEQ_FOR_EACH_I(BOOST_FUSION_ADAPT_ASSOC_CLASS_C, name, seq) \ - }}} \ - /***/ - -#define BOOST_FUSION_ADAPT_ASSOC_CLASS_C(r, name, i, xy) \ - template <> \ - struct class_member \ - { \ - typedef BOOST_PP_TUPLE_ELEM(3, 0, xy) type; \ - static type& call(name& class_) \ - { \ - return class_.BOOST_PP_TUPLE_ELEM(3, 1, xy); \ - }; \ - }; \ - template<> \ - struct class_assoc_member \ - { \ - typedef BOOST_PP_TUPLE_ELEM(3, 0, xy) type; \ - static type& call(name& class_) \ - { \ - return class_.BOOST_PP_TUPLE_ELEM(3, 1, xy); \ - }; \ + typedef BOOST_PP_TUPLE_ELEM(5, 4, ATTRIBUTE) type; \ }; - /***/ + +#define BOOST_FUSION_ADAPT_ASSOC_TPL_CLASS( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (1)TEMPLATE_PARAMS_SEQ, \ + (1)NAME_SEQ, \ + assoc_class_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_ASSOC_CLASS_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_CLASS_C) + +#define BOOST_FUSION_ADAPT_ASSOC_CLASS(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + assoc_class_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_ASSOC_CLASS_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_CLASS_C) #endif diff --git a/include/boost/fusion/adapted/class/adapt_assoc_class_named.hpp b/include/boost/fusion/adapted/class/adapt_assoc_class_named.hpp new file mode 100644 index 00000000..81930556 --- /dev/null +++ b/include/boost/fusion/adapted/class/adapt_assoc_class_named.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_CLASS_ADAPT_ASSOC_CLASS_NAMED_HPP +#define BOOST_FUSION_ADAPTED_CLASS_ADAPT_ASSOC_CLASS_NAMED_HPP + +#include +#include + +#define BOOST_FUSION_ADAPT_ASSOC_CLASS_NAMED_NS( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE( \ + WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \ + \ + BOOST_FUSION_ADAPT_ASSOC_CLASS( \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ)NAME, \ + ATTRIBUTES) + +#define BOOST_FUSION_ADAPT_ASSOC_CLASS_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_ASSOC_CLASS_NAMED_NS( \ + WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES) + +#endif diff --git a/include/boost/fusion/adapted/class/adapt_class.hpp b/include/boost/fusion/adapted/class/adapt_class.hpp index 9622e7b1..42f66632 100644 --- a/include/boost/fusion/adapted/class/adapt_class.hpp +++ b/include/boost/fusion/adapted/class/adapt_class.hpp @@ -1,132 +1,55 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2009-2010 Hartmut Kaiser + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_ADAPT_CLASS_OCTOBER_4_2009_840PM) -#define BOOST_FUSION_ADAPT_CLASS_OCTOBER_4_2009_840PM -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_CLASS_ADAPT_CLASS_HPP +#define BOOST_FUSION_ADAPTED_CLASS_ADAPT_CLASS_HPP + +#include +#include + +#include +#include +#include #include #include +#include #include +#include #include #include -#include -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#define BOOST_FUSION_ADAPT_CLASS_FILLER_0(A, B, C, D)\ + ((A, B, C, D)) BOOST_FUSION_ADAPT_CLASS_FILLER_1 +#define BOOST_FUSION_ADAPT_CLASS_FILLER_1(A, B, C, D)\ + ((A, B, C, D)) BOOST_FUSION_ADAPT_CLASS_FILLER_0 +#define BOOST_FUSION_ADAPT_CLASS_FILLER_0_END +#define BOOST_FUSION_ADAPT_CLASS_FILLER_1_END -#define BOOST_FUSION_ADAPT_CLASS(name, bseq) \ - BOOST_FUSION_ADAPT_CLASS_I( \ - name, BOOST_PP_CAT(BOOST_FUSION_ADAPT_CLASS_X bseq, 0)) \ - /***/ +#define BOOST_FUSION_ADAPT_CLASS_C(TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE) \ + BOOST_FUSION_ADAPT_CLASS_C_BASE( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE, 4) -#define BOOST_FUSION_ADAPT_CLASS_X(w, x, y, z) ((w, x, y, z)) BOOST_FUSION_ADAPT_CLASS_Y -#define BOOST_FUSION_ADAPT_CLASS_Y(w, x, y, z) ((w, x, y, z)) BOOST_FUSION_ADAPT_CLASS_X -#define BOOST_FUSION_ADAPT_CLASS_X0 -#define BOOST_FUSION_ADAPT_CLASS_Y0 +#define BOOST_FUSION_ADAPT_TPL_CLASS(TEMPLATE_PARAMS_SEQ, NAME_SEQ , ATTRIBUTES)\ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (1)TEMPLATE_PARAMS_SEQ, \ + (1)NAME_SEQ, \ + class_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_CLASS_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_CLASS_C) -// BOOST_FUSION_ADAPT_CLASS_I generates the overarching structure and uses -// SEQ_FOR_EACH_I to generate the "linear" substructures. -// Thanks to Paul Mensonides for the PP macro help - -#define BOOST_FUSION_ADAPT_CLASS_I(name, seq) \ - namespace boost { namespace fusion { namespace traits \ - { \ - template <> \ - struct tag_of \ - { \ - typedef class_tag type; \ - }; \ - }}} \ - \ - namespace boost { namespace mpl \ - { \ - template \ - struct sequence_tag; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - }} \ - \ - namespace boost { namespace fusion { namespace extension \ - { \ - template <> \ - struct class_size : mpl::int_ {}; \ - template struct class_member_proxy; \ - BOOST_PP_SEQ_FOR_EACH_I(BOOST_FUSION_ADAPT_CLASS_C, name, seq) \ - }}} \ - /***/ - -#define BOOST_FUSION_ADAPT_CLASS_C(r, fullname, i, xy) \ - template <> \ - struct class_member_proxy \ - { \ - typedef BOOST_PP_TUPLE_ELEM(4, 0, xy) lvalue; \ - typedef BOOST_PP_TUPLE_ELEM(4, 1, xy) rvalue; \ - typedef remove_const::type>::type type; \ - typedef add_reference::type>::type cref_type; \ - \ - class_member_proxy(fullname& obj) : obj(obj) {} \ - fullname& obj; \ - \ - class_member_proxy& operator=(cref_type val) \ - { \ - BOOST_PP_TUPLE_ELEM(4, 3, xy); \ - return *this; \ - } \ - \ - operator lvalue() \ - { \ - return BOOST_PP_TUPLE_ELEM(4, 2, xy); \ - } \ - }; \ - \ - template <> \ - struct class_member \ - { \ - typedef class_member_proxy proxy; \ - typedef proxy::type type; \ - typedef proxy::rvalue get_type; \ - \ - static get_type call(fullname const& obj) \ - { \ - return BOOST_PP_TUPLE_ELEM(4, 2, xy); \ - } \ - \ - static proxy call(fullname& obj) \ - { \ - return proxy(obj); \ - } \ - }; \ - /***/ +#define BOOST_FUSION_ADAPT_CLASS(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + class_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_CLASS_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_CLASS_C) #endif diff --git a/include/boost/fusion/adapted/class/adapt_class_named.hpp b/include/boost/fusion/adapted/class/adapt_class_named.hpp index f96eba72..edc73b25 100644 --- a/include/boost/fusion/adapted/class/adapt_class_named.hpp +++ b/include/boost/fusion/adapted/class/adapt_class_named.hpp @@ -1,156 +1,28 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2009-2010 Hartmut Kaiser + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_ADAPT_CLASS_NAMED_JAN_27_2010_0614PM) -#define BOOST_FUSION_ADAPT_CLASS_NAMED_JAN_27_2010_0614PM -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_CLASS_ADAPT_CLASS_NAMED_HPP +#define BOOST_FUSION_ADAPTED_CLASS_ADAPT_CLASS_NAMED_HPP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include -#define BOOST_FUSION_ADAPT_CLASS_NAMED(name, newname, bseq) \ - BOOST_FUSION_ADAPT_CLASS_NAMED_I(name, (boost)(fusion)(adapted), newname, \ - BOOST_PP_CAT(BOOST_FUSION_ADAPT_CLASS_NAMED_X bseq, 0)) \ - /***/ +#define BOOST_FUSION_ADAPT_CLASS_NAMED_NS( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE( \ + WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \ + \ + BOOST_FUSION_ADAPT_CLASS( \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ)NAME, \ + ATTRIBUTES) -#define BOOST_FUSION_ADAPT_CLASS_NAMED_NS(name, ns, newname, bseq) \ - BOOST_FUSION_ADAPT_CLASS_NAMED_I(name, ns, newname, \ - BOOST_PP_CAT(BOOST_FUSION_ADAPT_CLASS_NAMED_X bseq, 0)) \ - /***/ - -#define BOOST_FUSION_ADAPT_CLASS_NAMED_X(w, x, y, z) ((w, x, y, z)) BOOST_FUSION_ADAPT_CLASS_NAMED_Y -#define BOOST_FUSION_ADAPT_CLASS_NAMED_Y(w, x, y, z) ((w, x, y, z)) BOOST_FUSION_ADAPT_CLASS_NAMED_X -#define BOOST_FUSION_ADAPT_CLASS_NAMED_X0 -#define BOOST_FUSION_ADAPT_CLASS_NAMED_Y0 - -// BOOST_FUSION_ADAPT_CLASS_I generates the overarching structure and uses -// SEQ_FOR_EACH_I to generate the "linear" substructures. -// Thanks to Paul Mensonides for the PP macro help - -#define BOOST_FUSION_ADAPT_CLASS_NAMED_I(name, ns, newname, seq) \ - BOOST_PP_SEQ_FOR_EACH_R(1, BOOST_FUSION_ADAPT_CLASS_NAMED_NS_B, _, ns) \ - struct newname \ - { \ - newname(name& s) : obj(s) {} \ - name& obj; \ - }; \ - BOOST_PP_SEQ_FOR_EACH_R(1, BOOST_FUSION_ADAPT_CLASS_NAMED_NS_E, _, ns) \ - \ - namespace boost { namespace fusion { namespace traits \ - { \ - template <> \ - struct tag_of \ - { \ - typedef class_tag type; \ - }; \ - }}} \ - \ - namespace boost { namespace mpl \ - { \ - template \ - struct sequence_tag; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - }} \ - \ - namespace boost { namespace fusion { namespace extension \ - { \ - template <> \ - struct class_size \ - : mpl::int_ {}; \ - template struct class_member_proxy; \ - BOOST_PP_SEQ_FOR_EACH_I(BOOST_FUSION_ADAPT_CLASS_NAMED_C, \ - BOOST_FUSION_ADAPT_CLASS_NAMED_NAME(ns, newname),seq) \ - }}} \ - /***/ - -#define BOOST_FUSION_ADAPT_CLASS_NAMED_NAME(ns, newname) \ - BOOST_PP_SEQ_FOR_EACH_R(1, BOOST_FUSION_ADAPT_CLASS_NAMED_NS_D, _, ns) \ - newname \ - /***/ - -#define BOOST_FUSION_ADAPT_CLASS_NAMED_NS_B(r, _, ns) namespace ns { -#define BOOST_FUSION_ADAPT_CLASS_NAMED_NS_D(r, _, ns) ns:: -#define BOOST_FUSION_ADAPT_CLASS_NAMED_NS_E(r, _, ns) } - -#define BOOST_FUSION_ADAPT_CLASS_NAMED_C(r, fullname, i, xy) \ - template <> \ - struct class_member_proxy \ - { \ - typedef BOOST_PP_TUPLE_ELEM(4, 0, xy) lvalue; \ - typedef BOOST_PP_TUPLE_ELEM(4, 1, xy) rvalue; \ - typedef remove_const::type>::type type; \ - typedef add_reference::type>::type cref_type; \ - \ - class_member_proxy(fullname& obj) : obj(obj) {} \ - fullname& obj; \ - \ - class_member_proxy& operator=(cref_type val) \ - { \ - BOOST_PP_TUPLE_ELEM(4, 3, xy); \ - return *this; \ - } \ - \ - operator lvalue() \ - { \ - return BOOST_PP_TUPLE_ELEM(4, 2, xy); \ - } \ - }; \ - \ - template <> \ - struct class_member \ - { \ - typedef class_member_proxy proxy; \ - typedef proxy::type type; \ - typedef proxy::rvalue get_type; \ - \ - static get_type call(fullname const& obj) \ - { \ - return BOOST_PP_TUPLE_ELEM(4, 2, xy); \ - } \ - \ - static proxy call(fullname& obj) \ - { \ - return proxy(obj); \ - } \ - }; \ - /***/ +#define BOOST_FUSION_ADAPT_CLASS_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_CLASS_NAMED_NS( \ + WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES) #endif diff --git a/include/boost/fusion/adapted/class/class_iterator.hpp b/include/boost/fusion/adapted/class/class_iterator.hpp deleted file mode 100644 index 639ee927..00000000 --- a/include/boost/fusion/adapted/class/class_iterator.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(FUSION_CLASS_ITERATOR_OCTOBER_4_2009_839M) -#define FUSION_CLASS_ITERATOR_OCTOBER_4_2009_839M - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace fusion -{ - struct random_access_traversal_tag; - - template - struct class_iterator - : iterator_facade, random_access_traversal_tag> - { - BOOST_MPL_ASSERT_RELATION(N_, >=, 0); - BOOST_MPL_ASSERT_RELATION(N_, <=, extension::class_size::value); - - typedef mpl::int_ index; - typedef Class class_type; - - class_iterator(Class& class_) - : class_(class_) {} - Class& class_; - - template - struct value_of - : extension::class_member - { - }; - - template - struct deref - { - typedef typename - mpl::if_< - is_const - , typename extension::class_member::get_type - , typename extension::class_member::proxy - >::type - type; - - static type - call(Iterator const& iter) - { - return extension::class_member:: - call(iter.class_); - } - }; - - template - struct advance - { - typedef typename Iterator::index index; - typedef typename Iterator::class_type class_type; - typedef class_iterator type; - - static type - call(Iterator const& iter) - { - return type(iter.class_); - } - }; - - template - struct next : advance > {}; - - template - struct prior : advance > {}; - - template - struct distance : mpl::minus - { - typedef typename - mpl::minus< - typename I2::index, typename I1::index - >::type - type; - - static type - call(I1 const&, I2 const&) - { - return type(); - } - }; - }; -}} - -#endif - - diff --git a/include/boost/fusion/adapted/class/detail/adapt_base.hpp b/include/boost/fusion/adapted/class/detail/adapt_base.hpp new file mode 100644 index 00000000..511dc046 --- /dev/null +++ b/include/boost/fusion/adapted/class/detail/adapt_base.hpp @@ -0,0 +1,83 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_ADAPT_BASE_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_ADAPT_BASE_HPP + +#include + +#define BOOST_FUSION_ADAPT_CLASS_C_BASE(\ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,ATTRIBUTE,ATTRIBUTE_TUPEL_SIZE) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct class_member_proxy< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + > \ + { \ + typedef \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \ + type; \ + \ + class_member_proxy(BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj)\ + : obj(obj) \ + {} \ + \ + template \ + class_member_proxy& \ + operator=(Arg val) \ + { \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 3, ATTRIBUTE); \ + return *this; \ + } \ + \ + operator type() \ + { \ + return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \ + } \ + \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \ + }; \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_member \ + { \ + typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \ + typedef \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) \ + get_type; \ + typedef \ + class_member_proxy< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + > \ + proxy; \ + \ + static get_type \ + call(BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& obj) \ + { \ + return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \ + }; \ + \ + static proxy \ + call(BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj) \ + { \ + return proxy(obj); \ + }; \ + }; + +namespace boost { namespace fusion { namespace extension +{ + template + struct class_member_proxy; +}}} + +#endif diff --git a/include/boost/fusion/adapted/class/detail/at_impl.hpp b/include/boost/fusion/adapted/class/detail/at_impl.hpp index 12b5171f..9b17224b 100644 --- a/include/boost/fusion/adapted/class/detail/at_impl.hpp +++ b/include/boost/fusion/adapted/class/detail/at_impl.hpp @@ -1,70 +1,55 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_AT_IMPL_OCTOBER_4_2009_920PM) -#define BOOST_FUSION_AT_IMPL_OCTOBER_4_2009_920PM -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_AT_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_AT_IMPL_HPP -namespace boost { namespace fusion +#include +#include +#include + +namespace boost { namespace fusion { namespace extension { - struct class_tag; + template + struct at_impl; - namespace extension + template <> + struct at_impl { - template - struct at_impl; - - template - struct class_member; - - template - struct class_size; - - template <> - struct at_impl + template + struct apply { - template - struct apply + typedef + extension::struct_member< + typename remove_const::type + , N::value + > + member; + + typedef typename + mpl::if_< + is_const + , typename member::get_type + , typename member::proxy + >::type + type; + + static type + call(Seq& seq) { - static int const n_value = N::value; - BOOST_MPL_ASSERT_RELATION( - n_value, <=, extension::class_size::value); - - typedef typename - extension::class_member - element; - - typedef typename - mpl::if_< - is_const - , typename class_member::get_type - , typename class_member::proxy - >::type - type; - - static type - call(Sequence& seq) - { - return extension:: - class_member::call(seq); - } - - //~ static typename class_member::get_type - //~ call(Sequence const& seq) - //~ { - //~ return extension:: - //~ class_member::call(seq); - //~ } - }; + return member::call(seq); + } }; - } -}} + }; + + template <> + struct at_impl + : at_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/class/detail/at_key_impl.hpp b/include/boost/fusion/adapted/class/detail/at_key_impl.hpp deleted file mode 100644 index 9df985bf..00000000 --- a/include/boost/fusion/adapted/class/detail/at_key_impl.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2007 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_AT_KEY_IMPL_OCTOBER_4_2009_920PM) -#define BOOST_FUSION_AT_KEY_IMPL_OCTOBER_4_2009_920PM - -#include - -namespace boost { namespace fusion -{ - struct class_tag; - - namespace extension - { - template - struct at_key_impl; - - template - struct class_assoc_member; - - template <> - struct at_key_impl - { - template - struct apply - { - typedef typename - extension::class_assoc_member - element; - - typedef typename - mpl::eval_if< - is_const - , detail::cref_result - , detail::ref_result - >::type - type; - - static type - call(Sequence& seq) - { - return extension:: - class_assoc_member::call(seq); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/class/detail/begin_impl.hpp b/include/boost/fusion/adapted/class/detail/begin_impl.hpp index 4fadac4e..4255b80d 100644 --- a/include/boost/fusion/adapted/class/detail/begin_impl.hpp +++ b/include/boost/fusion/adapted/class/detail/begin_impl.hpp @@ -1,40 +1,65 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_BEGIN_IMPL_OCTOBER_4_2009_920PM) -#define BOOST_FUSION_BEGIN_IMPL_OCTOBER_4_2009_920PM -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_BEGIN_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_BEGIN_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct class_tag; + template + struct begin_impl; - namespace extension + template <> + struct begin_impl { - template - struct begin_impl; - - template <> - struct begin_impl + template + struct apply { - template - struct apply - { - typedef class_iterator type; + typedef + basic_iterator< + class_iterator_tag + , random_access_traversal_tag + , Seq + , 0 + > + type; - static type - call(Sequence& v) - { - return type(v); - } - }; + static type + call(Seq& seq) + { + return type(seq,0); + } }; - } -}} + }; + + template <> + struct begin_impl + { + template + struct apply + { + typedef + basic_iterator< + assoc_class_iterator_tag + , assoc_class_category + , Seq + , 0 + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; +}}} #endif diff --git a/include/boost/fusion/adapted/class/detail/category_of_impl.hpp b/include/boost/fusion/adapted/class/detail/category_of_impl.hpp index 821cf38b..a8dde001 100644 --- a/include/boost/fusion/adapted/class/detail/category_of_impl.hpp +++ b/include/boost/fusion/adapted/class/detail/category_of_impl.hpp @@ -1,34 +1,31 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_CATEGORY_OF_IMPL_OCTOBER_4_2009_919PM) -#define BOOST_FUSION_CATEGORY_OF_IMPL_OCTOBER_4_2009_919PM -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_CATEGORY_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_CATEGORY_OF_IMPL_HPP + +#include namespace boost { namespace fusion { - struct class_tag; - struct random_access_traversal_tag; - namespace extension { - template + template struct category_of_impl; template<> struct category_of_impl - { - template - struct apply - { - typedef random_access_traversal_tag type; - }; - }; + : category_of_impl + {}; + + template<> + struct category_of_impl + : category_of_impl + {}; } }} diff --git a/include/boost/fusion/adapted/class/detail/deref_data_impl.hpp b/include/boost/fusion/adapted/class/detail/deref_data_impl.hpp new file mode 100644 index 00000000..60737295 --- /dev/null +++ b/include/boost/fusion/adapted/class/detail/deref_data_impl.hpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_DEREF_DATA_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_DEREF_DATA_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_data_impl; + + template <> + struct deref_data_impl + : deref_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/adapted/class/detail/deref_impl.hpp b/include/boost/fusion/adapted/class/detail/deref_impl.hpp new file mode 100644 index 00000000..ed0cf535 --- /dev/null +++ b/include/boost/fusion/adapted/class/detail/deref_impl.hpp @@ -0,0 +1,55 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_DEREF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_DEREF_IMPL_HPP + +#include +#include +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_impl; + + template <> + struct deref_impl + { + template + struct apply + { + typedef + extension::struct_member< + typename remove_const::type + , It::index::value + > + member; + + typedef typename + mpl::if_< + is_const + , typename member::get_type + , typename member::proxy + >::type + type; + + static type + call(It const& it) + { + return member::call(*it.seq); + } + }; + }; + + template <> + struct deref_impl + : deref_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/adapted/class/detail/end_impl.hpp b/include/boost/fusion/adapted/class/detail/end_impl.hpp index 81c02c30..934a8ba9 100644 --- a/include/boost/fusion/adapted/class/detail/end_impl.hpp +++ b/include/boost/fusion/adapted/class/detail/end_impl.hpp @@ -1,48 +1,66 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_END_IMPL_OCTOBER_4_2009_919PM) -#define BOOST_FUSION_END_IMPL_OCTOBER_4_2009_919PM -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_END_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_END_IMPL_HPP -namespace boost { namespace fusion +#include +#include + +namespace boost { namespace fusion { namespace extension { - struct class_tag; + template + struct end_impl; - namespace extension + template <> + struct end_impl { - template - struct end_impl; - - template - struct class_size; - - template <> - struct end_impl + template + struct apply { - template - struct apply - { - typedef - class_iterator< - Sequence - , class_size::value - > - type; + typedef + basic_iterator< + class_iterator_tag + , random_access_traversal_tag + , Seq + , struct_size::type>::value + > + type; - static type - call(Sequence& v) - { - return type(v); - } - }; + static type + call(Seq& seq) + { + return type(seq,0); + } }; - } -}} + }; + + template <> + struct end_impl + { + template + struct apply + { + typedef + basic_iterator< + assoc_class_iterator_tag + , assoc_class_category + , Seq + , struct_size::type>::value + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; +}}} #endif diff --git a/include/boost/fusion/adapted/class/detail/extension.hpp b/include/boost/fusion/adapted/class/detail/extension.hpp new file mode 100644 index 00000000..3d505da8 --- /dev/null +++ b/include/boost/fusion/adapted/class/detail/extension.hpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_EXTENSION_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_EXTENSION_HPP + +#include + +namespace boost { namespace fusion +{ + struct class_tag; + struct class_iterator_tag; + struct assoc_class_tag; + struct assoc_class_iterator_tag; + + typedef assoc_struct_category assoc_class_category; +}} + +#endif diff --git a/include/boost/fusion/adapted/class/detail/has_key_impl.hpp b/include/boost/fusion/adapted/class/detail/has_key_impl.hpp deleted file mode 100644 index 27f1adce..00000000 --- a/include/boost/fusion/adapted/class/detail/has_key_impl.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2007 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_HAS_KEY_IMPL_OCTOBER_4_2009_919PM) -#define BOOST_FUSION_HAS_KEY_IMPL_OCTOBER_4_2009_919PM - -#include -#include - -namespace boost { namespace fusion { - - struct class_tag; - - namespace extension - { - struct no_such_member; - - template - struct has_key_impl; - - template - struct class_assoc_member; - - template<> - struct has_key_impl - { - template - struct apply - : mpl::not_::type> > - { - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/class/detail/is_sequence_impl.hpp b/include/boost/fusion/adapted/class/detail/is_sequence_impl.hpp index c1d35de1..d35e212c 100644 --- a/include/boost/fusion/adapted/class/detail/is_sequence_impl.hpp +++ b/include/boost/fusion/adapted/class/detail/is_sequence_impl.hpp @@ -1,31 +1,29 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_IS_SEQUENCE_IMPL_OCTOBER_4_2009_919PM) -#define BOOST_FUSION_IS_SEQUENCE_IMPL_OCTOBER_4_2009_919PM -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_IS_SEQUENCE_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_IS_SEQUENCE_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct class_tag; + template + struct is_sequence_impl; - namespace extension - { - template - struct is_sequence_impl; + template<> + struct is_sequence_impl + : is_sequence_impl + {}; - template<> - struct is_sequence_impl - { - template - struct apply : mpl::true_ {}; - }; - } -}} + template <> + struct is_sequence_impl + : is_sequence_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/class/detail/is_view_impl.hpp b/include/boost/fusion/adapted/class/detail/is_view_impl.hpp index 86ce0074..f52976e4 100644 --- a/include/boost/fusion/adapted/class/detail/is_view_impl.hpp +++ b/include/boost/fusion/adapted/class/detail/is_view_impl.hpp @@ -1,32 +1,29 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_IS_VIEW_IMPL_OCTOBER_4_2009_919PM) -#define BOOST_FUSION_IS_VIEW_IMPL_OCTOBER_4_2009_919PM -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_IS_VIEW_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_IS_VIEW_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct class_tag; + template + struct is_view_impl; - namespace extension - { - template - struct is_view_impl; + template<> + struct is_view_impl + : is_view_impl + {}; - template<> - struct is_view_impl - { - template - struct apply : mpl::false_ - {}; - }; - } -}} + template <> + struct is_view_impl + : is_view_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/class/detail/key_of_impl.hpp b/include/boost/fusion/adapted/class/detail/key_of_impl.hpp new file mode 100644 index 00000000..3d76d4a3 --- /dev/null +++ b/include/boost/fusion/adapted/class/detail/key_of_impl.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_KEY_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_KEY_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct key_of_impl; + + template <> + struct key_of_impl + : key_of_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/adapted/class/detail/size_impl.hpp b/include/boost/fusion/adapted/class/detail/size_impl.hpp index de34a3b1..a214bb98 100644 --- a/include/boost/fusion/adapted/class/detail/size_impl.hpp +++ b/include/boost/fusion/adapted/class/detail/size_impl.hpp @@ -1,37 +1,29 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_SIZE_IMPL_OCTOBER_4_2009_919PM) -#define BOOST_FUSION_SIZE_IMPL_OCTOBER_4_2009_919PM -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_SIZE_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_SIZE_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - namespace extension - { - template - struct class_size; - } + template + struct size_impl; - struct class_tag; + template <> + struct size_impl + : size_impl + {}; - namespace extension - { - template - struct size_impl; - - template <> - struct size_impl - { - template - struct apply : extension::class_size {}; - }; - } -}} + template <> + struct size_impl + : size_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/class/detail/value_at_impl.hpp b/include/boost/fusion/adapted/class/detail/value_at_impl.hpp index 64d2fc3a..0fd81f10 100644 --- a/include/boost/fusion/adapted/class/detail/value_at_impl.hpp +++ b/include/boost/fusion/adapted/class/detail/value_at_impl.hpp @@ -1,47 +1,29 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_VALUE_AT_IMPL_OCTOBER_4_2009_918PM) -#define BOOST_FUSION_VALUE_AT_IMPL_OCTOBER_4_2009_918PM -#include -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_VALUE_AT_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_VALUE_AT_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct class_tag; + template + struct value_at_impl; - namespace extension - { - template - struct value_at_impl; + template <> + struct value_at_impl + : value_at_impl + {}; - template - struct class_member; - - template - struct class_size; - - template <> - struct value_at_impl - { - template - struct apply - { - static int const n_value = N::value; - BOOST_MPL_ASSERT_RELATION( - n_value, <=, extension::class_size::value); - - typedef typename - extension::class_member::type - type; - }; - }; - } -}} + template <> + struct value_at_impl + : value_at_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/class/detail/value_at_key_impl.hpp b/include/boost/fusion/adapted/class/detail/value_at_key_impl.hpp deleted file mode 100644 index f9adc104..00000000 --- a/include/boost/fusion/adapted/class/detail/value_at_key_impl.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2007 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_VALUE_AT_KEY_IMPL_OCTOBER_4_2009_918PM) -#define BOOST_FUSION_VALUE_AT_KEY_IMPL_OCTOBER_4_2009_918PM - -#include - -namespace boost { namespace fusion -{ - struct class_tag; - - namespace extension - { - template - struct value_at_key_impl; - - template - struct class_assoc_member; - - template <> - struct value_at_key_impl - { - template - struct apply - { - typedef typename - extension::class_assoc_member::type - type; - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/class/detail/value_of_data_impl.hpp b/include/boost/fusion/adapted/class/detail/value_of_data_impl.hpp new file mode 100644 index 00000000..624200a6 --- /dev/null +++ b/include/boost/fusion/adapted/class/detail/value_of_data_impl.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_VALUE_OF_DATA_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_VALUE_OF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_data_impl; + + template <> + struct value_of_data_impl + : value_of_data_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/adapted/class/detail/value_of_impl.hpp b/include/boost/fusion/adapted/class/detail/value_of_impl.hpp new file mode 100644 index 00000000..49e5bf1c --- /dev/null +++ b/include/boost/fusion/adapted/class/detail/value_of_impl.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_CLASS_VALUE_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_CLASS_VALUE_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_impl; + + template <> + struct value_of_impl + : value_of_impl + {}; + + template <> + struct value_of_impl + : value_of_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/adapted/class/extension.hpp b/include/boost/fusion/adapted/class/extension.hpp deleted file mode 100644 index 71fdc94c..00000000 --- a/include/boost/fusion/adapted/class/extension.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(FUSION_CLASS_EXTENSION_OCTOBER_4_2009_839PM) -#define FUSION_CLASS_EXTENSION_OCTOBER_4_2009_839PM - -#include - -namespace boost { namespace fusion -{ - struct fusion_sequence_tag; - - namespace extension - { - template - struct class_member; - - template - struct class_size; - - template - struct class_member : class_member {}; - - template - struct class_size - : class_size - {}; - - struct no_such_member; - - template - struct class_assoc_member - { - typedef no_such_member type; - }; - - template - struct class_assoc_member - { - typedef typename - add_const::type>::type - type; - - static type& - call(Class const& class_) - { - return class_assoc_member::call( - const_cast(class_)); - } - }; - - } -}} - -#endif - - diff --git a/include/boost/fusion/adapted/std_pair.hpp b/include/boost/fusion/adapted/std_pair.hpp index 0c87084c..5792dd44 100644 --- a/include/boost/fusion/adapted/std_pair.hpp +++ b/include/boost/fusion/adapted/std_pair.hpp @@ -1,89 +1,24 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2009-2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_STD_PAIR_24122005_1744) -#define BOOST_FUSION_STD_PAIR_24122005_1744 -#include -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_STD_PAIR_HPP +#define BOOST_FUSION_ADAPTED_STD_PAIR_HPP -namespace boost { namespace fusion +#include + +namespace std { - struct struct_tag; - struct fusion_sequence_tag; + template + struct pair; +} - namespace traits - { - template -#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) - struct tag_of, void > -#else - struct tag_of > -#endif - { - typedef struct_tag type; - }; - } -}} - -namespace boost { namespace mpl -{ - template - struct sequence_tag; - - template - struct sequence_tag > - { - typedef fusion::fusion_sequence_tag type; - }; - - template - struct sequence_tag const> - { - typedef fusion::fusion_sequence_tag type; - }; -}} - -namespace boost { namespace fusion { namespace extension -{ - template - struct struct_member; - - template - struct struct_size; - - template - struct struct_member, 0> - { - typedef T1 type; - - static type& call(std::pair& pair) - { - return pair.first; - } - }; - - template - struct struct_member, 1> - { - typedef T2 type; - - static type& call(std::pair& pair) - { - return pair.second; - } - }; - - template - struct struct_size > : mpl::int_<2> - { - }; -}}} +BOOST_FUSION_ADAPT_TPL_STRUCT( + (T1)(T2),(std::pair)(T1)(T2),(T1, first)(T2, second)) #endif diff --git a/include/boost/fusion/adapted/std_pair/detail/at_impl.hpp b/include/boost/fusion/adapted/std_pair/detail/at_impl.hpp deleted file mode 100644 index 2f26fa68..00000000 --- a/include/boost/fusion/adapted/std_pair/detail/at_impl.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_AT_IMPL_24122005_1807) -#define BOOST_FUSION_AT_IMPL_24122005_1807 - -#include -#include -#include -#include - -namespace boost { namespace fusion { - - struct std_pair_tag; - - namespace extension - { - template - struct at_impl; - - template <> - struct at_impl - { - template - struct apply - { - static int const n_value = N::value; - BOOST_STATIC_ASSERT((n_value >= 0 && n_value < 2)); - typedef typename - mpl::if_c< - (n_value == 0) - , typename Sequence::first_type - , typename Sequence::second_type - > - element; - - typedef typename - mpl::eval_if< - is_const - , detail::cref_result - , detail::ref_result - >::type - type; - - template - static RT get(Sequence& p, mpl::int_<0>) - { - return p.first; - } - - template - static RT get(Sequence& p, mpl::int_<1>) - { - return p.second; - } - - static type - call(Sequence& p) - { - return get(p, N()); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/std_pair/detail/begin_impl.hpp b/include/boost/fusion/adapted/std_pair/detail/begin_impl.hpp deleted file mode 100644 index 1fd48f51..00000000 --- a/include/boost/fusion/adapted/std_pair/detail/begin_impl.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_BEGIN_IMPL_24122005_1752) -#define BOOST_FUSION_BEGIN_IMPL_24122005_1752 - -#include - -namespace boost { namespace fusion { - - struct std_pair_tag; - - namespace extension - { - template - struct begin_impl; - - template <> - struct begin_impl - { - template - struct apply - { - typedef std_pair_iterator type; - - static type - call(Sequence& v) - { - return type(v); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/std_pair/detail/category_of_impl.hpp b/include/boost/fusion/adapted/std_pair/detail/category_of_impl.hpp deleted file mode 100644 index 68df41dc..00000000 --- a/include/boost/fusion/adapted/std_pair/detail/category_of_impl.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_CATEGORY_OF_IMPL_24122005_1731) -#define BOOST_FUSION_CATEGORY_OF_IMPL_24122005_1731 - -#include - -namespace boost { namespace fusion { - - struct std_pair_tag; - struct random_access_traversal_tag; - - namespace extension - { - template - struct category_of_impl; - - template<> - struct category_of_impl - { - template - struct apply - { - typedef random_access_traversal_tag type; - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/std_pair/detail/end_impl.hpp b/include/boost/fusion/adapted/std_pair/detail/end_impl.hpp deleted file mode 100644 index 747f2c6f..00000000 --- a/include/boost/fusion/adapted/std_pair/detail/end_impl.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_END_IMPL_24122005_1755) -#define BOOST_FUSION_END_IMPL_24122005_1755 - -#include - -namespace boost { namespace fusion { - - struct std_pair_tag; - - namespace extension - { - template - struct end_impl; - - template <> - struct end_impl - { - template - struct apply - { - typedef std_pair_iterator type; - - static type - call(Sequence& v) - { - return type(v); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/std_pair/detail/is_sequence_impl.hpp b/include/boost/fusion/adapted/std_pair/detail/is_sequence_impl.hpp deleted file mode 100644 index 1c669a68..00000000 --- a/include/boost/fusion/adapted/std_pair/detail/is_sequence_impl.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_IS_SEQUENCE_IMPL_27122005_1651) -#define BOOST_FUSION_IS_SEQUENCE_IMPL_27122005_1651 - -#include - -namespace boost { namespace fusion { - - struct std_pair_tag; - - namespace extension - { - template - struct is_sequence_impl; - - template<> - struct is_sequence_impl - { - template - struct apply : mpl::true_ {}; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/std_pair/detail/is_view_impl.hpp b/include/boost/fusion/adapted/std_pair/detail/is_view_impl.hpp deleted file mode 100644 index 94842bc0..00000000 --- a/include/boost/fusion/adapted/std_pair/detail/is_view_impl.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_IS_VIEW_IMPL_27042006_2219) -#define BOOST_FUSION_IS_VIEW_IMPL_27042006_2219 - -#include - -namespace boost { namespace fusion -{ - struct std_pair_tag; - - namespace extension - { - template - struct is_view_impl; - - template<> - struct is_view_impl - { - template - struct apply : mpl::false_ - {}; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/std_pair/detail/size_impl.hpp b/include/boost/fusion/adapted/std_pair/detail/size_impl.hpp deleted file mode 100644 index 5f35bffd..00000000 --- a/include/boost/fusion/adapted/std_pair/detail/size_impl.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_SIZE_IMPL_24122005_1759) -#define BOOST_FUSION_SIZE_IMPL_24122005_1759 - -#include - -namespace boost { namespace fusion { - - struct std_pair_tag; - - namespace extension - { - template - struct size_impl; - - template <> - struct size_impl - { - template - struct apply : mpl::int_<2> {}; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/std_pair/detail/value_at_impl.hpp b/include/boost/fusion/adapted/std_pair/detail/value_at_impl.hpp deleted file mode 100644 index 16047ec9..00000000 --- a/include/boost/fusion/adapted/std_pair/detail/value_at_impl.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_VALUE_AT_IMPL_24122005_1917) -#define BOOST_FUSION_VALUE_AT_IMPL_24122005_1917 - -#include -#include - -namespace boost { namespace fusion { - - struct std_pair_tag; - - namespace extension - { - template - struct value_at_impl; - - template <> - struct value_at_impl - { - template - struct apply - { - static int const n_value = N::value; - BOOST_STATIC_ASSERT((n_value >= 0 && n_value < 2)); - typedef typename - mpl::if_c< - (n_value == 0) - , typename Sequence::first_type - , typename Sequence::second_type - >::type - type; - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/std_pair/std_pair_iterator.hpp b/include/boost/fusion/adapted/std_pair/std_pair_iterator.hpp deleted file mode 100644 index 9469723b..00000000 --- a/include/boost/fusion/adapted/std_pair/std_pair_iterator.hpp +++ /dev/null @@ -1,127 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(FUSION_STD_PAIR_ITERATOR_09262005_0934) -#define FUSION_STD_PAIR_ITERATOR_09262005_0934 - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace fusion -{ - struct random_access_traversal_tag; - - template - struct std_pair_iterator - : iterator_facade, random_access_traversal_tag> - { - BOOST_MPL_ASSERT_RELATION(N_, >=, 0); - BOOST_MPL_ASSERT_RELATION(N_, <=, 2); - - typedef mpl::int_ index; - typedef Pair_ pair_type; - - std_pair_iterator(Pair_& pair) - : pair(pair) {} - Pair_& pair; - - template - struct value_of; - - template - struct value_of > - : mpl::identity {}; - - template - struct value_of > - : mpl::identity {}; - - template - struct deref; - - template - struct deref > - { - typedef typename - mpl::if_< - is_const - , typename Pair::first_type const& - , typename Pair::first_type& - >::type - type; - - static type - call(std_pair_iterator const& iter) - { - return iter.pair.first; - } - }; - - template - struct deref > - { - typedef typename - mpl::if_< - is_const - , typename Pair::second_type const& - , typename Pair::second_type& - >::type - type; - - static type - call(std_pair_iterator const& iter) - { - return iter.pair.second; - } - }; - - template - struct advance - { - typedef typename Iterator::index index; - typedef typename Iterator::pair_type pair_type; - typedef std_pair_iterator type; - - static type - call(Iterator const& iter) - { - return type(iter.pair); - } - }; - - template - struct next : advance > {}; - - template - struct prior : advance > {}; - - template - struct distance : mpl::minus - { - typedef typename - mpl::minus< - typename I2::index, typename I1::index - >::type - type; - - static type - call(I1 const&, I2 const&) - { - return type(); - } - }; - }; -}} - -#endif - - diff --git a/include/boost/fusion/adapted/std_pair/tag_of.hpp b/include/boost/fusion/adapted/std_pair/tag_of.hpp deleted file mode 100644 index 2d4faaa5..00000000 --- a/include/boost/fusion/adapted/std_pair/tag_of.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_TAG_OF_24122005_1722) -#define BOOST_FUSION_TAG_OF_24122005_1722 - -#include - -#include - -namespace boost { namespace fusion { - - struct std_pair_tag; - struct fusion_sequence_tag; - - namespace traits - { - template - struct tag_of > - { - typedef std_pair_tag type; - }; - } -}} - -namespace boost { namespace mpl -{ - template - struct sequence_tag; - - template - struct sequence_tag > - { - typedef fusion::fusion_sequence_tag type; - }; - - template - struct sequence_tag const> - { - typedef fusion::fusion_sequence_tag type; - }; -}} - -#endif diff --git a/include/boost/fusion/adapted/struct.hpp b/include/boost/fusion/adapted/struct.hpp index 28a137ae..9c38bb48 100644 --- a/include/boost/fusion/adapted/struct.hpp +++ b/include/boost/fusion/adapted/struct.hpp @@ -1,29 +1,18 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2009-2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_STRUCT_24122005_1744) -#define BOOST_FUSION_STRUCT_24122005_1744 -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_STRUCT_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_HPP + +#include #include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #endif diff --git a/include/boost/fusion/adapted/struct/adapt_assoc_struct.hpp b/include/boost/fusion/adapted/struct/adapt_assoc_struct.hpp index 5061fe36..5708bfc3 100644 --- a/include/boost/fusion/adapted/struct/adapt_assoc_struct.hpp +++ b/include/boost/fusion/adapted/struct/adapt_assoc_struct.hpp @@ -1,113 +1,78 @@ /*============================================================================= Copyright (c) 2001-2007 Joel de Guzman Copyright (c) 2007 Dan Marsden + Copyright (c) 2009-2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_ADAPT_ASSOC_STRUCT_20070508_2207) -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_20070508_2207 -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_STRUCT_ADAPT_ASSOC_STRUCT_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_ASSOC_STRUCT_HPP + +#include +#include +#include + +#include +#include +#include #include #include +#include #include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(X, Y, Z)\ + ((X, Y, Z)) BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1 +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1(X, Y, Z)\ + ((X, Y, Z)) BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0 +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0_END +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1_END -namespace boost { namespace fusion { namespace extension { - template - struct struct_assoc_member; -}}} - - -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT(name, bseq) \ - BOOST_FUSION_ADAPT_ASSOC_STRUCT_I( \ - name, BOOST_PP_CAT(BOOST_FUSION_ADAPT_ASSOC_STRUCT_X bseq, 0)) \ - /***/ - -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_X(x, y, z) ((x, y, z)) BOOST_FUSION_ADAPT_ASSOC_STRUCT_Y -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_Y(x, y, z) ((x, y, z)) BOOST_FUSION_ADAPT_ASSOC_STRUCT_X -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_X0 -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_Y0 - -// BOOST_FUSION_ADAPT_ASSOC_STRUCT_I generates the overarching structure and uses -// SEQ_FOR_EACH_I to generate the "linear" substructures. -// Thanks to Paul Mensonides for the PP macro help - -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_I(name, seq) \ - namespace boost { namespace fusion { namespace traits \ - { \ - template <> \ - struct tag_of \ - { \ - typedef struct_tag type; \ - }; \ - }}} \ +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,PREFIX,ATTRIBUTE) \ \ - namespace boost { namespace mpl \ - { \ - template \ - struct sequence_tag; \ + BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, PREFIX, ATTRIBUTE, 3) \ \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - }} \ - \ - namespace boost { namespace fusion { namespace extension \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_assoc_key \ { \ - template <> \ - struct struct_size : mpl::int_ {}; \ - BOOST_PP_SEQ_FOR_EACH_I(BOOST_FUSION_ADAPT_ASSOC_STRUCT_C, name, seq) \ - }}} \ - /***/ - -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_C(r, name, i, xy) \ - template <> \ - struct struct_member \ - { \ - typedef BOOST_PP_TUPLE_ELEM(3, 0, xy) type; \ - static type& call(name& struct_) \ - { \ - return struct_.BOOST_PP_TUPLE_ELEM(3, 1, xy); \ - }; \ - }; \ - template<> \ - struct struct_assoc_member \ - { \ - typedef BOOST_PP_TUPLE_ELEM(3, 0, xy) type; \ - static type& call(name& struct_) \ - { \ - return struct_.BOOST_PP_TUPLE_ELEM(3, 1, xy); \ - }; \ + typedef BOOST_PP_TUPLE_ELEM(3, 2, ATTRIBUTE) type; \ }; - /***/ + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_C( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ, I, ATTRIBUTE) \ + \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,BOOST_PP_EMPTY(),ATTRIBUTE) + +#define BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (1)TEMPLATE_PARAMS_SEQ, \ + (1)NAME_SEQ, \ + assoc_struct_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_C) + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + assoc_struct_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_C) #endif diff --git a/include/boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp b/include/boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp new file mode 100644 index 00000000..7cefc517 --- /dev/null +++ b/include/boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_STRUCT_ADAPT_ASSOC_STRUCT_NAMED_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_ASSOC_STRUCT_NAMED_HPP + +#include +#include + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_C( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ, I, ATTRIBUTE) \ + \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ, I, obj., ATTRIBUTE) + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE( \ + WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \ + \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION( \ + (0)NAMESPACE_SEQ)NAME), \ + assoc_struct_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_C) + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS( \ + WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES) + +#endif diff --git a/include/boost/fusion/adapted/struct/adapt_struct.hpp b/include/boost/fusion/adapted/struct/adapt_struct.hpp index 88122aff..538b2f18 100644 --- a/include/boost/fusion/adapted/struct/adapt_struct.hpp +++ b/include/boost/fusion/adapted/struct/adapt_struct.hpp @@ -1,94 +1,55 @@ /*============================================================================= Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2009-2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_ADAPT_STRUCT_APRIL_2_2007_1158AM) -#define BOOST_FUSION_ADAPT_STRUCT_APRIL_2_2007_1158AM -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_HPP + +#include +#include + +#include +#include +#include #include #include +#include #include +#include #include #include -#include -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(X, Y) \ + ((X, Y)) BOOST_FUSION_ADAPT_STRUCT_FILLER_1 +#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(X, Y) \ + ((X, Y)) BOOST_FUSION_ADAPT_STRUCT_FILLER_0 +#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0_END +#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1_END -#define BOOST_FUSION_ADAPT_STRUCT(name, bseq) \ - BOOST_FUSION_ADAPT_STRUCT_I( \ - name, BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_X bseq, 0)) \ - /***/ +#define BOOST_FUSION_ADAPT_STRUCT_C(TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE)\ + BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,BOOST_PP_EMPTY(),ATTRIBUTE,2) -#define BOOST_FUSION_ADAPT_STRUCT_X(x, y) ((x, y)) BOOST_FUSION_ADAPT_STRUCT_Y -#define BOOST_FUSION_ADAPT_STRUCT_Y(x, y) ((x, y)) BOOST_FUSION_ADAPT_STRUCT_X -#define BOOST_FUSION_ADAPT_STRUCT_X0 -#define BOOST_FUSION_ADAPT_STRUCT_Y0 +#define BOOST_FUSION_ADAPT_TPL_STRUCT(TEMPLATE_PARAMS_SEQ,NAME_SEQ, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (1)TEMPLATE_PARAMS_SEQ, \ + (1)NAME_SEQ, \ + struct_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_STRUCT_C) -// BOOST_FUSION_ADAPT_STRUCT_I generates the overarching structure and uses -// SEQ_FOR_EACH_I to generate the "linear" substructures. -// Thanks to Paul Mensonides for the PP macro help - -#define BOOST_FUSION_ADAPT_STRUCT_I(name, seq) \ - namespace boost { namespace fusion { namespace traits \ - { \ - template <> \ - struct tag_of \ - { \ - typedef struct_tag type; \ - }; \ - }}} \ - \ - namespace boost { namespace mpl \ - { \ - template \ - struct sequence_tag; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - }} \ - \ - namespace boost { namespace fusion { namespace extension \ - { \ - template <> \ - struct struct_size : mpl::int_ {}; \ - BOOST_PP_SEQ_FOR_EACH_I(BOOST_FUSION_ADAPT_STRUCT_C, name, seq) \ - }}} \ - /***/ - -#define BOOST_FUSION_ADAPT_STRUCT_C(r, name, i, xy) \ - template <> \ - struct struct_member \ - { \ - typedef BOOST_PP_TUPLE_ELEM(2, 0, xy) type; \ - static type& call(name& struct_) \ - { \ - return struct_.BOOST_PP_TUPLE_ELEM(2, 1, xy); \ - }; \ - }; \ - /***/ +#define BOOST_FUSION_ADAPT_STRUCT(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + struct_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_STRUCT_C) #endif diff --git a/include/boost/fusion/adapted/struct/adapt_struct_named.hpp b/include/boost/fusion/adapted/struct/adapt_struct_named.hpp index b77b9150..1209a4f1 100644 --- a/include/boost/fusion/adapted/struct/adapt_struct_named.hpp +++ b/include/boost/fusion/adapted/struct/adapt_struct_named.hpp @@ -1,128 +1,39 @@ /*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2009-2010 Hartmut Kaiser + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_ADAPT_STRUCT_NAMED_SEP_29_2009_0748PM) -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_SEP_29_2009_0748PM -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_NAMED_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_NAMED_HPP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include -#define BOOST_FUSION_ADAPT_STRUCT_NAMED(name, newname, bseq) \ - BOOST_FUSION_ADAPT_STRUCT_NAMED_I(name, (boost)(fusion)(adapted), newname, \ - BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_NAMED_X bseq, 0)) \ - /***/ - -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(name, ns, newname, bseq) \ - BOOST_FUSION_ADAPT_STRUCT_NAMED_I(name, ns, newname, \ - BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_NAMED_X bseq, 0)) \ - /***/ - -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_X(x, y) ((x, y)) BOOST_FUSION_ADAPT_STRUCT_NAMED_Y -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_Y(x, y) ((x, y)) BOOST_FUSION_ADAPT_STRUCT_NAMED_X -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_X0 -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_Y0 - -// BOOST_FUSION_ADAPT_STRUCT_NAMED_I generates the overarching structure and uses -// uses SEQ_FOR_EACH_I to generate the "linear" substructures. -// Thanks to Paul Mensonides for the PP macro help - -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_I(name, ns, newname, seq) \ - BOOST_PP_SEQ_FOR_EACH_R(1, BOOST_FUSION_ADAPT_STRUCT_NAMED_NS_B, _, ns) \ - struct newname \ - { \ - newname(name& s) : s_(s) {} \ - name& s_; \ - }; \ - BOOST_PP_SEQ_FOR_EACH_R(1, BOOST_FUSION_ADAPT_STRUCT_NAMED_NS_E, _, ns) \ +#define BOOST_FUSION_ADAPT_STRUCT_NAMED_C( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE) \ \ - namespace boost { namespace fusion { namespace traits \ - { \ - template <> \ - struct tag_of \ - { \ - typedef struct_tag type; \ - }; \ - }}} \ - \ - namespace boost { namespace mpl \ - { \ - template \ - struct sequence_tag; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - \ - template<> \ - struct sequence_tag \ - { \ - typedef fusion::fusion_sequence_tag type; \ - }; \ - }} \ - \ - namespace boost { namespace fusion { namespace extension \ - { \ - template <> \ - struct struct_size \ - : mpl::int_ {}; \ - template struct class_member_proxy; \ - BOOST_PP_SEQ_FOR_EACH_I(BOOST_FUSION_ADAPT_STRUCT_NAMED_C, \ - (BOOST_FUSION_ADAPT_STRUCT_NAMED_NAME(ns, newname), name), seq) \ - }}} \ - /***/ + BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ, I, obj., ATTRIBUTE, 2) -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_NAME(ns, newname) \ - BOOST_PP_SEQ_FOR_EACH_R(1, BOOST_FUSION_ADAPT_STRUCT_NAMED_NS_D, _, ns) \ - newname \ - /***/ +#define BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE( \ + WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \ + \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION( \ + (0)NAMESPACE_SEQ)NAME), \ + struct_tag, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_STRUCT_NAMED_C) -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_NS_B(r, _, ns) namespace ns { -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_NS_D(r, _, ns) ns:: -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_NS_E(r, _, ns) } - -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_C(r, names, i, xy) \ - template <> \ - struct struct_member \ - { \ - typedef boost::mpl::if_< \ - boost::is_const \ - , boost::add_const::type \ - , BOOST_PP_TUPLE_ELEM(2, 0, xy)>::type type; \ - static type& call(BOOST_PP_TUPLE_ELEM(2, 0, names)& struct_) \ - { \ - return struct_.s_.BOOST_PP_TUPLE_ELEM(2, 1, xy); \ - } \ - }; \ - /***/ +#define BOOST_FUSION_ADAPT_STRUCT_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( \ + WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES) #endif - diff --git a/include/boost/fusion/adapted/struct/detail/adapt_base.hpp b/include/boost/fusion/adapted/struct/detail/adapt_base.hpp new file mode 100644 index 00000000..70a3cd8e --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/adapt_base.hpp @@ -0,0 +1,169 @@ +/*============================================================================= + Copyright (c) 2009-2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_ADAPT_BASE_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_ADAPT_BASE_HPP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME_TEMPLATE_PARAMS(SEQ) \ + BOOST_PP_SEQ_HEAD(SEQ) +#define BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(SEQ) \ + BOOST_PP_IF( \ + BOOST_PP_SEQ_HEAD(SEQ), \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME_TEMPLATE_PARAMS, \ + BOOST_PP_SEQ_HEAD)(BOOST_PP_SEQ_TAIL(SEQ)) + +#define BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL_C(R, _, ELEM) \ + (typename ELEM) +#define BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL(SEQ) \ + BOOST_PP_SEQ_ENUM( \ + BOOST_PP_SEQ_FOR_EACH( \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL_C, \ + _, \ + BOOST_PP_SEQ_TAIL(SEQ))) +#define BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(SEQ) \ + BOOST_PP_IF( \ + BOOST_PP_SEQ_HEAD(SEQ), \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL, \ + BOOST_PP_TUPLE_EAT(1))(SEQ) + +#ifdef BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS +# define BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \ + MODIFIER, TEMPLATE_PARAMS_SEQ,NAME_SEQ,TAG) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct tag_of< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) MODIFIER \ + , void \ + > \ + { \ + typedef TAG type; \ + }; +#else +# define BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \ + MODIFIER, TEMPLATE_PARAMS_SEQ,NAME_SEQ,TAG) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct tag_of \ + { \ + typedef TAG type; \ + }; +#endif + +#define BOOST_FUSION_ADAPT_STRUCT_BASE_UNPACK_AND_CALL(R,DATA,I,ATTRIBUTE) \ + BOOST_PP_TUPLE_ELEM(3,0,DATA)( \ + BOOST_PP_TUPLE_ELEM(3,1,DATA), \ + BOOST_PP_TUPLE_ELEM(3,2,DATA), \ + I, \ + ATTRIBUTE) + +#define BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,PREFIX,ATTRIBUTE,ATTRIBUTE_TUPEL_SIZE) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_member \ + { \ + typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \ + \ + template \ + static typename add_reference::type \ + call(Seq& seq) \ + { \ + return seq.PREFIX \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE); \ + } \ + \ + template \ + static typename add_reference::type>::type \ + call(Seq const& seq) \ + { \ + return seq.PREFIX \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE); \ + } \ + }; + +#define BOOST_FUSION_ADAPT_STRUCT_BASE( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,TAG,ATTRIBUTES_SEQ,ATTRIBUTES_CALLBACK) \ + \ +namespace boost \ +{ \ + namespace fusion \ + { \ + namespace traits \ + { \ + BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \ + BOOST_PP_EMPTY(),TEMPLATE_PARAMS_SEQ,NAME_SEQ,TAG) \ + BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \ + const,TEMPLATE_PARAMS_SEQ,NAME_SEQ,TAG) \ + } \ + \ + namespace extension \ + { \ + BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_ADAPT_STRUCT_BASE_UNPACK_AND_CALL, \ + (ATTRIBUTES_CALLBACK,TEMPLATE_PARAMS_SEQ,NAME_SEQ), \ + ATTRIBUTES_SEQ) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_size \ + : mpl::int_ \ + {}; \ + } \ + } \ + \ + namespace mpl \ + { \ + template \ + struct sequence_tag; \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + > \ + struct sequence_tag \ + { \ + typedef fusion::fusion_sequence_tag type; \ + }; \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + > \ + struct sequence_tag< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const \ + > \ + { \ + typedef fusion::fusion_sequence_tag type; \ + }; \ + } \ +} + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/at_impl.hpp b/include/boost/fusion/adapted/struct/detail/at_impl.hpp index 809902ae..09db935f 100644 --- a/include/boost/fusion/adapted/struct/detail/at_impl.hpp +++ b/include/boost/fusion/adapted/struct/detail/at_impl.hpp @@ -1,63 +1,58 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2009-2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_AT_IMPL_24122005_1807) -#define BOOST_FUSION_AT_IMPL_24122005_1807 + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_AT_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_AT_IMPL_HPP #include -#include -#include +#include +#include +#include -namespace boost { namespace fusion +namespace boost { namespace fusion { namespace extension { - struct struct_tag; + template + struct at_impl; - namespace extension + template <> + struct at_impl { - template - struct at_impl; - - template - struct struct_member; - - template - struct struct_size; - - template <> - struct at_impl + template + struct apply { - template - struct apply + typedef + extension::struct_member< + typename remove_const::type + , N::value + > + member; + + typedef typename + mpl::eval_if< + is_const + , detail::cref_result + , detail::ref_result + >::type + type; + + static type + call(Seq& seq) { - static int const n_value = N::value; - BOOST_MPL_ASSERT_RELATION( - n_value, <=, extension::struct_size::value); - - typedef typename - extension::struct_member - element; - - typedef typename - mpl::eval_if< - is_const - , detail::cref_result - , detail::ref_result - >::type - type; - - static type - call(Sequence& seq) - { - return extension:: - struct_member::call(seq); - } - }; + return member::call(seq); + } }; - } -}} + }; + + template <> + struct at_impl + : at_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/struct/detail/at_key_impl.hpp b/include/boost/fusion/adapted/struct/detail/at_key_impl.hpp deleted file mode 100644 index 4ce0fce9..00000000 --- a/include/boost/fusion/adapted/struct/detail/at_key_impl.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2005-2007 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_AT_KEY_IMPL_20070508_2248) -#define BOOST_FUSION_AT_KEY_IMPL_20070508_2248 - -#include - -namespace boost { namespace fusion -{ - struct struct_tag; - - namespace extension - { - template - struct at_key_impl; - - template - struct struct_assoc_member; - - template <> - struct at_key_impl - { - template - struct apply - { - typedef typename - extension::struct_assoc_member - element; - - typedef typename - mpl::eval_if< - is_const - , detail::cref_result - , detail::ref_result - >::type - type; - - static type - call(Sequence& seq) - { - return extension:: - struct_assoc_member::call(seq); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/struct/detail/begin_impl.hpp b/include/boost/fusion/adapted/struct/detail/begin_impl.hpp index bf5a00bc..583d81b6 100644 --- a/include/boost/fusion/adapted/struct/detail/begin_impl.hpp +++ b/include/boost/fusion/adapted/struct/detail/begin_impl.hpp @@ -1,40 +1,67 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2009-2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_BEGIN_IMPL_24122005_1752) -#define BOOST_FUSION_BEGIN_IMPL_24122005_1752 -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_BEGIN_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_BEGIN_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct struct_tag; + template + struct begin_impl; - namespace extension + template <> + struct begin_impl { - template - struct begin_impl; - - template <> - struct begin_impl + template + struct apply { - template - struct apply - { - typedef struct_iterator type; + typedef + basic_iterator< + struct_iterator_tag + , random_access_traversal_tag + , Seq + , 0 + > + type; - static type - call(Sequence& v) - { - return type(v); - } - }; + static type + call(Seq& seq) + { + return type(seq,0); + } }; - } -}} + }; + + template <> + struct begin_impl + { + template + struct apply + { + typedef + basic_iterator< + assoc_struct_iterator_tag + , assoc_struct_category + , Seq + , 0 + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; +}}} #endif diff --git a/include/boost/fusion/adapted/struct/detail/category_of_impl.hpp b/include/boost/fusion/adapted/struct/detail/category_of_impl.hpp index c23b9751..b7b1a14c 100644 --- a/include/boost/fusion/adapted/struct/detail/category_of_impl.hpp +++ b/include/boost/fusion/adapted/struct/detail/category_of_impl.hpp @@ -1,34 +1,41 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2009-2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_CATEGORY_OF_IMPL_24122005_1731) -#define BOOST_FUSION_CATEGORY_OF_IMPL_24122005_1731 -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_CATEGORY_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_CATEGORY_OF_IMPL_HPP namespace boost { namespace fusion { - struct struct_tag; - struct random_access_traversal_tag; - namespace extension { - template + template struct category_of_impl; template<> struct category_of_impl { - template + template struct apply { typedef random_access_traversal_tag type; }; }; + + template<> + struct category_of_impl + { + template + struct apply + { + typedef assoc_struct_category type; + }; + }; } }} diff --git a/include/boost/fusion/adapted/struct/detail/deref_data_impl.hpp b/include/boost/fusion/adapted/struct/detail/deref_data_impl.hpp new file mode 100644 index 00000000..ce4a79de --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/deref_data_impl.hpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 2009-2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEREF_DATA_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEREF_DATA_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_data_impl; + + template <> + struct deref_data_impl + : deref_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/deref_impl.hpp b/include/boost/fusion/adapted/struct/detail/deref_impl.hpp new file mode 100644 index 00000000..a54abbfc --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/deref_impl.hpp @@ -0,0 +1,56 @@ +/*============================================================================= + Copyright (c) 2009-2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEREF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEREF_IMPL_HPP + +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_impl; + + template <> + struct deref_impl + { + template + struct apply + { + typedef + extension::struct_member< + typename remove_const::type + , It::index::value + > + member; + + typedef typename + mpl::eval_if< + is_const + , detail::cref_result + , detail::ref_result + >::type + type; + + static type + call(It const& it) + { + return member::call(*it.seq); + } + }; + }; + + template <> + struct deref_impl + : deref_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/end_impl.hpp b/include/boost/fusion/adapted/struct/detail/end_impl.hpp index 514f7f58..738ffdd0 100644 --- a/include/boost/fusion/adapted/struct/detail/end_impl.hpp +++ b/include/boost/fusion/adapted/struct/detail/end_impl.hpp @@ -1,48 +1,68 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2009-2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_END_IMPL_24122005_1755) -#define BOOST_FUSION_END_IMPL_24122005_1755 -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_END_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_END_IMPL_HPP -namespace boost { namespace fusion +#include +#include + +namespace boost { namespace fusion { namespace extension { - struct struct_tag; + template + struct end_impl; - namespace extension + template <> + struct end_impl { - template - struct end_impl; - - template - struct struct_size; - - template <> - struct end_impl + template + struct apply { - template - struct apply - { - typedef - struct_iterator< - Sequence - , struct_size::value - > - type; + typedef + basic_iterator< + struct_iterator_tag + , random_access_traversal_tag + , Seq + , struct_size::type>::value + > + type; - static type - call(Sequence& v) - { - return type(v); - } - }; + static type + call(Seq& seq) + { + return type(seq,0); + } }; - } -}} + }; + + template <> + struct end_impl + { + template + struct apply + { + typedef + basic_iterator< + assoc_struct_iterator_tag + , assoc_struct_category + , Seq + , struct_size::type>::value + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; +}}} #endif diff --git a/include/boost/fusion/adapted/struct/detail/extension.hpp b/include/boost/fusion/adapted/struct/detail/extension.hpp new file mode 100644 index 00000000..892155eb --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/extension.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2009-2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_EXTENSION_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_EXTENSION_HPP + +#include + +namespace boost { namespace fusion +{ + struct struct_tag; + struct struct_iterator_tag; + struct assoc_struct_tag; + struct assoc_struct_iterator_tag; + struct fusion_sequence_tag; + + struct assoc_struct_category + : bidirectional_traversal_tag, associative_tag + {}; + + namespace extension + { + struct no_such_member; + + template + struct struct_member; + + template + struct struct_assoc_key; + + template + struct struct_size; + } +}} + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/has_key_impl.hpp b/include/boost/fusion/adapted/struct/detail/has_key_impl.hpp deleted file mode 100644 index 8972f5df..00000000 --- a/include/boost/fusion/adapted/struct/detail/has_key_impl.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2005-2007 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_HAS_KEY_IMPL_20070508_2231) -#define BOOST_FUSION_HAS_KEY_IMPL_20070508_2231 - -#include -#include - -namespace boost { namespace fusion { - - struct struct_tag; - - namespace extension - { - struct no_such_member; - - template - struct has_key_impl; - - template - struct struct_assoc_member; - - template<> - struct has_key_impl - { - template - struct apply - : mpl::not_::type> > - { - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/struct/detail/is_sequence_impl.hpp b/include/boost/fusion/adapted/struct/detail/is_sequence_impl.hpp index f81e9fb6..e71bb0e2 100644 --- a/include/boost/fusion/adapted/struct/detail/is_sequence_impl.hpp +++ b/include/boost/fusion/adapted/struct/detail/is_sequence_impl.hpp @@ -5,27 +5,30 @@ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_IS_SEQUENCE_IMPL_27122005_1651) -#define BOOST_FUSION_IS_SEQUENCE_IMPL_27122005_1651 + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_IS_SEQUENCE_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_IS_SEQUENCE_IMPL_HPP #include -namespace boost { namespace fusion +namespace boost { namespace fusion { namespace extension { - struct struct_tag; + template + struct is_sequence_impl; - namespace extension + template<> + struct is_sequence_impl { - template - struct is_sequence_impl; + template + struct apply + : mpl::true_ + {}; + }; - template<> - struct is_sequence_impl - { - template - struct apply : mpl::true_ {}; - }; - } -}} + template <> + struct is_sequence_impl + : is_sequence_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/struct/detail/is_view_impl.hpp b/include/boost/fusion/adapted/struct/detail/is_view_impl.hpp index da6f380b..61ca61fa 100644 --- a/include/boost/fusion/adapted/struct/detail/is_view_impl.hpp +++ b/include/boost/fusion/adapted/struct/detail/is_view_impl.hpp @@ -5,28 +5,30 @@ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_IS_VIEW_IMPL_27042006_2219) -#define BOOST_FUSION_IS_VIEW_IMPL_27042006_2219 + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_IS_VIEW_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_IS_VIEW_IMPL_HPP #include -namespace boost { namespace fusion +namespace boost { namespace fusion { namespace extension { - struct struct_tag; + template + struct is_view_impl; - namespace extension + template<> + struct is_view_impl { - template - struct is_view_impl; + template + struct apply + : mpl::false_ + {}; + }; - template<> - struct is_view_impl - { - template - struct apply : mpl::false_ - {}; - }; - } -}} + template <> + struct is_view_impl + : is_view_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/struct/detail/key_of_impl.hpp b/include/boost/fusion/adapted/struct/detail/key_of_impl.hpp new file mode 100644 index 00000000..28e6bbf0 --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/key_of_impl.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2009-2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_KEY_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_KEY_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct key_of_impl; + + template <> + struct key_of_impl + { + template + struct apply + { + typedef typename + extension::struct_assoc_key< + typename remove_const::type + , It::index::value + >::type + type; + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/proxy_type.hpp b/include/boost/fusion/adapted/struct/detail/proxy_type.hpp new file mode 100644 index 00000000..ed9a9625 --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/proxy_type.hpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_PROXY_TYPE_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_PROXY_TYPE_HPP + +#include +#include +#include +#include +#include +#include + +#define BOOST_FUSION_ADAPT_STRUCT_PROXY_DUMMY4(A,B,C,D) +#define BOOST_FUSION_ADAPT_STRUCT_PROXY_TYPE_NS_BEGIN(R,DATA,ELEM) \ + namespace ELEM { +#define BOOST_FUSION_ADAPT_STRUCT_PROXY_TYPE_NS_END(Z,I,DATA) } +#define BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION_I(Z,I,ELEM) ELEM:: + +#define BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE( \ + WRAPPED_TYPE,NAMESPACE_SEQ,NAME) \ + \ + BOOST_PP_IF( \ + BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(NAMESPACE_SEQ)), \ + BOOST_PP_SEQ_FOR_EACH_R, \ + BOOST_FUSION_ADAPT_STRUCT_PROXY_DUMMY4)( \ + 1, \ + BOOST_FUSION_ADAPT_STRUCT_PROXY_TYPE_NS_BEGIN, \ + _, \ + BOOST_PP_SEQ_TAIL(NAMESPACE_SEQ)) \ + \ + struct NAME \ + { \ + NAME(WRAPPED_TYPE& obj) \ + : obj(obj) \ + {} \ + \ + WRAPPED_TYPE& obj; \ + }; \ + \ + BOOST_PP_REPEAT_1( \ + BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(NAMESPACE_SEQ)), \ + BOOST_FUSION_ADAPT_STRUCT_PROXY_TYPE_NS_END, \ + _) + +#define BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION(NAMESPACE_SEQ) \ + BOOST_PP_IF( \ + BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(NAMESPACE_SEQ)), \ + BOOST_PP_SEQ_FOR_EACH_R, \ + BOOST_FUSION_ADAPT_STRUCT_PROXY_DUMMY4)( \ + 1, \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION_I, \ + _, \ + BOOST_PP_SEQ_TAIL(NAMESPACE_SEQ)) + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/size_impl.hpp b/include/boost/fusion/adapted/struct/detail/size_impl.hpp index 12ec14ba..b7b1ace8 100644 --- a/include/boost/fusion/adapted/struct/detail/size_impl.hpp +++ b/include/boost/fusion/adapted/struct/detail/size_impl.hpp @@ -5,33 +5,30 @@ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_SIZE_IMPL_24122005_1759) -#define BOOST_FUSION_SIZE_IMPL_24122005_1759 -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_SIZE_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_SIZE_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - namespace extension + template + struct size_impl; + + template <> + struct size_impl { - template - struct struct_size; - } + template + struct apply + : struct_size::type> + {}; + }; - struct struct_tag; - - namespace extension - { - template - struct size_impl; - - template <> - struct size_impl - { - template - struct apply : extension::struct_size {}; - }; - } -}} + template <> + struct size_impl + : size_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/struct/detail/value_at_impl.hpp b/include/boost/fusion/adapted/struct/detail/value_at_impl.hpp index 8f5d97a0..6f139219 100644 --- a/include/boost/fusion/adapted/struct/detail/value_at_impl.hpp +++ b/include/boost/fusion/adapted/struct/detail/value_at_impl.hpp @@ -5,43 +5,30 @@ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(BOOST_FUSION_VALUE_AT_IMPL_24122005_1917) -#define BOOST_FUSION_VALUE_AT_IMPL_24122005_1917 -#include -#include +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_AT_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_AT_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct struct_tag; + template + struct value_at_impl; - namespace extension + template <> + struct value_at_impl { - template - struct value_at_impl; + template + struct apply + : struct_member::type, N::value> + {}; + }; - template - struct struct_member; - - template - struct struct_size; - - template <> - struct value_at_impl - { - template - struct apply - { - static int const n_value = N::value; - BOOST_MPL_ASSERT_RELATION( - n_value, <=, extension::struct_size::value); - - typedef typename - extension::struct_member::type - type; - }; - }; - } -}} + template <> + struct value_at_impl + : value_at_impl + {}; +}}} #endif diff --git a/include/boost/fusion/adapted/struct/detail/value_at_key_impl.hpp b/include/boost/fusion/adapted/struct/detail/value_at_key_impl.hpp deleted file mode 100644 index b1b3dcfb..00000000 --- a/include/boost/fusion/adapted/struct/detail/value_at_key_impl.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2005-2007 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_VALUE_AT_KEY_IMPL_20070508_2300) -#define BOOST_FUSION_VALUE_AT_KEY_IMPL_20070508_2300 - -#include - -namespace boost { namespace fusion -{ - struct struct_tag; - - namespace extension - { - template - struct value_at_key_impl; - - template - struct struct_assoc_member; - - template <> - struct value_at_key_impl - { - template - struct apply - { - typedef typename - extension::struct_assoc_member::type - type; - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/adapted/struct/detail/value_of_data_impl.hpp b/include/boost/fusion/adapted/struct/detail/value_of_data_impl.hpp new file mode 100644 index 00000000..682adbbf --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/value_of_data_impl.hpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 2009-2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_OF_DATA_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_OF_DATA_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_data_impl; + + template <> + struct value_of_data_impl + : value_of_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/value_of_impl.hpp b/include/boost/fusion/adapted/struct/detail/value_of_impl.hpp new file mode 100644 index 00000000..7d8bf571 --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/value_of_impl.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2009-2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_impl; + + template <> + struct value_of_impl + { + template + struct apply + { + typedef typename + extension::struct_member< + typename remove_const::type + , It::index::value + >::type + type; + }; + }; + + template <> + struct value_of_impl + : value_of_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/adapted/struct/extension.hpp b/include/boost/fusion/adapted/struct/extension.hpp deleted file mode 100644 index 6f5de9ea..00000000 --- a/include/boost/fusion/adapted/struct/extension.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(FUSION_STRUCT_EXTENSION_APRIL_2_2007_1008AM) -#define FUSION_STRUCT_EXTENSION_APRIL_2_2007_1008AM - -#include - -namespace boost { namespace fusion -{ - struct fusion_sequence_tag; - - namespace extension - { - template - struct struct_member; - - template - struct struct_size; - - template - struct struct_member - { - typedef typename - add_const::type>::type - type; - - static type& - call(Struct const& struct_) - { - return struct_member::call( - const_cast(struct_)); - } - }; - - template - struct struct_size - : struct_size - {}; - - struct no_such_member; - - template - struct struct_assoc_member - { - typedef no_such_member type; - }; - - template - struct struct_assoc_member - { - typedef typename - add_const::type>::type - type; - - static type& - call(Struct const& struct_) - { - return struct_assoc_member::call( - const_cast(struct_)); - } - }; - - } -}} - -#endif - - diff --git a/include/boost/fusion/adapted/struct/struct_iterator.hpp b/include/boost/fusion/adapted/struct/struct_iterator.hpp deleted file mode 100644 index fe26aa33..00000000 --- a/include/boost/fusion/adapted/struct/struct_iterator.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2005-2006 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(FUSION_STRUCT_ITERATOR_APRIL_2_2007_1008AM) -#define FUSION_STRUCT_ITERATOR_APRIL_2_2007_1008AM - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace fusion -{ - struct random_access_traversal_tag; - - template - struct struct_iterator - : iterator_facade, random_access_traversal_tag> - { - BOOST_MPL_ASSERT_RELATION(N_, >=, 0); - BOOST_MPL_ASSERT_RELATION(N_, <=, extension::struct_size::value); - - typedef mpl::int_ index; - typedef Struct struct_type; - - struct_iterator(Struct& struct_) - : struct_(struct_) {} - Struct& struct_; - - template - struct value_of - : extension::struct_member - { - }; - - template - struct deref - { - typedef typename - add_reference< - typename extension::struct_member::type - >::type - type; - - static type - call(Iterator const& iter) - { - return extension::struct_member:: - call(iter.struct_); - } - }; - - template - struct advance - { - typedef typename Iterator::index index; - typedef typename Iterator::struct_type struct_type; - typedef struct_iterator type; - - static type - call(Iterator const& iter) - { - return type(iter.struct_); - } - }; - - template - struct next : advance > {}; - - template - struct prior : advance > {}; - - template - struct distance : mpl::minus - { - typedef typename - mpl::minus< - typename I2::index, typename I1::index - >::type - type; - - static type - call(I1 const&, I2 const&) - { - return type(); - } - }; - - private: - // silence MSVC warning C4512: assignment operator could not be generated - struct_iterator& operator= (struct_iterator const&); - }; -}} - -#endif - - diff --git a/include/boost/fusion/include/adapt_assoc_class.hpp b/include/boost/fusion/include/adapt_assoc_class.hpp new file mode 100644 index 00000000..ccbfeb18 --- /dev/null +++ b/include/boost/fusion/include/adapt_assoc_class.hpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_INCLUDE_ADAPT_ASSOC_CLASS_HPP +#define BOOST_FUSION_INCLUDE_ADAPT_ASSOC_CLASS_HPP + +#include + +#endif diff --git a/include/boost/fusion/include/adapt_assoc_class_named.hpp b/include/boost/fusion/include/adapt_assoc_class_named.hpp new file mode 100644 index 00000000..10782681 --- /dev/null +++ b/include/boost/fusion/include/adapt_assoc_class_named.hpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_INCLUDE_ADAPT_ASSOC_CLASS_NAMED_HPP +#define BOOST_FUSION_INCLUDE_ADAPT_ASSOC_CLASS_NAMED_HPP + +#include + +#endif diff --git a/include/boost/fusion/include/adapt_assoc_struct.hpp b/include/boost/fusion/include/adapt_assoc_struct.hpp new file mode 100644 index 00000000..681aa2e4 --- /dev/null +++ b/include/boost/fusion/include/adapt_assoc_struct.hpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_INCLUDE_ADAPT_ASSOC_STRUCT_HPP +#define BOOST_FUSION_INCLUDE_ADAPT_ASSOC_STRUCT_HPP + +#include + +#endif diff --git a/include/boost/fusion/include/adapt_assoc_struct_named.hpp b/include/boost/fusion/include/adapt_assoc_struct_named.hpp new file mode 100644 index 00000000..19204f50 --- /dev/null +++ b/include/boost/fusion/include/adapt_assoc_struct_named.hpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_INCLUDE_ADAPT_ASSOC_STRUCT_NAMED_HPP +#define BOOST_FUSION_INCLUDE_ADAPT_ASSOC_STRUCT_NAMED_HPP + +#include + +#endif diff --git a/include/boost/fusion/include/adapt_class.hpp b/include/boost/fusion/include/adapt_class.hpp index 7c32768e..77f519be 100644 --- a/include/boost/fusion/include/adapt_class.hpp +++ b/include/boost/fusion/include/adapt_class.hpp @@ -1,11 +1,12 @@ /*============================================================================= - Copyright (c) 2001-2009 Joel de Guzman + Copyright (c) 2001-2007 Joel de Guzman Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(FUSION_INCLUDE_ADAPT_CLASS) -#define FUSION_INCLUDE_ADAPT_CLASS + +#ifndef BOOST_FUSION_INCLUDE_ADAPT_CLASS_HPP +#define BOOST_FUSION_INCLUDE_ADAPT_CLASS_HPP #include diff --git a/include/boost/fusion/include/adapt_class_named.hpp b/include/boost/fusion/include/adapt_class_named.hpp new file mode 100644 index 00000000..81136a1f --- /dev/null +++ b/include/boost/fusion/include/adapt_class_named.hpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_FUSION_INCLUDE_ADAPT_CLASS_NAMED_HPP +#define BOOST_FUSION_INCLUDE_ADAPT_CLASS_NAMED_HPP + +#include + +#endif diff --git a/include/boost/fusion/include/adapt_struct.hpp b/include/boost/fusion/include/adapt_struct.hpp index facc8970..c1271543 100644 --- a/include/boost/fusion/include/adapt_struct.hpp +++ b/include/boost/fusion/include/adapt_struct.hpp @@ -4,8 +4,9 @@ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(FUSION_INCLUDE_ADAPT_STRUCT) -#define FUSION_INCLUDE_ADAPT_STRUCT + +#ifndef BOOST_FUSION_INCLUDE_ADAPT_STRUCT_HPP +#define BOOST_FUSION_INCLUDE_ADAPT_STRUCT_HPP #include diff --git a/include/boost/fusion/include/adapt_struct_named.hpp b/include/boost/fusion/include/adapt_struct_named.hpp index 67b6235f..01cbf329 100644 --- a/include/boost/fusion/include/adapt_struct_named.hpp +++ b/include/boost/fusion/include/adapt_struct_named.hpp @@ -1,11 +1,12 @@ /*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2010 Christopher Schmidt Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !defined(FUSION_INCLUDE_ADAPT_STRUCT_NAMED) -#define FUSION_INCLUDE_ADAPT_STRUCT_NAMED + +#ifndef BOOST_FUSION_INCLUDE_ADAPT_STRUCT_NAMED_HPP +#define BOOST_FUSION_INCLUDE_ADAPT_STRUCT_NAMED_HPP #include diff --git a/include/boost/fusion/support/is_sequence.hpp b/include/boost/fusion/support/is_sequence.hpp index 9ad50ec1..d57cecb4 100644 --- a/include/boost/fusion/support/is_sequence.hpp +++ b/include/boost/fusion/support/is_sequence.hpp @@ -56,8 +56,9 @@ namespace boost { namespace fusion { template struct is_sequence - : extension::is_sequence_impl::type>:: - template apply + : extension::is_sequence_impl< + typename fusion::detail::tag_of::type + >::template apply {}; } }} diff --git a/test/Jamfile b/test/Jamfile index 8ed08c4e..440e53a2 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -108,12 +108,19 @@ import testing ; [ run sequence/zip_view_ignore.cpp : : : : ] [ run sequence/repetitive_view.cpp : : : : ] [ run sequence/deduce_sequence.cpp : : : : ] - [ run sequence/adapt_struct.cpp : : : : ] + [ run sequence/adapt_assoc_class_named.cpp : : : : ] + [ run sequence/adapt_assoc_class.cpp : : : : ] + [ run sequence/adapt_assoc_struct_named.cpp : : : : ] [ run sequence/adapt_assoc_struct.cpp : : : : ] - [ run sequence/adapt_struct_named.cpp : : : : ] - [ run sequence/adapt_class.cpp : : : : ] + [ run sequence/adapt_assoc_tpl_class.cpp : : : : ] + [ run sequence/adapt_assoc_tpl_struct.cpp : : : : ] [ run sequence/adapt_class_named.cpp : : : : ] - + [ run sequence/adapt_class.cpp : : : : ] + [ run sequence/adapt_struct_named.cpp : : : : ] + [ run sequence/adapt_struct.cpp : : : : ] + [ run sequence/adapt_tpl_class.cpp : : : : ] + [ run sequence/adapt_tpl_struct.cpp : : : : ] + [ run functional/fused.cpp : : : : ] [ run functional/fused_function_object.cpp : : : : ] [ run functional/fused_procedure.cpp : : : : ] diff --git a/test/sequence/adapt_assoc_class.cpp b/test/sequence/adapt_assoc_class.cpp new file mode 100644 index 00000000..cdbdd36b --- /dev/null +++ b/test/sequence/adapt_assoc_class.cpp @@ -0,0 +1,136 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ns +{ + struct x_member; + struct y_member; + struct z_member; + + class point + { + public: + + point() : x(0), y(0) {} + point(int x, int y) : x(x), y(y) {} + + int get_x() const { return x; } + int get_y() const { return y; } + void set_x(int x_) { x = x_; } + void set_y(int y_) { y = y_; } + + private: + + int x; + int y; + }; +} + +BOOST_FUSION_ADAPT_ASSOC_CLASS( + ns::point, + (int, int, obj.get_x(), obj.set_x(val), ns::x_member) + (int, int, obj.get_y(), obj.set_y(val), ns::y_member) +) + +int +main() +{ + using namespace boost::fusion; + using namespace std; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + ns::point p(123, 456); + + std::cout << at_c<0>(p) << std::endl; + std::cout << at_c<1>(p) << std::endl; + std::cout << p << std::endl; + BOOST_TEST(p == make_vector(123, 456)); + + at_c<0>(p) = 6; + at_c<1>(p) = 9; + BOOST_TEST(p == make_vector(6, 9)); + + BOOST_STATIC_ASSERT(result_of::size::value == 2); + BOOST_STATIC_ASSERT(!result_of::empty::value); + + BOOST_TEST(front(p) == 6); + BOOST_TEST(back(p) == 9); + } + + { + boost::fusion::vector v1(4, 2); + ns::point v2(5, 3); + boost::fusion::vector v3(5, 4); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { + // conversion from ns::point to vector + ns::point p(5, 3); + boost::fusion::vector v(p); + v = p; + } + + { + // conversion from ns::point to list + ns::point p(5, 3); + boost::fusion::list l(p); + l = p; + } + + { + BOOST_MPL_ASSERT((boost::mpl::is_sequence)); + BOOST_MPL_ASSERT((boost::is_same< + boost::fusion::result_of::value_at_c::type + , boost::mpl::front::type>)); + } + + { + // assoc stuff + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((boost::mpl::not_ >)); + + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + + ns::point p(5, 3); + + BOOST_TEST(at_key(p) == 5); + BOOST_TEST(at_key(p) == 3); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_class_named.cpp b/test/sequence/adapt_assoc_class_named.cpp new file mode 100644 index 00000000..8f6ec592 --- /dev/null +++ b/test/sequence/adapt_assoc_class_named.cpp @@ -0,0 +1,142 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ns +{ + struct x_member; + struct y_member; + struct z_member; + + class point + { + public: + + point() : x(0), y(0) {} + point(int x, int y) : x(x), y(y) {} + + int get_x() const { return x; } + int get_y() const { return y; } + void set_x(int x_) { x = x_; } + void set_y(int y_) { y = y_; } + + private: + + int x; + int y; + }; +} + +BOOST_FUSION_ADAPT_ASSOC_CLASS_NAMED( + ns::point, + point, + (int, int, obj.obj.get_x(), obj.obj.set_x(val), ns::x_member) + (int, int, obj.obj.get_y(), obj.obj.set_y(val), ns::y_member) +) + +int +main() +{ + using namespace boost::fusion; + using namespace std; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + ns::point basep(123, 456); + adapted::point p(basep); + + std::cout << at_c<0>(p) << std::endl; + std::cout << at_c<1>(p) << std::endl; + std::cout << p << std::endl; + BOOST_TEST(p == make_vector(123, 456)); + + at_c<0>(p) = 6; + at_c<1>(p) = 9; + BOOST_TEST(p == make_vector(6, 9)); + + BOOST_STATIC_ASSERT(result_of::size::value == 2); + BOOST_STATIC_ASSERT(!result_of::empty::value); + + BOOST_TEST(front(p) == 6); + BOOST_TEST(back(p) == 9); + } + + { + boost::fusion::vector v1(4, 2); + ns::point basev2(5, 3); + adapted::point v2(basev2); + boost::fusion::vector v3(5, 4); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { + // conversion from adapted::point to vector + ns::point basep(5, 3); + adapted::point p(basep); + boost::fusion::vector v(p); + v = p; + } + + { + // conversion from adated::point to list + ns::point basep(5, 3); + adapted::point p(basep); + boost::fusion::list l(p); + l = p; + } + + { + BOOST_MPL_ASSERT((boost::mpl::is_sequence)); + BOOST_MPL_ASSERT((boost::is_same< + boost::fusion::result_of::value_at_c::type + , boost::mpl::front::type>)); + } + + { + // assoc stuff + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((boost::mpl::not_ >)); + + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + + ns::point basep(5, 3); + adapted::point p(basep); + + BOOST_TEST(at_key(p) == 5); + BOOST_TEST(at_key(p) == 3); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_struct_named.cpp b/test/sequence/adapt_assoc_struct_named.cpp new file mode 100644 index 00000000..2cbf2f53 --- /dev/null +++ b/test/sequence/adapt_assoc_struct_named.cpp @@ -0,0 +1,121 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ns +{ + struct x_member; + struct y_member; + struct z_member; + + struct point + { + int x; + int y; + }; +} + +BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED( + ns::point, + point, + (int, x, ns::x_member) + (int, y, ns::y_member) +) + +int +main() +{ + using namespace boost::fusion; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + ns::point basep = {123, 456}; + adapted::point p(basep); + + std::cout << at_c<0>(p) << std::endl; + std::cout << at_c<1>(p) << std::endl; + std::cout << p << std::endl; + BOOST_TEST(p == make_vector(123, 456)); + + at_c<0>(p) = 6; + at_c<1>(p) = 9; + BOOST_TEST(p == make_vector(6, 9)); + + BOOST_STATIC_ASSERT(result_of::size::value == 2); + BOOST_STATIC_ASSERT(!result_of::empty::value); + + BOOST_TEST(front(p) == 6); + BOOST_TEST(back(p) == 9); + } + + { + vector v1(4, 2); + ns::point basev2 = {5, 3}; + adapted::point v2(basev2); + + vector v3(5, 4); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { + // conversion from adapted::point to vector + ns::point basep = {5, 3}; + adapted::point p(basep); + vector v(p); + v = p; + } + + { + // conversion from adapted::point to list + ns::point basep = {5, 3}; + adapted::point p(basep); + list l(p); + l = p; + } + + { + // assoc stuff + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((boost::mpl::not_ >)); + + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + + ns::point basep = {5, 3}; + adapted::point p(basep); + + BOOST_TEST(at_key(p) == 5); + BOOST_TEST(at_key(p) == 3); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_tpl_class.cpp b/test/sequence/adapt_assoc_tpl_class.cpp new file mode 100644 index 00000000..31a37d4c --- /dev/null +++ b/test/sequence/adapt_assoc_tpl_class.cpp @@ -0,0 +1,140 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ns +{ + struct x_member; + struct y_member; + struct z_member; + + template + class point + { + public: + + point() : x(0), y(0) {} + point(X x, Y y) : x(x), y(y) {} + + X get_x() const { return x; } + Y get_y() const { return y; } + void set_x(X x_) { x = x_; } + void set_y(Y y_) { y = y_; } + + private: + + X x; + Y y; + }; +} + +BOOST_FUSION_ADAPT_ASSOC_TPL_CLASS( + (X)(Y), + (ns::point)(X)(Y), + (X, X, obj.get_x(), obj.set_x(val), ns::x_member) + (Y, Y, obj.get_y(), obj.set_y(val), ns::y_member) +) + +int +main() +{ + using namespace boost::fusion; + using namespace std; + + typedef ns::point point; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + point p(123, 456); + + std::cout << at_c<0>(p) << std::endl; + std::cout << at_c<1>(p) << std::endl; + std::cout << p << std::endl; + BOOST_TEST(p == make_vector(123, 456)); + + at_c<0>(p) = 6; + at_c<1>(p) = 9; + BOOST_TEST(p == make_vector(6, 9)); + + BOOST_STATIC_ASSERT(result_of::size::value == 2); + BOOST_STATIC_ASSERT(!result_of::empty::value); + + BOOST_TEST(front(p) == 6); + BOOST_TEST(back(p) == 9); + } + + { + boost::fusion::vector v1(4, 2); + point v2(5, 3); + boost::fusion::vector v3(5, 4); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { + // conversion from point to vector + point p(5, 3); + boost::fusion::vector v(p); + v = p; + } + + { + // conversion from point to list + point p(5, 3); + boost::fusion::list l(p); + l = p; + } + + { + BOOST_MPL_ASSERT((boost::mpl::is_sequence)); + BOOST_MPL_ASSERT((boost::is_same< + boost::fusion::result_of::value_at_c::type + , boost::mpl::front::type>)); + } + + { + // assoc stuff + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((boost::mpl::not_ >)); + + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + + point p(5, 3); + + BOOST_TEST(at_key(p) == 5); + BOOST_TEST(at_key(p) == 3); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_assoc_tpl_struct.cpp b/test/sequence/adapt_assoc_tpl_struct.cpp new file mode 100644 index 00000000..b148c22b --- /dev/null +++ b/test/sequence/adapt_assoc_tpl_struct.cpp @@ -0,0 +1,133 @@ +/*============================================================================= + Copyright (c) 2010 Christopher Schmidt + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ns +{ + struct x_member; + struct y_member; + struct z_member; + + template + struct point + { + X x; + Y y; + }; +} + +BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( + (X)(Y), + (ns::point)(X)(Y), + (int, x, ns::x_member) + (int, y, ns::y_member) +) + +int +main() +{ + using namespace boost::fusion; + + typedef ns::point point; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + point p = {123, 456}; + + std::cout << at_c<0>(p) << std::endl; + std::cout << at_c<1>(p) << std::endl; + std::cout << p << std::endl; + BOOST_TEST(p == make_vector(123, 456)); + + at_c<0>(p) = 6; + at_c<1>(p) = 9; + BOOST_TEST(p == make_vector(6, 9)); + + BOOST_STATIC_ASSERT(result_of::size::value == 2); + BOOST_STATIC_ASSERT(!result_of::empty::value); + + BOOST_TEST(front(p) == 6); + BOOST_TEST(back(p) == 9); + } + + { + vector v1(4, 2); + point v2 = {5, 3}; + vector v3(5, 4); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { + // conversion from point to vector + point p = {5, 3}; + vector v(p); + v = p; + } + + { + // conversion from point to list + point p = {5, 3}; + list l(p); + l = p; + } + + { + // assoc stuff + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((result_of::has_key)); + BOOST_MPL_ASSERT((boost::mpl::not_ >)); + + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); + + point p = {5, 3}; + + BOOST_TEST(at_key(p) == 5); + BOOST_TEST(at_key(p) == 3); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_tpl_class.cpp b/test/sequence/adapt_tpl_class.cpp new file mode 100644 index 00000000..7a1b0be9 --- /dev/null +++ b/test/sequence/adapt_tpl_class.cpp @@ -0,0 +1,133 @@ +/*============================================================================= + Copyright (c) 2001-2009 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ns +{ + template + class point + { + public: + + point() : x(0), y(0) {} + point(X x, Y y) : x(x), y(y) {} + + X get_x() const { return x; } + Y get_y() const { return y; } + void set_x(X x_) { x = x_; } + void set_y(Y y_) { y = y_; } + + private: + + X x; + Y y; + }; +} + +BOOST_FUSION_ADAPT_TPL_CLASS( + (X)(Y), + (ns::point)(X)(Y), + (X, X, obj.get_x(), obj.set_x(val)) + (Y, Y, obj.get_y(), obj.set_y(val)) +) + +int +main() +{ + using namespace boost::fusion; + using namespace std; + + typedef ns::point point; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + point p(123, 456); + + std::cout << at_c<0>(p) << std::endl; + std::cout << at_c<1>(p) << std::endl; + std::cout << p << std::endl; + BOOST_TEST(p == make_vector(123, 456)); + + at_c<0>(p) = 6; + at_c<1>(p) = 9; + BOOST_TEST(p == make_vector(6, 9)); + + BOOST_STATIC_ASSERT(result_of::size::value == 2); + BOOST_STATIC_ASSERT(!result_of::empty::value); + + BOOST_TEST(front(p) == 6); + BOOST_TEST(back(p) == 9); + } + + { + boost::fusion::vector v1(4, 2); + point v2(5, 3); + boost::fusion::vector v3(5, 4); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { + // conversion from point to vector + point p(5, 3); + boost::fusion::vector v(p); + v = p; + } + + { + // conversion from point to list + point p(5, 3); + boost::fusion::list l(p); + l = p; + } + + { + BOOST_MPL_ASSERT((boost::mpl::is_sequence)); + BOOST_MPL_ASSERT((boost::is_same< + boost::fusion::result_of::value_at_c::type + , boost::mpl::front::type>)); + } + + return boost::report_errors(); +} + diff --git a/test/sequence/adapt_tpl_struct.cpp b/test/sequence/adapt_tpl_struct.cpp new file mode 100644 index 00000000..13e4446c --- /dev/null +++ b/test/sequence/adapt_tpl_struct.cpp @@ -0,0 +1,122 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ns +{ + template + struct point + { + X x; + Y y; + }; +} + +BOOST_FUSION_ADAPT_TPL_STRUCT( + (X)(Y), + (ns::point)(X)(Y), + (X, x) + (Y, y) +) + +template +struct s { M m; }; +BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), (M, m)) + +int +main() +{ + using namespace boost::fusion; + + typedef ns::point point; + + std::cout << tuple_open('['); + std::cout << tuple_close(']'); + std::cout << tuple_delimiter(", "); + + { + BOOST_MPL_ASSERT_NOT((traits::is_view)); + point p = {123, 456}; + + std::cout << at_c<0>(p) << std::endl; + std::cout << at_c<1>(p) << std::endl; + std::cout << p << std::endl; + BOOST_TEST(p == make_vector(123, 456)); + + at_c<0>(p) = 6; + at_c<1>(p) = 9; + BOOST_TEST(p == make_vector(6, 9)); + + BOOST_STATIC_ASSERT(result_of::size::value == 2); + BOOST_STATIC_ASSERT(!result_of::empty::value); + + BOOST_TEST(front(p) == 6); + BOOST_TEST(back(p) == 9); + } + + { + vector v1(4, 2); + point v2 = {5, 3}; + vector v3(5, 4); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { + // conversion from point to vector + point p = {5, 3}; + vector v(p); + v = p; + } + + { + // conversion from point to list + point p = {5, 3}; + list l(p); + l = p; + } + + { // begin/end + using namespace boost::fusion; + + typedef result_of::begin >::type b; + typedef result_of::end >::type e; + // this fails + BOOST_MPL_ASSERT((boost::is_same::type, e>)); + } + + return boost::report_errors(); +} +