diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
commit | 1a78a62555be32868418fe52f8e330c9d0f95d5a (patch) | |
tree | d3765a80e7d3b9640ec2e930743630cd6b9fce2b /boost/fusion/adapted | |
download | boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2 boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip |
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'boost/fusion/adapted')
90 files changed, 4550 insertions, 0 deletions
diff --git a/boost/fusion/adapted/adt.hpp b/boost/fusion/adapted/adt.hpp new file mode 100644 index 0000000000..a8293caaf8 --- /dev/null +++ b/boost/fusion/adapted/adt.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 2001-2011 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_ADT_HPP +#define BOOST_FUSION_ADAPTED_ADT_HPP + +#include <boost/fusion/adapted/adt/adapt_assoc_adt_named.hpp> +#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp> +#include <boost/fusion/adapted/adt/adapt_adt_named.hpp> +#include <boost/fusion/adapted/adt/adapt_adt.hpp> + +#endif diff --git a/boost/fusion/adapted/adt/adapt_adt.hpp b/boost/fusion/adapted/adt/adapt_adt.hpp new file mode 100644 index 0000000000..454ac922e5 --- /dev/null +++ b/boost/fusion/adapted/adt/adapt_adt.hpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2001-2009 Joel de Guzman + Copyright (c) 2009-2010 Hartmut Kaiser + Copyright (c) 2010-2011 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_ADT_ADAPT_ADT_HPP +#define BOOST_FUSION_ADAPTED_ADT_ADAPT_ADT_HPP + +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/empty.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/type_traits/remove_const.hpp> + +#include <boost/fusion/adapted/struct/detail/extension.hpp> +#include <boost/fusion/adapted/struct/detail/adapt_base.hpp> +#include <boost/fusion/adapted/struct/detail/at_impl.hpp> +#include <boost/fusion/adapted/struct/detail/is_view_impl.hpp> +#include <boost/fusion/adapted/struct/detail/is_sequence_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_at_impl.hpp> +#include <boost/fusion/adapted/struct/detail/category_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/size_impl.hpp> +#include <boost/fusion/adapted/struct/detail/begin_impl.hpp> +#include <boost/fusion/adapted/struct/detail/end_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/deref_impl.hpp> +#include <boost/fusion/adapted/adt/detail/extension.hpp> +#include <boost/fusion/adapted/adt/detail/adapt_base.hpp> + +#define BOOST_FUSION_ADAPT_ADT_FILLER_0(A, B, C, D)\ + ((A, B, C, D)) BOOST_FUSION_ADAPT_ADT_FILLER_1 +#define BOOST_FUSION_ADAPT_ADT_FILLER_1(A, B, C, D)\ + ((A, B, C, D)) BOOST_FUSION_ADAPT_ADT_FILLER_0 +#define BOOST_FUSION_ADAPT_ADT_FILLER_0_END +#define BOOST_FUSION_ADAPT_ADT_FILLER_1_END + +#define BOOST_FUSION_ADAPT_ADT_C(TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE) \ + BOOST_FUSION_ADAPT_ADT_C_BASE( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE, 4) + +#define BOOST_FUSION_ADAPT_TPL_ADT(TEMPLATE_PARAMS_SEQ, NAME_SEQ , ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (1)TEMPLATE_PARAMS_SEQ, \ + (1)NAME_SEQ, \ + struct_tag, \ + 0, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_ADT_FILLER_0(0,0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ADT_C) + +#define BOOST_FUSION_ADAPT_ADT(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + struct_tag, \ + 0, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_ADT_FILLER_0(0,0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ADT_C) + +#define BOOST_FUSION_ADAPT_ADT_AS_VIEW(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + struct_tag, \ + 1, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_ADT_FILLER_0(0,0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ADT_C) + +#endif diff --git a/boost/fusion/adapted/adt/adapt_adt_named.hpp b/boost/fusion/adapted/adt/adapt_adt_named.hpp new file mode 100644 index 0000000000..c2ace0130c --- /dev/null +++ b/boost/fusion/adapted/adt/adapt_adt_named.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_ADT_ADAPT_ADT_NAMED_HPP +#define BOOST_FUSION_ADAPTED_ADT_ADAPT_ADT_NAMED_HPP + +#include <boost/fusion/adapted/adt/adapt_adt.hpp> +#include <boost/fusion/adapted/struct/detail/proxy_type.hpp> + +#define BOOST_FUSION_ADAPT_ADT_NAMED_NS( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \ + WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \ + \ + BOOST_FUSION_ADAPT_ADT_AS_VIEW( \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ)NAME, \ + ATTRIBUTES) + +#define BOOST_FUSION_ADAPT_ADT_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_ADT_NAMED_NS( \ + WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES) + +#endif diff --git a/boost/fusion/adapted/adt/adapt_assoc_adt.hpp b/boost/fusion/adapted/adt/adapt_assoc_adt.hpp new file mode 100644 index 0000000000..cce1dfb081 --- /dev/null +++ b/boost/fusion/adapted/adt/adapt_assoc_adt.hpp @@ -0,0 +1,90 @@ +/*============================================================================= + Copyright (c) 2001-2009 Joel de Guzman + Copyright (c) 2007 Dan Marsden + Copyright (c) 2010-2011 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_ADT_ADAPT_ASSOC_ADT_HPP +#define BOOST_FUSION_ADAPTED_ADT_ADAPT_ASSOC_ADT_HPP + +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/empty.hpp> +#include <boost/preprocessor/tuple/elem.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/remove_const.hpp> + +#include <boost/fusion/adapted/struct/detail/extension.hpp> +#include <boost/fusion/adapted/struct/detail/adapt_base.hpp> +#include <boost/fusion/adapted/struct/detail/at_impl.hpp> +#include <boost/fusion/adapted/struct/detail/is_view_impl.hpp> +#include <boost/fusion/adapted/struct/detail/is_sequence_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_at_impl.hpp> +#include <boost/fusion/adapted/struct/detail/category_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/size_impl.hpp> +#include <boost/fusion/adapted/struct/detail/begin_impl.hpp> +#include <boost/fusion/adapted/struct/detail/end_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/deref_impl.hpp> +#include <boost/fusion/adapted/struct/detail/deref_data_impl.hpp> +#include <boost/fusion/adapted/struct/detail/key_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_of_data_impl.hpp> +#include <boost/fusion/adapted/adt/detail/extension.hpp> +#include <boost/fusion/adapted/adt/detail/adapt_base.hpp> + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(A, B, C, D, E)\ + ((A, B, C, D, E)) BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1 +#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1(A, B, C, D, E)\ + ((A, B, C, D, E)) BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0 +#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0_END +#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1_END + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_C( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE) \ + \ + BOOST_FUSION_ADAPT_ADT_C_BASE(TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,ATTRIBUTE,5) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_assoc_key<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ), I> \ + { \ + typedef BOOST_PP_TUPLE_ELEM(5, 4, ATTRIBUTE) type; \ + }; + +#define BOOST_FUSION_ADAPT_ASSOC_TPL_ADT( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (1)TEMPLATE_PARAMS_SEQ, \ + (1)NAME_SEQ, \ + assoc_struct_tag, \ + 0, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(0,0,0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_ADT_C) + +#define BOOST_FUSION_ADAPT_ASSOC_ADT(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + assoc_struct_tag, \ + 0, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(0,0,0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_ADT_C) + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_AS_VIEW(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + assoc_struct_tag, \ + 1, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(0,0,0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_ADT_C) + +#endif diff --git a/boost/fusion/adapted/adt/adapt_assoc_adt_named.hpp b/boost/fusion/adapted/adt/adapt_assoc_adt_named.hpp new file mode 100644 index 0000000000..b875982533 --- /dev/null +++ b/boost/fusion/adapted/adt/adapt_assoc_adt_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_ADT_ADAPT_ASSOC_ADT_NAMED_HPP +#define BOOST_FUSION_ADAPTED_ADT_ADAPT_ASSOC_ADT_NAMED_HPP + +#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp> +#include <boost/fusion/adapted/struct/detail/proxy_type.hpp> + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED_NS( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \ + WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \ + \ + BOOST_FUSION_ADAPT_ASSOC_ADT_AS_VIEW( \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ)NAME, \ + ATTRIBUTES) + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED_NS( \ + WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES) + +#endif diff --git a/boost/fusion/adapted/adt/detail/adapt_base.hpp b/boost/fusion/adapted/adt/detail/adapt_base.hpp new file mode 100644 index 0000000000..bddc79de7e --- /dev/null +++ b/boost/fusion/adapted/adt/detail/adapt_base.hpp @@ -0,0 +1,181 @@ +/*============================================================================= + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_HPP +#define BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_HPP + +#include <boost/preprocessor/control/if.hpp> +#include <boost/preprocessor/seq/seq.hpp> +#include <boost/preprocessor/seq/elem.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_const.hpp> + +#define BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_TEMPLATE_IMPL(TEMPLATE_PARAMS_SEQ) \ + typename detail::get_identity< \ + lvalue \ + , BOOST_PP_SEQ_ELEM(1,TEMPLATE_PARAMS_SEQ) \ + >::type + +#define BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_NON_TEMPLATE_IMPL( \ + TEMPLATE_PARAMS_SEQ) \ + \ + boost::remove_const<boost::remove_reference<lvalue>::type>::type + +#define BOOST_FUSION_ADAPT_ADT_C_BASE( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,ATTRIBUTE,ATTRIBUTE_TUPEL_SIZE) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct access::adt_attribute_access< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + > \ + { \ + template<class Val> \ + static void \ + boost_fusion_adapt_adt_impl_set( \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj, \ + Val const& val) \ + { \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 3, ATTRIBUTE); \ + } \ + \ + static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \ + boost_fusion_adapt_adt_impl_get( \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj) \ + { \ + return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \ + } \ + \ + static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) \ + boost_fusion_adapt_adt_impl_get( \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& obj) \ + { \ + return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \ + } \ + }; \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct adt_attribute_proxy< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + , true \ + > \ + { \ + typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) type; \ + \ + explicit \ + adt_attribute_proxy( \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& o) \ + : obj(&o) \ + {} \ + \ + type get() const \ + { \ + return access::adt_attribute_access< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + >::boost_fusion_adapt_adt_impl_get(*obj); \ + } \ + \ + operator type() const \ + { \ + return get(); \ + } \ + \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const* obj; \ + }; \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct adt_attribute_proxy< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + , false \ + > \ + { \ + typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \ + \ + explicit \ + adt_attribute_proxy( \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& o) \ + : obj(&o) \ + {} \ + \ + template<class Val> \ + adt_attribute_proxy& \ + operator=(Val const& val) \ + { \ + access::adt_attribute_access< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + >::boost_fusion_adapt_adt_impl_set(*obj, val); \ + return *this; \ + } \ + \ + type get() const \ + { \ + return access::adt_attribute_access< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + >::boost_fusion_adapt_adt_impl_get(*obj); \ + } \ + \ + operator type() const \ + { \ + return get(); \ + } \ + \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)* obj; \ + }; \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct access::struct_member< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + > \ + { \ + typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) lvalue; \ + BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + \ + typedef \ + BOOST_PP_IF( \ + BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), \ + BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_TEMPLATE_IMPL, \ + BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_NON_TEMPLATE_IMPL)( \ + TEMPLATE_PARAMS_SEQ) \ + type; \ + \ + template<typename Seq> \ + struct apply \ + { \ + typedef \ + adt_attribute_proxy< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + , is_const<Seq>::value \ + > \ + type; \ + \ + static type \ + call(Seq& obj) \ + { \ + return type(obj); \ + } \ + }; \ + }; + +#endif diff --git a/boost/fusion/adapted/adt/detail/extension.hpp b/boost/fusion/adapted/adt/detail/extension.hpp new file mode 100644 index 0000000000..50c40cf34e --- /dev/null +++ b/boost/fusion/adapted/adt/detail/extension.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_ADT_DETAIL_EXTENSION_HPP +#define BOOST_FUSION_ADAPTED_ADT_DETAIL_EXTENSION_HPP + +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/remove_reference.hpp> + +namespace boost { namespace fusion { namespace detail +{ + template <typename T, typename Dummy> + struct get_identity + : remove_const<typename remove_reference<T>::type> + {}; +}}} + +#endif diff --git a/boost/fusion/adapted/array.hpp b/boost/fusion/adapted/array.hpp new file mode 100644 index 0000000000..b95081786f --- /dev/null +++ b/boost/fusion/adapted/array.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_ARRAY_27122005_1035) +#define BOOST_FUSION_ARRAY_27122005_1035 + +//For backwards compatibility +#include <boost/fusion/adapted/boost_array.hpp> + +#include <boost/fusion/adapted/array/tag_of.hpp> +#include <boost/fusion/adapted/array/is_view_impl.hpp> +#include <boost/fusion/adapted/array/is_sequence_impl.hpp> +#include <boost/fusion/adapted/array/category_of_impl.hpp> +#include <boost/fusion/adapted/array/begin_impl.hpp> +#include <boost/fusion/adapted/array/end_impl.hpp> +#include <boost/fusion/adapted/array/size_impl.hpp> +#include <boost/fusion/adapted/array/at_impl.hpp> +#include <boost/fusion/adapted/array/value_at_impl.hpp> +#include <boost/fusion/adapted/array/deref_impl.hpp> +#include <boost/fusion/adapted/array/value_of_impl.hpp> + +#endif diff --git a/boost/fusion/adapted/array/at_impl.hpp b/boost/fusion/adapted/array/at_impl.hpp new file mode 100644 index 0000000000..12f0372670 --- /dev/null +++ b/boost/fusion/adapted/array/at_impl.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_ARRAY_AT_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_AT_IMPL_HPP + +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/remove_extent.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct at_impl; + + template<> + struct at_impl<po_array_tag> + { + template<typename Seq, typename N> + struct apply + { + typedef typename + add_reference<typename remove_extent<Seq>::type>::type + type; + + static type + call(Seq& seq) + { + return seq[N::value]; + } + }; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/array/begin_impl.hpp b/boost/fusion/adapted/array/begin_impl.hpp new file mode 100644 index 0000000000..2ee4d707b1 --- /dev/null +++ b/boost/fusion/adapted/array/begin_impl.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + 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_ARRAY_BEGIN_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_BEGIN_IMPL_HPP + +#include <boost/fusion/iterator/basic_iterator.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct begin_impl; + + template <> + struct begin_impl<po_array_tag> + { + template <typename Seq> + struct apply + { + typedef + basic_iterator< + po_array_iterator_tag + , random_access_traversal_tag + , Seq + , 0 + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/array/category_of_impl.hpp b/boost/fusion/adapted/array/category_of_impl.hpp new file mode 100644 index 0000000000..0a633a455d --- /dev/null +++ b/boost/fusion/adapted/array/category_of_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + 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_ARRAY_CATEGORY_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_CATEGORY_OF_IMPL_HPP + +namespace boost { namespace fusion +{ + struct random_access_traversal_tag; + + namespace extension + { + template<typename> + struct category_of_impl; + + template<> + struct category_of_impl<po_array_tag> + { + template<typename Seq> + struct apply + { + typedef random_access_traversal_tag type; + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/array/deref_impl.hpp b/boost/fusion/adapted/array/deref_impl.hpp new file mode 100644 index 0000000000..a58cf99001 --- /dev/null +++ b/boost/fusion/adapted/array/deref_impl.hpp @@ -0,0 +1,40 @@ +/*============================================================================= + 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_ARRAY_DEREF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_DEREF_IMPL_HPP + +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/remove_extent.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template <typename> + struct deref_impl; + + template <> + struct deref_impl<po_array_iterator_tag> + { + template <typename It> + struct apply + { + typedef typename + add_reference< + typename remove_extent<typename It::seq_type>::type + >::type + type; + + static type + call(It const& it) + { + return (*it.seq)[It::index::value]; + } + }; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/array/end_impl.hpp b/boost/fusion/adapted/array/end_impl.hpp new file mode 100644 index 0000000000..5b367f9c00 --- /dev/null +++ b/boost/fusion/adapted/array/end_impl.hpp @@ -0,0 +1,44 @@ +/*============================================================================= + 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_ARRAY_END_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_END_IMPL_HPP + +#include <boost/fusion/iterator/basic_iterator.hpp> +#include <boost/type_traits/rank.hpp> +#include <boost/type_traits/extent.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template <typename> + struct end_impl; + + template <> + struct end_impl<po_array_tag> + { + template <typename Seq> + struct apply + { + typedef + basic_iterator< + po_array_iterator_tag + , random_access_traversal_tag + , Seq + , extent<Seq,rank<Seq>::value-1>::value + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/array/is_sequence_impl.hpp b/boost/fusion/adapted/array/is_sequence_impl.hpp new file mode 100644 index 0000000000..d6de858561 --- /dev/null +++ b/boost/fusion/adapted/array/is_sequence_impl.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_ARRAY_IS_SEQUENCE_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_IS_SEQUENCE_IMPL_HPP + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct is_sequence_impl; + + template<> + struct is_sequence_impl<po_array_tag> + { + template<typename Seq> + struct apply + : mpl::true_ + {}; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/array/is_view_impl.hpp b/boost/fusion/adapted/array/is_view_impl.hpp new file mode 100644 index 0000000000..238eac0e58 --- /dev/null +++ b/boost/fusion/adapted/array/is_view_impl.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_ARRAY_IS_VIEW_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_IS_VIEW_IMPL_HPP + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct is_view_impl; + + template<> + struct is_view_impl<po_array_tag> + { + template<typename Seq> + struct apply + : mpl::false_ + {}; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/array/size_impl.hpp b/boost/fusion/adapted/array/size_impl.hpp new file mode 100644 index 0000000000..8be5a29d81 --- /dev/null +++ b/boost/fusion/adapted/array/size_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_ARRAY_SIZE_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_SIZE_IMPL_HPP + +#include <boost/type_traits/rank.hpp> +#include <boost/type_traits/extent.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct size_impl; + + template<> + struct size_impl<po_array_tag> + { + template<typename Seq> + struct apply + : extent<Seq,rank<Seq>::value-1> + {}; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/array/tag_of.hpp b/boost/fusion/adapted/array/tag_of.hpp new file mode 100644 index 0000000000..7c732a7021 --- /dev/null +++ b/boost/fusion/adapted/array/tag_of.hpp @@ -0,0 +1,72 @@ +/*============================================================================= + 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_ARRAY_TAG_OF_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_TAG_OF_HPP + +#include <boost/fusion/support/tag_of_fwd.hpp> +#include <cstddef> + +namespace boost +{ + namespace fusion + { + struct po_array_tag; + struct po_array_iterator_tag; + struct random_access_traversal_tag; + struct fusion_sequence_tag; + + namespace traits + { +#ifdef BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS + template<typename T, std::size_t N> + struct tag_of<T[N], void> + { + typedef po_array_tag type; + }; + + template<typename T, std::size_t N> + struct tag_of<T const[N], void> + { + typedef po_array_tag type; + }; +#else + template<typename T, std::size_t N> + struct tag_of<T[N], void> + { + typedef po_array_tag type; + }; + + template<typename T, std::size_t N> + struct tag_of<T const[N], void> + { + typedef po_array_tag type; + }; +#endif + } + } + + namespace mpl + { + template<typename> + struct sequence_tag; + + template<typename T, std::size_t N> + struct sequence_tag<T[N]> + { + typedef fusion::po_array_tag type; + }; + + template<typename T, std::size_t N> + struct sequence_tag<T const[N] > + { + typedef fusion::po_array_tag type; + }; + } +} + +#endif diff --git a/boost/fusion/adapted/array/value_at_impl.hpp b/boost/fusion/adapted/array/value_at_impl.hpp new file mode 100644 index 0000000000..4e04c37a8f --- /dev/null +++ b/boost/fusion/adapted/array/value_at_impl.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_ARRAY_VALUE_AT_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_VALUE_AT_IMPL_HPP + +#include <boost/type_traits/remove_extent.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct value_at_impl; + + template <> + struct value_at_impl<po_array_tag> + { + template <typename Seq, typename N> + struct apply + : remove_extent<Seq> + {}; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/array/value_of_impl.hpp b/boost/fusion/adapted/array/value_of_impl.hpp new file mode 100644 index 0000000000..2bbddf235e --- /dev/null +++ b/boost/fusion/adapted/array/value_of_impl.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_ARRAY_VALUE_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_ARRAY_VALUE_OF_IMPL_HPP + +#include <boost/type_traits/remove_extent.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template <typename> + struct value_of_impl; + + template <> + struct value_of_impl<po_array_iterator_tag> + { + template <typename It> + struct apply + : remove_extent<typename It::seq_type> + {}; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/boost_array.hpp b/boost/fusion/adapted/boost_array.hpp new file mode 100644 index 0000000000..ed9fd9b3ad --- /dev/null +++ b/boost/fusion/adapted/boost_array.hpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_BOOST_ARRAY_27122005_1035) +#define BOOST_FUSION_BOOST_ARRAY_27122005_1035 + +#include <boost/fusion/adapted/boost_array/array_iterator.hpp> +#include <boost/fusion/adapted/boost_array/tag_of.hpp> +#include <boost/fusion/adapted/boost_array/detail/is_view_impl.hpp> +#include <boost/fusion/adapted/boost_array/detail/is_sequence_impl.hpp> +#include <boost/fusion/adapted/boost_array/detail/category_of_impl.hpp> +#include <boost/fusion/adapted/boost_array/detail/begin_impl.hpp> +#include <boost/fusion/adapted/boost_array/detail/end_impl.hpp> +#include <boost/fusion/adapted/boost_array/detail/size_impl.hpp> +#include <boost/fusion/adapted/boost_array/detail/at_impl.hpp> +#include <boost/fusion/adapted/boost_array/detail/value_at_impl.hpp> + +#endif diff --git a/boost/fusion/adapted/boost_array/array_iterator.hpp b/boost/fusion/adapted/boost_array/array_iterator.hpp new file mode 100644 index 0000000000..1246144980 --- /dev/null +++ b/boost/fusion/adapted/boost_array/array_iterator.hpp @@ -0,0 +1,107 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_ARRAY_ITERATOR_26122005_2250) +#define BOOST_FUSION_ARRAY_ITERATOR_26122005_2250 + +#include <cstddef> +#include <boost/config.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/minus.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/fusion/iterator/iterator_facade.hpp> + +namespace boost { namespace fusion +{ + struct random_access_traversal_tag; + + template <typename Array, int Pos> + struct array_iterator + : iterator_facade<array_iterator<Array, Pos>, random_access_traversal_tag> + { + BOOST_MPL_ASSERT_RELATION(Pos, >=, 0); + BOOST_MPL_ASSERT_RELATION(Pos, <=, static_cast<int>(Array::static_size)); + + typedef mpl::int_<Pos> index; + typedef Array array_type; + + array_iterator(Array& a) + : array(a) {} + + Array& array; + + template <typename Iterator> + struct value_of + { + typedef typename Iterator::array_type array_type; + typedef typename array_type::value_type type; + }; + + template <typename Iterator> + struct deref + { + typedef typename Iterator::array_type array_type; + typedef typename + mpl::if_< + is_const<array_type> + , typename array_type::const_reference + , typename array_type::reference + >::type + type; + + static type + call(Iterator const & it) + { + return it.array[Iterator::index::value]; + } + }; + + template <typename Iterator, typename N> + struct advance + { + typedef typename Iterator::index index; + typedef typename Iterator::array_type array_type; + typedef array_iterator<array_type, index::value + N::value> type; + + static type + call(Iterator const& i) + { + return type(i.array); + } + }; + + template <typename Iterator> + struct next : advance<Iterator, mpl::int_<1> > {}; + + template <typename Iterator> + struct prior : advance<Iterator, mpl::int_<-1> > {}; + + template <typename I1, typename I2> + struct distance : mpl::minus<typename I2::index, typename I1::index> + { + typedef typename + mpl::minus< + typename I2::index, typename I1::index + >::type + type; + + static type + call(I1 const&, I2 const&) + { + return type(); + } + }; + + private: + + array_iterator<Array, Pos>& operator=(array_iterator<Array, Pos> const&); + }; +}} + +#endif diff --git a/boost/fusion/adapted/boost_array/detail/at_impl.hpp b/boost/fusion/adapted/boost_array/detail/at_impl.hpp new file mode 100644 index 0000000000..6df8858663 --- /dev/null +++ b/boost/fusion/adapted/boost_array/detail/at_impl.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_27122005_1241) +#define BOOST_FUSION_AT_IMPL_27122005_1241 + +#include <boost/type_traits/is_const.hpp> + +#include <boost/mpl/if.hpp> + +namespace boost { namespace fusion { + + struct boost_array_tag; + + namespace extension + { + template<typename T> + struct at_impl; + + template<> + struct at_impl<boost_array_tag> + { + template<typename Sequence, typename N> + struct apply + { + typedef typename mpl::if_< + is_const<Sequence>, + typename Sequence::const_reference, + typename Sequence::reference>::type type; + + static type + call(Sequence& seq) + { + return seq[N::value]; + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_array/detail/begin_impl.hpp b/boost/fusion/adapted/boost_array/detail/begin_impl.hpp new file mode 100644 index 0000000000..c8bce9ffe7 --- /dev/null +++ b/boost/fusion/adapted/boost_array/detail/begin_impl.hpp @@ -0,0 +1,40 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_27122005_1117) +#define BOOST_FUSION_BEGIN_IMPL_27122005_1117 + +#include <boost/fusion/adapted/boost_array/array_iterator.hpp> + +namespace boost { namespace fusion { + + struct boost_array_tag; + + namespace extension + { + template<typename T> + struct begin_impl; + + template <> + struct begin_impl<boost_array_tag> + { + template <typename Sequence> + struct apply + { + typedef array_iterator<Sequence, 0> type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_array/detail/category_of_impl.hpp b/boost/fusion/adapted/boost_array/detail/category_of_impl.hpp new file mode 100644 index 0000000000..8e92efd7c3 --- /dev/null +++ b/boost/fusion/adapted/boost_array/detail/category_of_impl.hpp @@ -0,0 +1,35 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_27122005_1044) +#define BOOST_FUSION_CATEGORY_OF_IMPL_27122005_1044 + +#include <boost/config/no_tr1/utility.hpp> + +namespace boost { namespace fusion { + + struct boost_array_tag; + struct random_access_traversal_tag; + + namespace extension + { + template<typename T> + struct category_of_impl; + + template<> + struct category_of_impl<boost_array_tag> + { + template<typename T> + struct apply + { + typedef random_access_traversal_tag type; + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_array/detail/end_impl.hpp b/boost/fusion/adapted/boost_array/detail/end_impl.hpp new file mode 100644 index 0000000000..38b5a82cb4 --- /dev/null +++ b/boost/fusion/adapted/boost_array/detail/end_impl.hpp @@ -0,0 +1,40 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_27122005_1120) +#define BOOST_FUSION_END_IMPL_27122005_1120 + +#include <boost/fusion/adapted/boost_array/array_iterator.hpp> + +namespace boost { namespace fusion { + + struct boost_array_tag; + + namespace extension + { + template <typename Tag> + struct end_impl; + + template <> + struct end_impl<boost_array_tag> + { + template <typename Sequence> + struct apply + { + typedef array_iterator<Sequence, Sequence::static_size> type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_array/detail/is_sequence_impl.hpp b/boost/fusion/adapted/boost_array/detail/is_sequence_impl.hpp new file mode 100644 index 0000000000..cdbe6c8382 --- /dev/null +++ b/boost/fusion/adapted/boost_array/detail/is_sequence_impl.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_1648) +#define BOOST_FUSION_IS_SEQUENCE_IMPL_27122005_1648 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion { + + struct boost_array_tag; + + namespace extension + { + template<typename Tag> + struct is_sequence_impl; + + template<> + struct is_sequence_impl<boost_array_tag> + { + template<typename Sequence> + struct apply : mpl::true_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_array/detail/is_view_impl.hpp b/boost/fusion/adapted/boost_array/detail/is_view_impl.hpp new file mode 100644 index 0000000000..cf63c6a667 --- /dev/null +++ b/boost/fusion/adapted/boost_array/detail/is_view_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_2221) +#define BOOST_FUSION_IS_VIEW_IMPL_27042006_2221 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct boost_array_tag; + + namespace extension + { + template<typename Tag> + struct is_view_impl; + + template<> + struct is_view_impl<boost_array_tag> + { + template<typename T> + struct apply : mpl::false_ + {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_array/detail/size_impl.hpp b/boost/fusion/adapted/boost_array/detail/size_impl.hpp new file mode 100644 index 0000000000..c04ab93c6c --- /dev/null +++ b/boost/fusion/adapted/boost_array/detail/size_impl.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_27122005_1251) +#define BOOST_FUSION_SIZE_IMPL_27122005_1251 + +namespace boost { namespace fusion { + + struct boost_array_tag; + + namespace extension + { + template<typename T> + struct size_impl; + + template<> + struct size_impl<boost_array_tag> + { + template<typename Sequence> + struct apply : mpl::int_<Sequence::static_size> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_array/detail/value_at_impl.hpp b/boost/fusion/adapted/boost_array/detail/value_at_impl.hpp new file mode 100644 index 0000000000..9f80f73b39 --- /dev/null +++ b/boost/fusion/adapted/boost_array/detail/value_at_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_27122005_1256) +#define BOOST_FUSION_VALUE_AT_IMPL_27122005_1256 + +namespace boost { namespace fusion { + + struct boost_array_tag; + + namespace extension + { + template<typename T> + struct value_at_impl; + + template <> + struct value_at_impl<boost_array_tag> + { + template <typename Sequence, typename N> + struct apply + { + typedef typename Sequence::value_type type; + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_array/tag_of.hpp b/boost/fusion/adapted/boost_array/tag_of.hpp new file mode 100644 index 0000000000..f33c93fc70 --- /dev/null +++ b/boost/fusion/adapted/boost_array/tag_of.hpp @@ -0,0 +1,58 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_SEQUENCE_TAG_OF_27122005_1030) +#define FUSION_SEQUENCE_TAG_OF_27122005_1030 + +#include <boost/fusion/support/tag_of_fwd.hpp> + +#include <cstddef> + +namespace boost +{ + template<typename T, std::size_t N> + class array; +} + +namespace boost { namespace fusion +{ + struct boost_array_tag; + struct fusion_sequence_tag; + + namespace traits + { + template<typename T, std::size_t N> +#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) + struct tag_of<boost::array<T,N>, void > +#else + struct tag_of<boost::array<T,N> > +#endif + { + typedef boost_array_tag type; + }; + } +}} + +namespace boost { namespace mpl +{ + template<typename> + struct sequence_tag; + + template<typename T, std::size_t N> + struct sequence_tag<array<T,N> > + { + typedef fusion::fusion_sequence_tag type; + }; + + template<typename T, std::size_t N> + struct sequence_tag<array<T,N> const> + { + typedef fusion::fusion_sequence_tag type; + }; +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple.hpp b/boost/fusion/adapted/boost_tuple.hpp new file mode 100644 index 0000000000..6149478f3a --- /dev/null +++ b/boost/fusion/adapted/boost_tuple.hpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_BOOST_TUPLE_09272006_0732) +#define BOOST_FUSION_BOOST_TUPLE_09272006_0732 + +#include <boost/fusion/adapted/boost_tuple/tag_of.hpp> +#include <boost/fusion/adapted/boost_tuple/detail/is_view_impl.hpp> +#include <boost/fusion/adapted/boost_tuple/detail/is_sequence_impl.hpp> +#include <boost/fusion/adapted/boost_tuple/detail/category_of_impl.hpp> +#include <boost/fusion/adapted/boost_tuple/detail/begin_impl.hpp> +#include <boost/fusion/adapted/boost_tuple/detail/end_impl.hpp> +#include <boost/fusion/adapted/boost_tuple/detail/size_impl.hpp> +#include <boost/fusion/adapted/boost_tuple/detail/at_impl.hpp> +#include <boost/fusion/adapted/boost_tuple/detail/value_at_impl.hpp> + +#endif diff --git a/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp b/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp new file mode 100644 index 0000000000..551f0fd900 --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp @@ -0,0 +1,189 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_BOOST_TUPLE_ITERATOR_09262006_1851) +#define FUSION_BOOST_TUPLE_ITERATOR_09262006_1851 + +#include <boost/fusion/iterator/iterator_facade.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/or.hpp> +#include <boost/mpl/plus.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/tuple/tuple.hpp> + +namespace boost { namespace fusion +{ + struct forward_traversal_tag; + + namespace detail + { + template <typename T> + struct boost_tuple_is_empty : mpl::false_ {}; + + template <> + struct boost_tuple_is_empty<tuples::null_type> : mpl::true_ {}; + + template <> + struct boost_tuple_is_empty<tuples::null_type const> : mpl::true_ {}; + + template <> + struct boost_tuple_is_empty<tuples::tuple<> > : mpl::true_ {}; + + template <> + struct boost_tuple_is_empty<tuples::tuple<> const> : mpl::true_ {}; + } + + template <typename Cons = tuples::null_type> + struct boost_tuple_iterator + : iterator_facade<boost_tuple_iterator<Cons>, forward_traversal_tag> + { + typedef Cons cons_type; + + explicit boost_tuple_iterator(Cons& in_cons) + : cons(in_cons) {} + Cons& cons; + + template <typename Iterator> + struct value_of : mpl::identity<typename Iterator::cons_type::head_type> {}; + + template <typename Iterator> + struct deref + { + typedef typename value_of<Iterator>::type element; + + typedef typename + mpl::if_< + is_const<typename Iterator::cons_type> + , typename tuples::access_traits<element>::const_type + , typename tuples::access_traits<element>::non_const_type + >::type + type; + + static type + call(Iterator const& iter) + { + return iter.cons.get_head(); + } + }; + + template <typename Iterator> + struct next + { + typedef typename Iterator::cons_type cons_type; + typedef typename cons_type::tail_type tail_type; + + typedef boost_tuple_iterator< + typename mpl::eval_if< + is_const<cons_type> + , add_const<tail_type> + , mpl::identity<tail_type> + >::type> + type; + + static type + call(Iterator const& iter) + { + return type(iter.cons.get_tail()); + } + }; + + template <typename I1, typename I2> + struct distance; + + // detail + template <typename I1, typename I2> + struct lazy_next_distance + { + typedef + typename mpl::plus< + mpl::int_<1>, + typename distance< + typename next<I1>::type, + I2 + >::type + >::type type; + }; + + template <typename I1, typename I2> + struct distance + { + typedef typename mpl::eval_if< + boost::is_same<I1, I2>, + mpl::int_<0>, + lazy_next_distance<I1, I2> + >::type type; + + static type + call(I1 const&, I2 const&) + { + return type(); + } + }; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + boost_tuple_iterator& operator= (boost_tuple_iterator const&); + }; + + template <typename Null> + struct boost_tuple_null_iterator + : iterator_facade<boost_tuple_iterator<Null>, forward_traversal_tag> + { + typedef Null cons_type; + + template <typename I1, typename I2> + struct equal_to + : mpl::or_< + is_same<I1, I2> + , mpl::and_< + detail::boost_tuple_is_empty<typename I1::cons_type> + , detail::boost_tuple_is_empty<typename I2::cons_type> + > + > + {}; + }; + + template <> + struct boost_tuple_iterator<tuples::null_type> + : boost_tuple_null_iterator<tuples::null_type> + { + template <typename Cons> + explicit boost_tuple_iterator(Cons const&) {} + }; + + template <> + struct boost_tuple_iterator<tuples::null_type const> + : boost_tuple_null_iterator<tuples::null_type const> + { + template <typename Cons> + explicit boost_tuple_iterator(Cons const&) {} + }; + + template <> + struct boost_tuple_iterator<tuples::tuple<> > + : boost_tuple_null_iterator<tuples::tuple<> > + { + template <typename Cons> + explicit boost_tuple_iterator(Cons const&) {} + }; + + template <> + struct boost_tuple_iterator<tuples::tuple<> const> + : boost_tuple_null_iterator<tuples::tuple<> const> + { + template <typename Cons> + explicit boost_tuple_iterator(Cons const&) {} + }; +}} + +#endif + + diff --git a/boost/fusion/adapted/boost_tuple/detail/at_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/at_impl.hpp new file mode 100644 index 0000000000..8e2312500b --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/at_impl.hpp @@ -0,0 +1,50 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_AT_IMPL_09262006_1920) +#define BOOST_FUSION_AT_IMPL_09262006_1920 + +#include <boost/tuple/tuple.hpp> +#include <boost/mpl/if.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename T> + struct at_impl; + + template <> + struct at_impl<boost_tuple_tag> + { + template <typename Sequence, typename N> + struct apply + { + typedef typename + tuples::element<N::value, Sequence>::type + element; + + typedef typename + mpl::if_< + is_const<Sequence> + , typename tuples::access_traits<element>::const_type + , typename tuples::access_traits<element>::non_const_type + >::type + type; + + static type + call(Sequence& seq) + { + return tuples::get<N::value>(seq); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/begin_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/begin_impl.hpp new file mode 100644 index 0000000000..010c442750 --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/begin_impl.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_BEGIN_IMPL_09272006_0719) +#define BOOST_FUSION_BEGIN_IMPL_09272006_0719 + +#include <boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename T> + struct begin_impl; + + template <> + struct begin_impl<boost_tuple_tag> + { + template <typename Sequence> + struct apply + { + typedef boost_tuple_iterator<Sequence> type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/category_of_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/category_of_impl.hpp new file mode 100644 index 0000000000..9b52c98a88 --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/category_of_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_CATEGORY_OF_IMPL_09272006_0726) +#define BOOST_FUSION_CATEGORY_OF_IMPL_09272006_0726 + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + struct forward_traversal_tag; + + namespace extension + { + template<typename T> + struct category_of_impl; + + template<> + struct category_of_impl<boost_tuple_tag> + { + template<typename T> + struct apply + { + typedef forward_traversal_tag type; + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/end_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/end_impl.hpp new file mode 100644 index 0000000000..e54702bf74 --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/end_impl.hpp @@ -0,0 +1,54 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_END_IMPL_09272006_0721) +#define BOOST_FUSION_END_IMPL_09272006_0721 + +#include <boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_const.hpp> + +namespace boost { namespace tuples +{ + struct null_type; +}} + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template <typename Tag> + struct end_impl; + + template <> + struct end_impl<boost_tuple_tag> + { + template <typename Sequence> + struct apply + { + typedef + boost_tuple_iterator< + typename mpl::if_< + is_const<Sequence> + , tuples::null_type const + , tuples::null_type + >::type + > + type; + + static type + call(Sequence& seq) + { + return type(seq); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/is_sequence_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/is_sequence_impl.hpp new file mode 100644 index 0000000000..c74fb4dfea --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/is_sequence_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_IS_SEQUENCE_IMPL_09272006_0726) +#define BOOST_FUSION_IS_SEQUENCE_IMPL_09272006_0726 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename Tag> + struct is_sequence_impl; + + template<> + struct is_sequence_impl<boost_tuple_tag> + { + template<typename Sequence> + struct apply : mpl::true_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/is_view_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/is_view_impl.hpp new file mode 100644 index 0000000000..5d639d2b23 --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/is_view_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_IS_VIEW_IMPL_09272006_0725) +#define BOOST_FUSION_IS_VIEW_IMPL_09272006_0725 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename Tag> + struct is_view_impl; + + template<> + struct is_view_impl<boost_tuple_tag> + { + template<typename T> + struct apply : mpl::false_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/size_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/size_impl.hpp new file mode 100644 index 0000000000..1dad42030f --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/size_impl.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_SIZE_IMPL_09272006_0724) +#define BOOST_FUSION_SIZE_IMPL_09272006_0724 + +#include <boost/tuple/tuple.hpp> +#include <boost/mpl/int.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename T> + struct size_impl; + + template <> + struct size_impl<boost_tuple_tag> + { + template <typename Sequence> + struct apply : mpl::int_<tuples::length<Sequence>::value> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/value_at_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/value_at_impl.hpp new file mode 100644 index 0000000000..4f5fc6a656 --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/value_at_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_VALUE_AT_IMPL_09262006_1926) +#define BOOST_FUSION_VALUE_AT_IMPL_09262006_1926 + +#include <boost/tuple/tuple.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename T> + struct value_at_impl; + + template <> + struct value_at_impl<boost_tuple_tag> + { + template <typename Sequence, typename N> + struct apply : tuples::element<N::value, Sequence> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/tag_of.hpp b/boost/fusion/adapted/boost_tuple/tag_of.hpp new file mode 100644 index 0000000000..18356de2af --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/tag_of.hpp @@ -0,0 +1,114 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_TAG_OF_09262006_1900) +#define BOOST_FUSION_TAG_OF_09262006_1900 + +#include <boost/fusion/support/tag_of_fwd.hpp> + +namespace boost { namespace tuples +{ + struct null_type; + + template < + class T0, class T1, class T2, class T3, class T4, + class T5, class T6, class T7, class T8, class T9 + > + class tuple; + + template <class Head, class Tail> + struct cons; +}} + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + struct fusion_sequence_tag; + + namespace traits + { + template < + class T0, class T1, class T2, class T3, class T4, + class T5, class T6, class T7, class T8, class T9 + > +#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) + struct tag_of<tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>, void > +#else + struct tag_of<tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> > +#endif + { + typedef boost_tuple_tag type; + }; + + template <class Head, class Tail> +#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) + struct tag_of<tuples::cons<Head, Tail>, void > +#else + struct tag_of<tuples::cons<Head, Tail> > +#endif + { + typedef boost_tuple_tag type; + }; + + template <> + struct tag_of<tuples::null_type> + { + typedef boost_tuple_tag type; + }; + } +}} + +namespace boost { namespace mpl +{ + template<typename> + struct sequence_tag; + + template < + class T0, class T1, class T2, class T3, class T4, + class T5, class T6, class T7, class T8, class T9 + > + struct sequence_tag<tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> > + { + typedef fusion::fusion_sequence_tag type; + }; + + template < + class T0, class T1, class T2, class T3, class T4, + class T5, class T6, class T7, class T8, class T9 + > + struct sequence_tag< + tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> const + > + { + typedef fusion::fusion_sequence_tag type; + }; + + template <class Head, class Tail> + struct sequence_tag<tuples::cons<Head, Tail> > + { + typedef fusion::fusion_sequence_tag type; + }; + + template <class Head, class Tail> + struct sequence_tag<tuples::cons<Head, Tail> const> + { + typedef fusion::fusion_sequence_tag type; + }; + + template <> + struct sequence_tag<tuples::null_type> + { + typedef fusion::fusion_sequence_tag type; + }; + + template <> + struct sequence_tag<tuples::null_type const> + { + typedef fusion::fusion_sequence_tag type; + }; +}} + +#endif diff --git a/boost/fusion/adapted/mpl.hpp b/boost/fusion/adapted/mpl.hpp new file mode 100644 index 0000000000..739ff93826 --- /dev/null +++ b/boost/fusion/adapted/mpl.hpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_MPL_31122005_1152) +#define BOOST_FUSION_MPL_31122005_1152 + +#include <boost/fusion/adapted/mpl/detail/begin_impl.hpp> +#include <boost/fusion/adapted/mpl/detail/end_impl.hpp> +#include <boost/fusion/adapted/mpl/detail/is_sequence_impl.hpp> +#include <boost/fusion/adapted/mpl/detail/size_impl.hpp> +#include <boost/fusion/adapted/mpl/detail/value_at_impl.hpp> +#include <boost/fusion/adapted/mpl/detail/at_impl.hpp> +#include <boost/fusion/adapted/mpl/detail/has_key_impl.hpp> +#include <boost/fusion/adapted/mpl/detail/category_of_impl.hpp> +#include <boost/fusion/adapted/mpl/detail/is_view_impl.hpp> +#include <boost/fusion/adapted/mpl/detail/empty_impl.hpp> + +#endif diff --git a/boost/fusion/adapted/mpl/detail/at_impl.hpp b/boost/fusion/adapted/mpl/detail/at_impl.hpp new file mode 100644 index 0000000000..99342d7b3c --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/at_impl.hpp @@ -0,0 +1,40 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_31122005_1642) +#define BOOST_FUSION_AT_IMPL_31122005_1642 + +#include <boost/mpl/at.hpp> + +namespace boost { namespace fusion +{ + struct mpl_sequence_tag; + + namespace extension + { + template<typename Tag> + struct at_impl; + + template <> + struct at_impl<mpl_sequence_tag> + { + template <typename Sequence, typename N> + struct apply + { + typedef typename mpl::at<Sequence, N>::type type; + + static type + call(Sequence) + { + return type(); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/detail/begin_impl.hpp b/boost/fusion/adapted/mpl/detail/begin_impl.hpp new file mode 100644 index 0000000000..ef274ba0a6 --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/begin_impl.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_31122005_1209) +#define BOOST_FUSION_BEGIN_IMPL_31122005_1209 + +#include <boost/fusion/adapted/mpl/mpl_iterator.hpp> +#include <boost/mpl/begin.hpp> +#include <boost/type_traits/remove_const.hpp> + +namespace boost { namespace fusion { + + struct mpl_sequence_tag; + + namespace extension + { + template <typename Tag> + struct begin_impl; + + template <> + struct begin_impl<mpl_sequence_tag> + { + template <typename Sequence> + struct apply + { + typedef typename mpl::begin< + typename remove_const<Sequence>::type + >::type iterator; + typedef mpl_iterator<iterator> type; + + static type + call(Sequence) + { + return type(); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/detail/category_of_impl.hpp b/boost/fusion/adapted/mpl/detail/category_of_impl.hpp new file mode 100644 index 0000000000..be43a56194 --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/category_of_impl.hpp @@ -0,0 +1,54 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_20060217_2141) +#define BOOST_FUSION_CATEGORY_OF_IMPL_20060217_2141 + +#include <boost/fusion/support/detail/mpl_iterator_category.hpp> +#include <boost/mpl/begin_end.hpp> +#include <boost/mpl/is_sequence.hpp> +#include <boost/static_assert.hpp> + +namespace boost { namespace fusion { + + namespace detail + { + template <typename T> + struct mpl_sequence_category_of + { + // assumes T is an mpl sequence + // there should be no way this will ever be + // called where T is an mpl iterator + + BOOST_STATIC_ASSERT(mpl::is_sequence<T>::value); + typedef typename + mpl_iterator_category< + typename mpl::begin<T>::type::category + >::type + type; + }; + } + + struct mpl_sequence_tag; + + namespace extension + { + template<typename Tag> + struct category_of_impl; + + template<> + struct category_of_impl<mpl_sequence_tag> + { + template<typename T> + struct apply + : detail::mpl_sequence_category_of<T> + {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/detail/empty_impl.hpp b/boost/fusion/adapted/mpl/detail/empty_impl.hpp new file mode 100644 index 0000000000..f2eb22a0d9 --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/empty_impl.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_EMPTY_IMPL_31122005_1554) +#define BOOST_FUSION_EMPTY_IMPL_31122005_1554 + +#include <boost/mpl/empty.hpp> + +namespace boost { namespace fusion +{ + struct mpl_sequence_tag; + + namespace extension + { + template <typename Sequence> + struct empty_impl; + + template <> + struct empty_impl<mpl_sequence_tag> + { + template <typename Sequence> + struct apply : mpl::empty<Sequence> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/detail/end_impl.hpp b/boost/fusion/adapted/mpl/detail/end_impl.hpp new file mode 100644 index 0000000000..613ab63cc0 --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/end_impl.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_31122005_1237) +#define BOOST_FUSION_END_IMPL_31122005_1237 + +#include <boost/fusion/adapted/mpl/mpl_iterator.hpp> +#include <boost/mpl/end.hpp> +#include <boost/type_traits/add_const.hpp> + +namespace boost { namespace fusion +{ + struct mpl_sequence_tag; + + namespace extension + { + template <typename Tag> + struct end_impl; + + template <> + struct end_impl<mpl_sequence_tag> + { + template <typename Sequence> + struct apply + { + typedef typename mpl::end< + typename remove_const<Sequence>::type + >::type iterator; + typedef mpl_iterator<iterator> type; + + static type + call(Sequence) + { + return type(); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/detail/has_key_impl.hpp b/boost/fusion/adapted/mpl/detail/has_key_impl.hpp new file mode 100644 index 0000000000..b2b3253a8e --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/has_key_impl.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_HAS_KEY_IMPL_31122005_1647) +#define BOOST_FUSION_HAS_KEY_IMPL_31122005_1647 + +#include <boost/mpl/has_key.hpp> + +namespace boost { namespace fusion +{ + struct mpl_sequence_tag; + + namespace extension + { + template <typename Tag> + struct has_key_impl; + + template <> + struct has_key_impl<mpl_sequence_tag> + { + template <typename Sequence, typename Key> + struct apply : mpl::has_key<Sequence, Key> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/detail/is_sequence_impl.hpp b/boost/fusion/adapted/mpl/detail/is_sequence_impl.hpp new file mode 100644 index 0000000000..2c6c5f988b --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/is_sequence_impl.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_31122005_1505) +#define BOOST_FUSION_IS_SEQUENCE_IMPL_31122005_1505 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct mpl_sequence_tag; + + namespace extension + { + template<typename Tag> + struct is_sequence_impl; + + template<> + struct is_sequence_impl<mpl_sequence_tag> + { + template<typename T> + struct apply : mpl::true_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/detail/is_view_impl.hpp b/boost/fusion/adapted/mpl/detail/is_view_impl.hpp new file mode 100644 index 0000000000..bd9b7a4211 --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/is_view_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_03202006_0048) +#define BOOST_FUSION_IS_VIEW_IMPL_03202006_0048 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct mpl_sequence_tag; + + namespace extension + { + template<typename Tag> + struct is_view_impl; + + template<> + struct is_view_impl<mpl_sequence_tag> + { + template<typename T> + struct apply : mpl::true_ + {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/detail/size_impl.hpp b/boost/fusion/adapted/mpl/detail/size_impl.hpp new file mode 100644 index 0000000000..38168724d4 --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/size_impl.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_31122005_1508) +#define BOOST_FUSION_SIZE_IMPL_31122005_1508 + +#include <boost/mpl/size.hpp> + +namespace boost { namespace fusion +{ + struct mpl_sequence_tag; + + namespace extension + { + template<typename Tag> + struct size_impl; + + template <> + struct size_impl<mpl_sequence_tag> + { + template <typename Sequence> + struct apply : mpl::size<Sequence> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/detail/value_at_impl.hpp b/boost/fusion/adapted/mpl/detail/value_at_impl.hpp new file mode 100644 index 0000000000..5560b82717 --- /dev/null +++ b/boost/fusion/adapted/mpl/detail/value_at_impl.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_31122005_1621) +#define BOOST_FUSION_VALUE_AT_IMPL_31122005_1621 + +#include <boost/mpl/at.hpp> + +namespace boost { namespace fusion +{ + struct mpl_sequence_tag; + + namespace extension + { + template <typename Tag> + struct value_at_impl; + + template <> + struct value_at_impl<mpl_sequence_tag> + { + template <typename Sequence, typename N> + struct apply : mpl::at<Sequence, N> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/mpl/mpl_iterator.hpp b/boost/fusion/adapted/mpl/mpl_iterator.hpp new file mode 100644 index 0000000000..7caa8ea728 --- /dev/null +++ b/boost/fusion/adapted/mpl/mpl_iterator.hpp @@ -0,0 +1,113 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_MPL_ITERATOR_05052005_0731) +#define FUSION_MPL_ITERATOR_05052005_0731 + +#include <boost/fusion/support/detail/mpl_iterator_category.hpp> +#include <boost/fusion/iterator/iterator_facade.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/mpl/deref.hpp> +#include <boost/mpl/next.hpp> +#include <boost/mpl/prior.hpp> +#include <boost/mpl/advance.hpp> +#include <boost/mpl/distance.hpp> + +namespace boost { namespace fusion +{ + template <typename Iterator_> + struct mpl_iterator + : iterator_facade< + mpl_iterator<Iterator_> + , typename detail::mpl_iterator_category<typename Iterator_::category>::type + > + { + typedef typename remove_const<Iterator_>::type iterator_type; + + template <typename Iterator> + struct value_of : mpl::deref<typename Iterator::iterator_type> {}; + + template <typename Iterator> + struct deref + { + typedef typename mpl::deref< + typename Iterator::iterator_type>::type + type; + + static type + call(Iterator) + { + return type(); + } + }; + + template <typename Iterator> + struct next + { + typedef mpl_iterator< + typename mpl::next<typename Iterator::iterator_type>::type> + type; + + static type + call(Iterator) + { + return type(); + } + }; + + template <typename Iterator> + struct prior + { + typedef mpl_iterator< + typename mpl::prior<typename Iterator::iterator_type>::type> + type; + + static type + call(Iterator) + { + return type(); + } + }; + + template <typename Iterator, typename N> + struct advance + { + typedef mpl_iterator< + typename mpl::advance<typename Iterator::iterator_type, N>::type> + type; + + static type + call(Iterator const& /*i*/) + { + return type(); + } + }; + + template <typename I1, typename I2> + struct distance : + mpl::distance< + typename I1::iterator_type + , typename I2::iterator_type> + { + typedef typename + mpl::distance< + typename I1::iterator_type + , typename I2::iterator_type + >::type + type; + + static type + call(I1 const&, I2 const&) + { + return type(); + } + }; + }; +}} + +#endif + + diff --git a/boost/fusion/adapted/std_pair.hpp b/boost/fusion/adapted/std_pair.hpp new file mode 100644 index 0000000000..4263e00c98 --- /dev/null +++ b/boost/fusion/adapted/std_pair.hpp @@ -0,0 +1,19 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STD_PAIR_HPP +#define BOOST_FUSION_ADAPTED_STD_PAIR_HPP + +#include <boost/fusion/adapted/struct/adapt_struct.hpp> +#include <utility> + +BOOST_FUSION_ADAPT_TPL_STRUCT( + (T1)(T2),(std::pair)(T1)(T2),(T1, first)(T2, second)) + +#endif diff --git a/boost/fusion/adapted/std_tuple.hpp b/boost/fusion/adapted/std_tuple.hpp new file mode 100644 index 0000000000..a49b4807d4 --- /dev/null +++ b/boost/fusion/adapted/std_tuple.hpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_BOOST_TUPLE_09242011_1744) +#define BOOST_FUSION_BOOST_TUPLE_09242011_1744 + +#include <boost/fusion/adapted/std_tuple/detail/is_view_impl.hpp> +#include <boost/fusion/adapted/std_tuple/detail/is_sequence_impl.hpp> +#include <boost/fusion/adapted/std_tuple/detail/category_of_impl.hpp> +#include <boost/fusion/adapted/std_tuple/detail/begin_impl.hpp> +#include <boost/fusion/adapted/std_tuple/detail/end_impl.hpp> +#include <boost/fusion/adapted/std_tuple/detail/size_impl.hpp> +#include <boost/fusion/adapted/std_tuple/detail/at_impl.hpp> +#include <boost/fusion/adapted/std_tuple/detail/value_at_impl.hpp> +#include <boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp> +#include <boost/fusion/adapted/std_tuple/tag_of.hpp> + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/at_impl.hpp b/boost/fusion/adapted/std_tuple/detail/at_impl.hpp new file mode 100644 index 0000000000..2f09719ca7 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/at_impl.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_AT_IMPL_09242011_1744) +#define BOOST_FUSION_AT_IMPL_09242011_1744 + +#include <tuple> +#include <utility> +#include <boost/mpl/eval_if.hpp> +#include <boost/fusion/support/detail/access.hpp> +#include <boost/type_traits/remove_const.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct at_impl; + + template <> + struct at_impl<std_tuple_tag> + { + template <typename Sequence, typename N> + struct apply + { + typedef typename remove_const<Sequence>::type seq_type; + typedef std::tuple_element<N::value, seq_type> element; + + typedef typename + mpl::eval_if< + is_const<Sequence> + , fusion::detail::cref_result<element> + , fusion::detail::ref_result<element> + >::type + type; + + static type + call(Sequence& seq) + { + return std::get<N::value>(seq); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/begin_impl.hpp b/boost/fusion/adapted/std_tuple/detail/begin_impl.hpp new file mode 100644 index 0000000000..8b219024b8 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/begin_impl.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_BEGIN_IMPL_09242011_1744) +#define BOOST_FUSION_BEGIN_IMPL_09242011_1744 + +#include <boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct begin_impl; + + template <> + struct begin_impl<std_tuple_tag> + { + template <typename Sequence> + struct apply + { + typedef std_tuple_iterator<Sequence, 0> type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/category_of_impl.hpp b/boost/fusion/adapted/std_tuple/detail/category_of_impl.hpp new file mode 100644 index 0000000000..96d567d5e9 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/category_of_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_CATEGORY_OF_IMPL_09272006_0726) +#define BOOST_FUSION_CATEGORY_OF_IMPL_09272006_0726 + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + struct random_access_traversal_tag; + + namespace extension + { + template<typename T> + struct category_of_impl; + + template<> + struct category_of_impl<std_tuple_tag> + { + template<typename T> + struct apply + { + typedef random_access_traversal_tag type; + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/end_impl.hpp b/boost/fusion/adapted/std_tuple/detail/end_impl.hpp new file mode 100644 index 0000000000..78782b7943 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/end_impl.hpp @@ -0,0 +1,43 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_END_IMPL_09242011_1744) +#define BOOST_FUSION_END_IMPL_09242011_1744 + +#include <boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <tuple> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct end_impl; + + template <> + struct end_impl<std_tuple_tag> + { + template <typename Sequence> + struct apply + { + typedef typename remove_const<Sequence>::type seq_type; + static int const size = std::tuple_size<seq_type>::value; + typedef std_tuple_iterator<Sequence, size> type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/is_sequence_impl.hpp b/boost/fusion/adapted/std_tuple/detail/is_sequence_impl.hpp new file mode 100644 index 0000000000..6da5bdc34d --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/is_sequence_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_IS_SEQUENCE_IMPL_09242011_1744) +#define BOOST_FUSION_IS_SEQUENCE_IMPL_09242011_1744 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename Tag> + struct is_sequence_impl; + + template<> + struct is_sequence_impl<std_tuple_tag> + { + template<typename Sequence> + struct apply : mpl::true_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/is_view_impl.hpp b/boost/fusion/adapted/std_tuple/detail/is_view_impl.hpp new file mode 100644 index 0000000000..9439431b5a --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/is_view_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_IS_VIEW_IMPL_09242011_1744) +#define BOOST_FUSION_IS_VIEW_IMPL_09242011_1744 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename Tag> + struct is_view_impl; + + template<> + struct is_view_impl<std_tuple_tag> + { + template<typename T> + struct apply : mpl::false_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/size_impl.hpp b/boost/fusion/adapted/std_tuple/detail/size_impl.hpp new file mode 100644 index 0000000000..d8b10af1ef --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/size_impl.hpp @@ -0,0 +1,36 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_SIZE_IMPL_09242011_1744) +#define BOOST_FUSION_SIZE_IMPL_09242011_1744 + +#include <tuple> +#include <boost/mpl/int.hpp> +#include <boost/type_traits/remove_const.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct size_impl; + + template <> + struct size_impl<std_tuple_tag> + { + template <typename Sequence> + struct apply : + mpl::int_<std::tuple_size< + typename remove_const<Sequence>::type>::value + > + {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/value_at_impl.hpp b/boost/fusion/adapted/std_tuple/detail/value_at_impl.hpp new file mode 100644 index 0000000000..fa9656e7b2 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/value_at_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_VALUE_AT_IMPL_09242011_1744) +#define BOOST_FUSION_VALUE_AT_IMPL_09242011_1744 + +#include <tuple> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct value_at_impl; + + template <> + struct value_at_impl<std_tuple_tag> + { + template <typename Sequence, typename N> + struct apply : std::tuple_element<N::value, Sequence> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp b/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp new file mode 100644 index 0000000000..4998e21d1a --- /dev/null +++ b/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp @@ -0,0 +1,107 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_TUPLE_ITERATOR_09112011_1905) +#define FUSION_STD_TUPLE_ITERATOR_09112011_1905 + +#include <boost/fusion/iterator/iterator_facade.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/fusion/support/detail/access.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/eval_if.hpp> +#include <tuple> +#include <utility> + +namespace boost { namespace fusion +{ + struct random_access_traversal_tag; + + template <typename Tuple, int Index> + struct std_tuple_iterator_identity; + + template <typename Tuple, int Index> + struct std_tuple_iterator + : iterator_facade< + std_tuple_iterator<Tuple, Index> + , random_access_traversal_tag> + { + typedef Tuple tuple_type; + static int const index = Index; + typedef std_tuple_iterator_identity< + typename add_const<Tuple>::type, Index> + identity; + + explicit std_tuple_iterator(Tuple& tuple) + : tuple(tuple) {} + + Tuple& tuple; + + template <typename Iterator> + struct value_of + : std::tuple_element<Iterator::index, + typename remove_const<typename Iterator::tuple_type>::type> {}; + + template <typename Iterator> + struct deref + { + typedef value_of<Iterator> element; + typedef typename + mpl::eval_if< + is_const<typename Iterator::tuple_type> + , fusion::detail::cref_result<element> + , fusion::detail::ref_result<element> + >::type + type; + + static type + call(Iterator const& iter) + { + return std::get<Index>(iter.tuple); + } + }; + + template <typename Iterator, typename N> + struct advance + { + static int const index = Iterator::index; + typedef typename Iterator::tuple_type tuple_type; + typedef std_tuple_iterator<tuple_type, index+N::value> type; + + static type + call(Iterator const& i) + { + return type(i.tuple); + } + }; + + template <typename Iterator> + struct next : advance<Iterator, mpl::int_<1>> {}; + + template <typename Iterator> + struct prior : advance<Iterator, mpl::int_<-1>> {}; + + template <typename I1, typename I2> + struct equal_to + : is_same<typename I1::identity, typename I2::identity> {}; + + template <typename First, typename Last> + struct distance + { + typedef mpl::int_<Last::index-First::index> type; + + static type + call(First const&, Last const&) + { + return type(); + } + }; + }; +}} + +#endif + + diff --git a/boost/fusion/adapted/std_tuple/tag_of.hpp b/boost/fusion/adapted/std_tuple/tag_of.hpp new file mode 100644 index 0000000000..10e2e18142 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/tag_of.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2001-2011 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(BOOST_FUSION_TAG_OF_09112011_1842) +#define BOOST_FUSION_TAG_OF_09112011_1842 + +#include <tuple> +#include <boost/fusion/support/tag_of_fwd.hpp> + +namespace std +{ + template <typename... Elements> + class tuple; +} + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + struct fusion_sequence_tag; + + namespace traits + { + template <typename... Elements> + struct tag_of<std::tuple<Elements...>> + { + typedef std_tuple_tag type; + }; + } +}} + +namespace boost { namespace mpl +{ + template <typename> + struct sequence_tag; + + template <typename... Elements> + struct sequence_tag<std::tuple<Elements...>> + { + typedef fusion::fusion_sequence_tag type; + }; + + template <typename... Elements> + struct sequence_tag<std::tuple<Elements...> const> + { + typedef fusion::fusion_sequence_tag type; + }; +}} + +#endif diff --git a/boost/fusion/adapted/struct.hpp b/boost/fusion/adapted/struct.hpp new file mode 100644 index 0000000000..acc12e692b --- /dev/null +++ b/boost/fusion/adapted/struct.hpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STRUCT_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_HPP + +#include <boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp> +#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp> +#include <boost/fusion/adapted/struct/adapt_struct_named.hpp> +#include <boost/fusion/adapted/struct/adapt_struct.hpp> +#include <boost/fusion/adapted/struct/define_assoc_struct.hpp> +#include <boost/fusion/adapted/struct/define_struct.hpp> + +#endif diff --git a/boost/fusion/adapted/struct/adapt_assoc_struct.hpp b/boost/fusion/adapted/struct/adapt_assoc_struct.hpp new file mode 100644 index 0000000000..755bffd1c6 --- /dev/null +++ b/boost/fusion/adapted/struct/adapt_assoc_struct.hpp @@ -0,0 +1,96 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2007 Dan Marsden + Copyright (c) 2009-2011 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_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_ASSOC_STRUCT_HPP + +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/empty.hpp> +#include <boost/preprocessor/tuple/elem.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/type_traits/remove_const.hpp> + +#include <boost/fusion/adapted/struct/detail/extension.hpp> +#include <boost/fusion/adapted/struct/detail/adapt_base.hpp> +#include <boost/fusion/adapted/struct/detail/at_impl.hpp> +#include <boost/fusion/adapted/struct/detail/is_view_impl.hpp> +#include <boost/fusion/adapted/struct/detail/is_sequence_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_at_impl.hpp> +#include <boost/fusion/adapted/struct/detail/category_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/size_impl.hpp> +#include <boost/fusion/adapted/struct/detail/begin_impl.hpp> +#include <boost/fusion/adapted/struct/detail/end_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/deref_impl.hpp> +#include <boost/fusion/adapted/struct/detail/deref_data_impl.hpp> +#include <boost/fusion/adapted/struct/detail/key_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_of_data_impl.hpp> + +#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 + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,PREFIX,ATTRIBUTE) \ + \ + BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, PREFIX, ATTRIBUTE, 3) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_assoc_key<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ), I> \ + { \ + 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, \ + 0, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,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, \ + 0, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_C) + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_AS_VIEW(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + assoc_struct_tag, \ + 1, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_C) + +#endif diff --git a/boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp b/boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp new file mode 100644 index 0000000000..92c3aa3e30 --- /dev/null +++ b/boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2010-2011 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 <boost/fusion/adapted/struct/adapt_assoc_struct.hpp> +#include <boost/fusion/adapted/struct/detail/proxy_type.hpp> + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_FILLER_0(X, Y, Z) \ + (X, obj.Y, Z) BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_FILLER_1 +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_FILLER_1(X, Y, Z) \ + (X, obj.Y, Z) BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_FILLER_0 +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_FILLER_0_END +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_FILLER_1_END + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \ + WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \ + \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_AS_VIEW( \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ)NAME, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_FILLER_0 ATTRIBUTES, \ + _END)) + +#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/boost/fusion/adapted/struct/adapt_struct.hpp b/boost/fusion/adapted/struct/adapt_struct.hpp new file mode 100644 index 0000000000..f20533c99e --- /dev/null +++ b/boost/fusion/adapted/struct/adapt_struct.hpp @@ -0,0 +1,71 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2009-2011 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_STRUCT_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_HPP + +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/empty.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/type_traits/remove_const.hpp> + +#include <boost/fusion/adapted/struct/detail/extension.hpp> +#include <boost/fusion/adapted/struct/detail/adapt_base.hpp> +#include <boost/fusion/adapted/struct/detail/at_impl.hpp> +#include <boost/fusion/adapted/struct/detail/is_view_impl.hpp> +#include <boost/fusion/adapted/struct/detail/is_sequence_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_at_impl.hpp> +#include <boost/fusion/adapted/struct/detail/category_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/size_impl.hpp> +#include <boost/fusion/adapted/struct/detail/begin_impl.hpp> +#include <boost/fusion/adapted/struct/detail/end_impl.hpp> +#include <boost/fusion/adapted/struct/detail/value_of_impl.hpp> +#include <boost/fusion/adapted/struct/detail/deref_impl.hpp> + +#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_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_TPL_STRUCT(TEMPLATE_PARAMS_SEQ,NAME_SEQ, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (1)TEMPLATE_PARAMS_SEQ, \ + (1)NAME_SEQ, \ + struct_tag, \ + 0, \ + ((0,0)) BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_STRUCT_FILLER_0 ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_STRUCT_C) + +#define BOOST_FUSION_ADAPT_STRUCT(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + struct_tag, \ + 0, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_STRUCT_C) + +#define BOOST_FUSION_ADAPT_STRUCT_AS_VIEW(NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + struct_tag, \ + 1, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_ADAPT_STRUCT_C) + +#endif diff --git a/boost/fusion/adapted/struct/adapt_struct_named.hpp b/boost/fusion/adapted/struct/adapt_struct_named.hpp new file mode 100644 index 0000000000..17a3d8e3ca --- /dev/null +++ b/boost/fusion/adapted/struct/adapt_struct_named.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2009-2010 Hartmut Kaiser + Copyright (c) 2010-2011 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_STRUCT_NAMED_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_NAMED_HPP + +#include <boost/fusion/adapted/struct/adapt_struct.hpp> +#include <boost/fusion/adapted/struct/detail/proxy_type.hpp> +#include <boost/preprocessor/empty.hpp> + +#define BOOST_FUSION_ADAPT_STRUCT_NAMED_FILLER_0(X, Y) \ + (X, obj.Y) BOOST_FUSION_ADAPT_STRUCT_NAMED_FILLER_1 +#define BOOST_FUSION_ADAPT_STRUCT_NAMED_FILLER_1(X, Y) \ + (X, obj.Y) BOOST_FUSION_ADAPT_STRUCT_NAMED_FILLER_0 +#define BOOST_FUSION_ADAPT_STRUCT_NAMED_FILLER_0_END +#define BOOST_FUSION_ADAPT_STRUCT_NAMED_FILLER_1_END + +#define BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \ + WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \ + \ + BOOST_FUSION_ADAPT_STRUCT_AS_VIEW( \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ)NAME, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_STRUCT_NAMED_FILLER_0 ATTRIBUTES,_END)) + +#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/boost/fusion/adapted/struct/define_assoc_struct.hpp b/boost/fusion/adapted/struct/define_assoc_struct.hpp new file mode 100644 index 0000000000..9d264e4085 --- /dev/null +++ b/boost/fusion/adapted/struct/define_assoc_struct.hpp @@ -0,0 +1,43 @@ +/*============================================================================= + Copyright (c) 2010-2011 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_DEFINE_ASSOC_STRUCT_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DEFINE_ASSOC_STRUCT_HPP + +#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp> +#include <boost/fusion/adapted/struct/detail/define_struct.hpp> + +#define BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT( \ + TEMPLATE_PARAMS_SEQ, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_DEFINE_TPL_STRUCT_IMPL( \ + TEMPLATE_PARAMS_SEQ, \ + (0)NAMESPACE_SEQ, \ + NAME, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ + 3) \ + \ + BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( \ + TEMPLATE_PARAMS_SEQ, \ + (BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ) NAME)\ + TEMPLATE_PARAMS_SEQ, \ + ATTRIBUTES) + +#define BOOST_FUSION_DEFINE_ASSOC_STRUCT(NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + BOOST_FUSION_DEFINE_STRUCT_IMPL( \ + (0)NAMESPACE_SEQ, \ + NAME, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ + 3) \ + \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT( \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ) NAME, \ + ATTRIBUTES) + +#endif diff --git a/boost/fusion/adapted/struct/define_struct.hpp b/boost/fusion/adapted/struct/define_struct.hpp new file mode 100644 index 0000000000..b733115ac0 --- /dev/null +++ b/boost/fusion/adapted/struct/define_struct.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2010-2011 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_DEFINE_STRUCT_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DEFINE_STRUCT_HPP + +#include <boost/fusion/adapted/struct/adapt_struct.hpp> +#include <boost/fusion/adapted/struct/detail/define_struct.hpp> + +#define BOOST_FUSION_DEFINE_TPL_STRUCT( \ + TEMPLATE_PARAMS_SEQ, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + \ + BOOST_FUSION_DEFINE_TPL_STRUCT_IMPL( \ + TEMPLATE_PARAMS_SEQ, \ + (0)NAMESPACE_SEQ, \ + NAME, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ + 2) \ + \ + BOOST_FUSION_ADAPT_TPL_STRUCT( \ + TEMPLATE_PARAMS_SEQ, \ + (BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ) NAME)\ + TEMPLATE_PARAMS_SEQ, \ + ATTRIBUTES) + +#define BOOST_FUSION_DEFINE_STRUCT(NAMESPACE_SEQ, NAME, ATTRIBUTES) \ + BOOST_FUSION_DEFINE_STRUCT_IMPL( \ + (0)NAMESPACE_SEQ, \ + NAME, \ + BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ + 2) \ + \ + BOOST_FUSION_ADAPT_STRUCT( \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ) NAME, \ + ATTRIBUTES) + +#endif diff --git a/boost/fusion/adapted/struct/detail/adapt_base.hpp b/boost/fusion/adapted/struct/detail/adapt_base.hpp new file mode 100644 index 0000000000..1c8f040850 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/adapt_base.hpp @@ -0,0 +1,245 @@ +/*============================================================================= + Copyright (c) 2001-2009 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2009-2011 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_DETAIL_ADAPT_BASE_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_HPP + +#include <boost/config.hpp> +#include <boost/fusion/support/tag_of_fwd.hpp> + +#include <boost/preprocessor/empty.hpp> +#include <boost/preprocessor/stringize.hpp> +#include <boost/preprocessor/control/if.hpp> +#include <boost/preprocessor/seq/size.hpp> +#include <boost/preprocessor/seq/for_each.hpp> +#include <boost/preprocessor/seq/for_each_i.hpp> +#include <boost/preprocessor/seq/enum.hpp> +#include <boost/preprocessor/seq/seq.hpp> +#include <boost/preprocessor/tuple/eat.hpp> +#include <boost/preprocessor/tuple/elem.hpp> +#include <boost/preprocessor/arithmetic/dec.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/tag.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/type_traits/add_const.hpp> + +#define BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME_TEMPLATE_PARAMS(SEQ) \ + BOOST_PP_SEQ_HEAD(SEQ)<BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TAIL(SEQ))> \ + BOOST_PP_EMPTY() + +#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<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) MODIFIER> \ + { \ + 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) + +#ifdef BOOST_MSVC +# define BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAM(R,_,ELEM) \ + typedef ELEM ELEM; +# define BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS_IMPL(SEQ) \ + BOOST_PP_SEQ_FOR_EACH( \ + BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAM, \ + _, \ + BOOST_PP_SEQ_TAIL(SEQ)) +# define BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS(SEQ) \ + BOOST_PP_IF( \ + BOOST_PP_SEQ_HEAD(SEQ), \ + BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS_IMPL, \ + BOOST_PP_TUPLE_EAT(1))(SEQ) +#else +# define BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS(SEQ) +#endif + +#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 access::struct_member< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + > \ + { \ + typedef \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \ + attribute_type; \ + BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + \ + typedef attribute_type type; \ + \ + template<typename Seq> \ + struct apply \ + { \ + typedef typename \ + add_reference< \ + typename mpl::eval_if< \ + is_const<Seq> \ + , add_const<attribute_type> \ + , mpl::identity<attribute_type> \ + >::type \ + >::type \ + type; \ + \ + static type \ + call(Seq& seq) \ + { \ + return seq.PREFIX() \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE); \ + } \ + }; \ + }; \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_member_name< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + > \ + { \ + typedef char const* type; \ + \ + static type \ + call() \ + { \ + return BOOST_PP_STRINGIZE( \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)); \ + } \ + }; + +#define BOOST_FUSION_ADAPT_STRUCT_BASE( \ + TEMPLATE_PARAMS_SEQ, \ + NAME_SEQ, \ + TAG, \ + IS_VIEW, \ + 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_IF( \ + BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)), \ + BOOST_PP_SEQ_FOR_EACH_I_R, \ + BOOST_PP_TUPLE_EAT(4))( \ + 1, \ + BOOST_FUSION_ADAPT_STRUCT_BASE_UNPACK_AND_CALL, \ + (ATTRIBUTES_CALLBACK,TEMPLATE_PARAMS_SEQ,NAME_SEQ), \ + BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ)) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_size<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)> \ + : mpl::int_<BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ))> \ + {}; \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + > \ + struct struct_is_view< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + > \ + : mpl::BOOST_PP_IF(IS_VIEW,true_,false_) \ + {}; \ + } \ + } \ + \ + namespace mpl \ + { \ + template<typename> \ + struct sequence_tag; \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + > \ + struct sequence_tag<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)> \ + { \ + 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/boost/fusion/adapted/struct/detail/at_impl.hpp b/boost/fusion/adapted/struct/detail/at_impl.hpp new file mode 100644 index 0000000000..68fd241a88 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/at_impl.hpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STRUCT_DETAIL_AT_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_AT_IMPL_HPP + +#include <boost/mpl/int.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct at_impl; + + template <> + struct at_impl<struct_tag> + { + template <typename Seq, typename N> + struct apply + : access::struct_member< + typename remove_const<Seq>::type + , N::value + >::template apply<Seq> + {}; + }; + + template <> + struct at_impl<assoc_struct_tag> + : at_impl<struct_tag> + {}; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/begin_impl.hpp b/boost/fusion/adapted/struct/detail/begin_impl.hpp new file mode 100644 index 0000000000..a7901fcad5 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/begin_impl.hpp @@ -0,0 +1,67 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STRUCT_DETAIL_BEGIN_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_BEGIN_IMPL_HPP + +#include <boost/fusion/iterator/basic_iterator.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct begin_impl; + + template <> + struct begin_impl<struct_tag> + { + template <typename Seq> + struct apply + { + typedef + basic_iterator< + struct_iterator_tag + , random_access_traversal_tag + , Seq + , 0 + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; + + template <> + struct begin_impl<assoc_struct_tag> + { + template <typename Seq> + struct apply + { + typedef + basic_iterator< + struct_iterator_tag + , assoc_struct_category + , Seq + , 0 + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/category_of_impl.hpp b/boost/fusion/adapted/struct/detail/category_of_impl.hpp new file mode 100644 index 0000000000..b98e824202 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/category_of_impl.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STRUCT_DETAIL_CATEGORY_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_CATEGORY_OF_IMPL_HPP + +namespace boost { namespace fusion +{ + namespace extension + { + template<typename> + struct category_of_impl; + + template<> + struct category_of_impl<struct_tag> + { + template<typename Seq> + struct apply + { + typedef random_access_traversal_tag type; + }; + }; + + template<> + struct category_of_impl<assoc_struct_tag> + { + template<typename Seq> + struct apply + { + typedef assoc_struct_category type; + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/define_struct.hpp b/boost/fusion/adapted/struct/detail/define_struct.hpp new file mode 100644 index 0000000000..53f1e5d646 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/define_struct.hpp @@ -0,0 +1,353 @@ +/*============================================================================= + Copyright (c) 2010-2011 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_DEFINE_STRUCT_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEFINE_STRUCT_HPP + +#include <boost/config.hpp> +#include <boost/fusion/sequence/intrinsic/begin.hpp> +#include <boost/fusion/iterator/deref.hpp> +#include <boost/fusion/iterator/next.hpp> +#include <boost/fusion/iterator/advance.hpp> +#include <boost/fusion/adapted/struct/detail/adapt_base.hpp> +#include <boost/fusion/adapted/struct/detail/namespace.hpp> +#include <boost/preprocessor/inc.hpp> +#include <boost/preprocessor/if.hpp> +#include <boost/preprocessor/expr_if.hpp> +#include <boost/preprocessor/dec.hpp> +#include <boost/preprocessor/logical/not.hpp> +#include <boost/preprocessor/punctuation/comma_if.hpp> +#include <boost/preprocessor/comparison/equal.hpp> +#include <boost/preprocessor/seq/seq.hpp> +#include <boost/preprocessor/seq/for_each.hpp> +#include <boost/preprocessor/seq/for_each_i.hpp> +#include <boost/preprocessor/seq/enum.hpp> +#include <boost/preprocessor/seq/size.hpp> +#include <boost/preprocessor/tuple/elem.hpp> +#include <boost/preprocessor/tuple/eat.hpp> +#include <boost/call_traits.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include <boost/utility/enable_if.hpp> + +#define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I( \ + R, ATTRIBUTE_TUPEL_SIZE, I, ATTRIBUTE) \ + \ + BOOST_PP_COMMA_IF(I) \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)( \ + other_self.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)) + +#define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I( \ + R, ATTRIBUTE_TUPEL_SIZE, I_, ATTRIBUTE) \ + \ + BOOST_PP_EXPR_IF( \ + I_, \ + typedef typename \ + boost::fusion::result_of::next< \ + BOOST_PP_CAT(I,BOOST_PP_DEC(I_)) \ + >::type \ + BOOST_PP_CAT(I,I_); \ + BOOST_PP_CAT(I,I_) BOOST_PP_CAT(i,I_)= \ + boost::fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(I_))); \ + ) \ + \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)= \ + boost::fusion::deref(BOOST_PP_CAT(i,I_)); + +#define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_OP( \ + ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + template<typename Seq> \ + self_type& \ + operator=(Seq const& seq) \ + { \ + typedef typename \ + boost::fusion::result_of::begin<Seq const>::type \ + I0; \ + I0 i0=boost::fusion::begin(seq); \ + \ + BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I, \ + ATTRIBUTE_TUPEL_SIZE, \ + ATTRIBUTES_SEQ) \ + \ + return *this; \ + } + +#define BOOST_FUSION_DEFINE_STRUCT_ATTR_I(R, ATTRIBUTE_TUPEL_SIZE, ATTRIBUTE) \ + \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,0,ATTRIBUTE) \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE); + +#define BOOST_FUSION_DEFINE_STRUCT_SEQ_CTOR_FILLER_I( \ + R, ATTRIBUTE_TUPEL_SIZE, I, ATTRIBUTE) \ + \ + BOOST_PP_COMMA_IF(I) \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)( \ + boost::fusion::deref(boost::fusion::advance_c<I>(boost::fusion::begin( \ + seq)))) + +#define BOOST_FUSION_DEFINE_STRUCT_SEQ_CTOR_DISABLER( \ + ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + , typename boost::disable_if< \ + boost::is_convertible< \ + Seq const& \ + , BOOST_PP_TUPLE_ELEM( \ + ATTRIBUTE_TUPEL_SIZE, \ + 0, \ + BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ)) \ + > \ + >::type* =0 + +#define BOOST_FUSION_DEFINE_STRUCT_SEQ_DEFAULT_CTOR_FILLER_I( \ + R, ATTRIBUTE_TUPEL_SIZE, I, ATTRIBUTE) \ + \ + BOOST_PP_COMMA_IF(I) \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)() + +#define BOOST_FUSION_DEFINE_STRUCT_IMPL_IMPL( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_PP_SEQ_FOR_EACH_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_ATTR_I, \ + ATTRIBUTE_TUPEL_SIZE, \ + ATTRIBUTES_SEQ) \ + \ + NAME() \ + : BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_SEQ_DEFAULT_CTOR_FILLER_I, \ + ATTRIBUTE_TUPEL_SIZE, \ + ATTRIBUTES_SEQ) \ + {} \ + \ + NAME(self_type const& other_self) \ + : BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I, \ + ATTRIBUTE_TUPEL_SIZE, \ + ATTRIBUTES_SEQ) \ + {} \ + \ + template<typename Seq> \ + NAME(Seq const& seq \ + BOOST_PP_IF( \ + BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)), \ + BOOST_PP_TUPLE_EAT(2), \ + BOOST_FUSION_DEFINE_STRUCT_SEQ_CTOR_DISABLER)( \ + ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + ) \ + : BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_SEQ_CTOR_FILLER_I, \ + ATTRIBUTE_TUPEL_SIZE, \ + ATTRIBUTES_SEQ) \ + {} \ + \ + BOOST_FUSION_DEFINE_STRUCT_ASSIGN_OP(ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) + +#define BOOST_FUSION_DEFINE_STRUCT_CTOR_1( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + explicit \ + NAME(boost::call_traits< \ + BOOST_PP_TUPLE_ELEM( \ + ATTRIBUTE_TUPEL_SIZE,0,BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ)) \ + >::param_type arg) \ + : BOOST_PP_TUPLE_ELEM( \ + ATTRIBUTE_TUPEL_SIZE,1,BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ))(arg) \ + {} + +#define BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_1( \ + TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + explicit \ + NAME(typename boost::call_traits< \ + typename boost::fusion::detail::get_first_arg< \ + BOOST_PP_TUPLE_ELEM( \ + ATTRIBUTE_TUPEL_SIZE, \ + 0, \ + BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ)) \ + , BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ) \ + >::type \ + >::param_type arg) \ + : BOOST_PP_TUPLE_ELEM( \ + ATTRIBUTE_TUPEL_SIZE,1,BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ))(arg) \ + {} + +#define BOOST_FUSION_DEFINE_STRUCT_CTOR_FILLER_I( \ + R, ATTRIBUTE_TUPEL_SIZE, I, ATTRIBUTE) \ + \ + BOOST_PP_COMMA_IF(I) \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)(BOOST_PP_CAT(_,I)) + +#define BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_ARG_I(R, DATA, I, ATTRIBUTE) \ + \ + BOOST_PP_COMMA_IF(I) \ + typename boost::call_traits< \ + typename boost::fusion::detail::get_first_arg< \ + BOOST_PP_TUPLE_ELEM( \ + BOOST_PP_TUPLE_ELEM(3,0,DATA), \ + 0, \ + ATTRIBUTE) \ + , BOOST_PP_TUPLE_ELEM(3,2,DATA) \ + >::type \ + >::param_type BOOST_PP_CAT(_,I) + +#define BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_N( \ + TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + NAME(BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_ARG_I, \ + ( \ + ATTRIBUTE_TUPEL_SIZE, \ + BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ), \ + BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ) \ + ), \ + ATTRIBUTES_SEQ)) \ + : BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_CTOR_FILLER_I, \ + ATTRIBUTE_TUPEL_SIZE, \ + ATTRIBUTES_SEQ) \ + {} + +#define BOOST_FUSION_DEFINE_STRUCT_CTOR_ARG_I( \ + R, ATTRIBUTE_TUPEL_SIZE, I, ATTRIBUTE) \ + \ + BOOST_PP_COMMA_IF(I) \ + boost::call_traits< \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,0,ATTRIBUTE) \ + >::param_type BOOST_PP_CAT(_,I) + +#define BOOST_FUSION_DEFINE_STRUCT_CTOR_N( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + NAME(BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_CTOR_ARG_I, \ + ATTRIBUTE_TUPEL_SIZE, \ + ATTRIBUTES_SEQ)) \ + : BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_CTOR_FILLER_I, \ + ATTRIBUTE_TUPEL_SIZE, \ + ATTRIBUTES_SEQ) \ + {} + +#define BOOST_FUSION_DEFINE_STRUCT_CTOR( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)), \ + BOOST_FUSION_DEFINE_STRUCT_CTOR_N, \ + BOOST_FUSION_DEFINE_STRUCT_CTOR_1)( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) + +#define BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR( \ + TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)), \ + BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_N, \ + BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_1)( \ + TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) + +#define BOOST_FUSION_DEFINE_NONEMPTY_STRUCT_IMPL( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_FUSION_DEFINE_STRUCT_IMPL_IMPL( \ + NAME, BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ), ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_FUSION_DEFINE_STRUCT_CTOR( \ + NAME, BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ), ATTRIBUTE_TUPEL_SIZE) + +#define BOOST_FUSION_DEFINE_EMPTY_STRUCT_IMPL( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + template<typename Seq> \ + NAME(Seq const&) \ + {} \ + \ + template<typename Seq> \ + self_type& \ + operator=(Seq const& seq) \ + { \ + return *this; \ + } + +#define BOOST_FUSION_DEFINE_STRUCT_IMPL( \ + NAMESPACE_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_BEGIN(NAMESPACE_SEQ) \ + \ + struct NAME \ + { \ + typedef NAME self_type; \ + \ + BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)), \ + BOOST_FUSION_DEFINE_NONEMPTY_STRUCT_IMPL, \ + BOOST_FUSION_DEFINE_EMPTY_STRUCT_IMPL)( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + }; \ + \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_END(NAMESPACE_SEQ) + +#define BOOST_FUSION_DEFINE_NONEMPTY_TPL_STRUCT_IMPL( \ + TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_FUSION_DEFINE_STRUCT_IMPL_IMPL( \ + NAME, BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ), ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR( \ + TEMPLATE_PARAMS_SEQ, \ + NAME, \ + BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ), \ + ATTRIBUTE_TUPEL_SIZE) + +#define BOOST_FUSION_DEFINE_EMPTY_TPL_STRUCT_IMPL( \ + TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_FUSION_DEFINE_EMPTY_STRUCT_IMPL( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) + +#define BOOST_FUSION_DEFINE_TPL_STRUCT_IMPL( \ + TEMPLATE_PARAMS_SEQ, \ + NAMESPACE_SEQ, \ + NAME, \ + ATTRIBUTES_SEQ, \ + ATTRIBUTE_TUPEL_SIZE) \ + \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_BEGIN(NAMESPACE_SEQ) \ + \ + template< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL( \ + (0)TEMPLATE_PARAMS_SEQ) \ + > \ + struct NAME \ + { \ + typedef NAME self_type; \ + \ + BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)), \ + BOOST_FUSION_DEFINE_NONEMPTY_TPL_STRUCT_IMPL, \ + BOOST_FUSION_DEFINE_EMPTY_TPL_STRUCT_IMPL)( \ + TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE)\ + }; \ + \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_END(NAMESPACE_SEQ) + +namespace boost { namespace fusion { namespace detail +{ + template<typename A1, typename A2> + struct get_first_arg + { + typedef A1 type; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/deref_data_impl.hpp b/boost/fusion/adapted/struct/detail/deref_data_impl.hpp new file mode 100644 index 0000000000..d3b6ced6c6 --- /dev/null +++ b/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_STRUCT_DETAIL_DEREF_DATA_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_DEREF_DATA_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template <typename> + struct deref_data_impl; + + template <> + struct deref_data_impl<struct_iterator_tag> + : deref_impl<struct_iterator_tag> + {}; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/deref_impl.hpp b/boost/fusion/adapted/struct/detail/deref_impl.hpp new file mode 100644 index 0000000000..3f25efef58 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/deref_impl.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + 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_STRUCT_DETAIL_DEREF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_DEREF_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template <typename> + struct deref_impl; + + template <> + struct deref_impl<struct_iterator_tag> + { + template <typename It> + struct apply + { + typedef typename + access::struct_member< + typename remove_const<typename It::seq_type>::type + , It::index::value + >::template apply<typename It::seq_type> + impl; + + typedef typename impl::type type; + + static + type + call(It const& it) + { + return impl::call(*it.seq); + } + }; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/end_impl.hpp b/boost/fusion/adapted/struct/detail/end_impl.hpp new file mode 100644 index 0000000000..0d09092957 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/end_impl.hpp @@ -0,0 +1,67 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STRUCT_DETAIL_END_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_END_IMPL_HPP + +#include <boost/fusion/iterator/basic_iterator.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template <typename> + struct end_impl; + + template <> + struct end_impl<struct_tag> + { + template <typename Seq> + struct apply + { + typedef + basic_iterator< + struct_iterator_tag + , random_access_traversal_tag + , Seq + , struct_size<typename remove_const<Seq>::type>::value + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; + + template <> + struct end_impl<assoc_struct_tag> + { + template <typename Seq> + struct apply + { + typedef + basic_iterator< + struct_iterator_tag + , assoc_struct_category + , Seq + , struct_size<typename remove_const<Seq>::type>::value + > + type; + + static type + call(Seq& seq) + { + return type(seq,0); + } + }; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/extension.hpp b/boost/fusion/adapted/struct/detail/extension.hpp new file mode 100644 index 0000000000..17edb89dca --- /dev/null +++ b/boost/fusion/adapted/struct/detail/extension.hpp @@ -0,0 +1,57 @@ +/*============================================================================= + 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_STRUCT_DETAIL_EXTENSION_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_EXTENSION_HPP + +#include <boost/fusion/support/category_of.hpp> + +namespace boost { namespace fusion +{ + struct struct_tag; + struct struct_iterator_tag; + struct assoc_struct_tag; + struct fusion_sequence_tag; + + struct assoc_struct_category + : random_access_traversal_tag, associative_tag + {}; + + namespace extension + { + struct no_such_member; + + struct access + { + template<typename Seq, int N> + struct struct_member; + + template<typename Seq, int N> + struct adt_attribute_access; + }; + + template <typename T, int N, bool Const> + struct adt_attribute_proxy; + + template<typename Seq, int N> + struct struct_member_name; + + template<typename Seq> + struct struct_size; + + template<typename Seq> + struct struct_is_view; + + template<typename Seq, int N> + struct struct_assoc_key; + + } +}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/is_sequence_impl.hpp b/boost/fusion/adapted/struct/detail/is_sequence_impl.hpp new file mode 100644 index 0000000000..c32222f8cf --- /dev/null +++ b/boost/fusion/adapted/struct/detail/is_sequence_impl.hpp @@ -0,0 +1,35 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STRUCT_DETAIL_IS_SEQUENCE_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_IS_SEQUENCE_IMPL_HPP + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct is_sequence_impl; + + template<> + struct is_sequence_impl<struct_tag> + { + template<typename Seq> + struct apply + : mpl::true_ + {}; + }; + + template <> + struct is_sequence_impl<assoc_struct_tag> + : is_sequence_impl<struct_tag> + {}; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/is_view_impl.hpp b/boost/fusion/adapted/struct/detail/is_view_impl.hpp new file mode 100644 index 0000000000..71d284077c --- /dev/null +++ b/boost/fusion/adapted/struct/detail/is_view_impl.hpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STRUCT_DETAIL_IS_VIEW_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_IS_VIEW_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct is_view_impl; + + template<> + struct is_view_impl<struct_tag> + { + template<typename Seq> + struct apply + : struct_is_view<typename remove_const<Seq>::type> + {}; + }; + + template <> + struct is_view_impl<assoc_struct_tag> + : is_view_impl<struct_tag> + {}; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/key_of_impl.hpp b/boost/fusion/adapted/struct/detail/key_of_impl.hpp new file mode 100644 index 0000000000..d24a24b1b3 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/key_of_impl.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + 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_STRUCT_DETAIL_KEY_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_KEY_OF_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template <typename> + struct key_of_impl; + + template <> + struct key_of_impl<struct_iterator_tag> + { + template <typename It> + struct apply + : extension::struct_assoc_key< + typename remove_const<typename It::seq_type>::type + , It::index::value + > + {}; + }; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/namespace.hpp b/boost/fusion/adapted/struct/detail/namespace.hpp new file mode 100644 index 0000000000..0f3ec5e0b1 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/namespace.hpp @@ -0,0 +1,51 @@ +/*============================================================================= + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_NAMESPACE_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_NAMESPACE_HPP + +#include <boost/preprocessor/dec.hpp> +#include <boost/preprocessor/control/if.hpp> +#include <boost/preprocessor/seq/seq.hpp> +#include <boost/preprocessor/seq/for_each.hpp> +#include <boost/preprocessor/seq/size.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/tuple/eat.hpp> + +#define BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_BEGIN_I(R,DATA,ELEM) \ + namespace ELEM { +#define BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_END_I(Z,I,DATA) } +#define BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION_I(Z,I,ELEM) ELEM:: + +#define BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_BEGIN(NAMESPACE_SEQ) \ + BOOST_PP_IF( \ + BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(NAMESPACE_SEQ)), \ + BOOST_PP_SEQ_FOR_EACH_R, \ + BOOST_PP_TUPLE_EAT(4))( \ + 1, \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_BEGIN_I, \ + _, \ + BOOST_PP_SEQ_TAIL(NAMESPACE_SEQ)) + +#define BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_END(NAMESPACE_SEQ) \ + BOOST_PP_REPEAT_1( \ + BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(NAMESPACE_SEQ)), \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_END_I, \ + _) + +#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_PP_TUPLE_EAT(4))( \ + 1, \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION_I, \ + _, \ + BOOST_PP_SEQ_TAIL(NAMESPACE_SEQ)) + +#endif diff --git a/boost/fusion/adapted/struct/detail/proxy_type.hpp b/boost/fusion/adapted/struct/detail/proxy_type.hpp new file mode 100644 index 0000000000..bf0a6ebd53 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/proxy_type.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_PROXY_TYPE_HPP +#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_PROXY_TYPE_HPP + +#include <boost/fusion/adapted/struct/detail/namespace.hpp> + +#define BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \ + WRAPPED_TYPE,NAMESPACE_SEQ,NAME) \ + \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_BEGIN(NAMESPACE_SEQ) \ + \ + struct NAME \ + { \ + NAME(WRAPPED_TYPE& in_obj) \ + : obj(in_obj) \ + {} \ + \ + WRAPPED_TYPE& obj; \ + \ + private: \ + NAME& operator= (NAME const&); \ + }; \ + \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_END(NAMESPACE_SEQ) + +#define BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME) \ + \ + BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \ + WRAPPED_TYPE, (0)NAMESPACE_SEQ, NAME) + +#endif diff --git a/boost/fusion/adapted/struct/detail/size_impl.hpp b/boost/fusion/adapted/struct/detail/size_impl.hpp new file mode 100644 index 0000000000..baf411bd00 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/size_impl.hpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STRUCT_DETAIL_SIZE_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_SIZE_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct size_impl; + + template <> + struct size_impl<struct_tag> + { + template <typename Seq> + struct apply + : struct_size<typename remove_const<Seq>::type> + {}; + }; + + template <> + struct size_impl<assoc_struct_tag> + : size_impl<struct_tag> + {}; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/value_at_impl.hpp b/boost/fusion/adapted/struct/detail/value_at_impl.hpp new file mode 100644 index 0000000000..f820475324 --- /dev/null +++ b/boost/fusion/adapted/struct/detail/value_at_impl.hpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2001-2011 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_STRUCT_DETAIL_VALUE_AT_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_VALUE_AT_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template<typename> + struct value_at_impl; + + template <> + struct value_at_impl<struct_tag> + { + template <typename Seq, typename N> + struct apply + : access::struct_member<typename remove_const<Seq>::type, N::value> + {}; + }; + + template <> + struct value_at_impl<assoc_struct_tag> + : value_at_impl<struct_tag> + {}; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/value_of_data_impl.hpp b/boost/fusion/adapted/struct/detail/value_of_data_impl.hpp new file mode 100644 index 0000000000..4528b854a4 --- /dev/null +++ b/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_STRUCT_DETAIL_VALUE_OF_DATA_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_VALUE_OF_DATA_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template <typename> + struct value_of_data_impl; + + template <> + struct value_of_data_impl<struct_iterator_tag> + : value_of_impl<struct_iterator_tag> + {}; +}}} + +#endif diff --git a/boost/fusion/adapted/struct/detail/value_of_impl.hpp b/boost/fusion/adapted/struct/detail/value_of_impl.hpp new file mode 100644 index 0000000000..63dcbe52ff --- /dev/null +++ b/boost/fusion/adapted/struct/detail/value_of_impl.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + 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_STRUCT_DETAIL_VALUE_OF_IMPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_VALUE_OF_IMPL_HPP + +namespace boost { namespace fusion { namespace extension +{ + template <typename> + struct value_of_impl; + + template <> + struct value_of_impl<struct_iterator_tag> + { + template <typename It> + struct apply + : access::struct_member< + typename remove_const<typename It::seq_type>::type + , It::index::value + > + {}; + }; +}}} + +#endif |