better adapt structs/classes implementation

[SVN r59913]
This commit is contained in:
Christopher Schmidt
2010-02-25 20:10:37 +00:00
parent f84bc30bd3
commit e67765747d
39 changed files with 266 additions and 701 deletions

View File

@ -13,6 +13,10 @@
#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>

View File

@ -11,6 +11,10 @@
#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>

View File

@ -1,4 +1,6 @@
/*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
Copyright (c) 2009-2010 Hartmut Kaiser
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying

View File

@ -1,16 +1,20 @@
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2009-2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_ADAPT_BASE_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_ADAPT_BASE_HPP
#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>
@ -20,11 +24,14 @@
#include <boost/preprocessor/tuple/eat.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/mpl/tag.hpp>
#include <boost/type_traits/add_reference.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_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), \
@ -47,7 +54,7 @@
#ifdef BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS
# define BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \
MODIFIER, TEMPLATE_PARAMS_SEQ,NAME_SEQ,TAG) \
MODIFIER, TEMPLATE_PARAMS_SEQ, NAME_SEQ, TAG) \
\
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
@ -61,7 +68,7 @@
};
#else
# define BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \
MODIFIER, TEMPLATE_PARAMS_SEQ,NAME_SEQ,TAG) \
MODIFIER, TEMPLATE_PARAMS_SEQ, NAME_SEQ, TAG) \
\
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
@ -90,19 +97,46 @@
typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \
\
template<typename Seq> \
static typename add_reference<type>::type \
call(Seq& seq) \
struct apply \
{ \
return seq.PREFIX \
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE); \
} \
typedef typename \
add_reference< \
typename mpl::eval_if< \
is_const<Seq> \
, add_const<BOOST_PP_TUPLE_ELEM( \
ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \
> \
, mpl::identity<BOOST_PP_TUPLE_ELEM( \
ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \
> \
>::type \
>::type \
type; \
\
template<typename Seq> \
static typename add_reference<typename add_const<type>::type>::type \
call(Seq const& seq) \
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 seq.PREFIX \
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE); \
return BOOST_PP_STRINGIZE( \
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)); \
} \
};
@ -116,9 +150,9 @@ namespace boost
namespace traits \
{ \
BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \
BOOST_PP_EMPTY(),TEMPLATE_PARAMS_SEQ,NAME_SEQ,TAG) \
BOOST_PP_EMPTY(), TEMPLATE_PARAMS_SEQ, NAME_SEQ, TAG) \
BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \
const,TEMPLATE_PARAMS_SEQ,NAME_SEQ,TAG) \
const, TEMPLATE_PARAMS_SEQ, NAME_SEQ, TAG) \
} \
\
namespace extension \

View File

@ -7,13 +7,10 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_AT_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_AT_IMPL_HPP
#ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_AT_IMPL_HPP
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_AT_IMPL_HPP
#include <boost/fusion/support/detail/access.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/int.hpp>
namespace boost { namespace fusion { namespace extension
{
@ -25,28 +22,11 @@ namespace boost { namespace fusion { namespace extension
{
template <typename Seq, typename N>
struct apply
{
typedef
extension::struct_member<
typename remove_const<Seq>::type
, N::value
>
member;
typedef typename
mpl::eval_if<
is_const<Seq>
, detail::cref_result<member>
, detail::ref_result<member>
>::type
type;
static type
call(Seq& seq)
{
return member::call(seq);
}
};
: extension::struct_member<
typename remove_const<Seq>::type
, N::value
>::template apply<Seq>
{};
};
template <>

View File

@ -7,8 +7,8 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_BEGIN_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_BEGIN_IMPL_HPP
#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>
@ -48,7 +48,7 @@ namespace boost { namespace fusion { namespace extension
{
typedef
basic_iterator<
assoc_struct_iterator_tag
struct_iterator_tag
, assoc_struct_category
, Seq
, 0

View File

@ -7,8 +7,8 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_CATEGORY_OF_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_CATEGORY_OF_IMPL_HPP
#ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_CATEGORY_OF_IMPL_HPP
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_CATEGORY_OF_IMPL_HPP
namespace boost { namespace fusion
{

View File

@ -5,8 +5,8 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEREF_DATA_IMPL_HPP
#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
{
@ -14,8 +14,8 @@ namespace boost { namespace fusion { namespace extension
struct deref_data_impl;
template <>
struct deref_data_impl<assoc_struct_iterator_tag>
: deref_impl<assoc_struct_iterator_tag>
struct deref_data_impl<struct_iterator_tag>
: deref_impl<struct_iterator_tag>
{};
}}}

View File

@ -5,13 +5,8 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEREF_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEREF_IMPL_HPP
#include <boost/fusion/support/detail/access.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/is_const.hpp>
#ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_DEREF_IMPL_HPP
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_DEREF_IMPL_HPP
namespace boost { namespace fusion { namespace extension
{
@ -24,33 +19,23 @@ namespace boost { namespace fusion { namespace extension
template <typename It>
struct apply
{
typedef
extension::struct_member<
typename remove_const<typename It::seq_type>::type
, It::index::value
>
member;
typedef typename
extension::struct_member<
typename remove_const<typename It::seq_type>::type
, It::index::value
>::template apply<typename It::seq_type>
impl;
typedef typename
mpl::eval_if<
is_const<typename It::seq_type>
, detail::cref_result<member>
, detail::ref_result<member>
>::type
type;
typedef typename impl::type type;
static type
call(It const& it)
{
return member::call(*it.seq);
}
static
type
call(It const& it)
{
return impl::call(*it.seq);
}
};
};
template <>
struct deref_impl<assoc_struct_iterator_tag>
: deref_impl<struct_iterator_tag>
{};
}}}
#endif

View File

@ -7,11 +7,10 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_END_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_END_IMPL_HPP
#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>
#include <boost/type_traits/remove_const.hpp>
namespace boost { namespace fusion { namespace extension
{
@ -49,7 +48,7 @@ namespace boost { namespace fusion { namespace extension
{
typedef
basic_iterator<
assoc_struct_iterator_tag
struct_iterator_tag
, assoc_struct_category
, Seq
, struct_size<typename remove_const<Seq>::type>::value

View File

@ -7,8 +7,8 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_EXTENSION_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_EXTENSION_HPP
#ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_EXTENSION_HPP
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_EXTENSION_HPP
#include <boost/fusion/support/category_of.hpp>
@ -17,7 +17,6 @@ namespace boost { namespace fusion
struct struct_tag;
struct struct_iterator_tag;
struct assoc_struct_tag;
struct assoc_struct_iterator_tag;
struct fusion_sequence_tag;
struct assoc_struct_category
@ -31,6 +30,9 @@ namespace boost { namespace fusion
template<typename Seq, int N>
struct struct_member;
template<typename Seq, int N>
struct struct_member_name;
template<typename Seq, int N>
struct struct_assoc_key;

View File

@ -1,13 +1,14 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2009-2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_IS_SEQUENCE_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_IS_SEQUENCE_IMPL_HPP
#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>

View File

@ -1,13 +1,14 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2009-2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_IS_VIEW_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_IS_VIEW_IMPL_HPP
#ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_IS_VIEW_IMPL_HPP
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_IS_VIEW_IMPL_HPP
#include <boost/mpl/bool.hpp>

View File

@ -5,10 +5,8 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_KEY_OF_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_KEY_OF_IMPL_HPP
#include <boost/type_traits/remove_const.hpp>
#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
{
@ -16,18 +14,15 @@ namespace boost { namespace fusion { namespace extension
struct key_of_impl;
template <>
struct key_of_impl<assoc_struct_iterator_tag>
struct key_of_impl<struct_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
extension::struct_assoc_key<
typename remove_const<typename It::seq_type>::type
, It::index::value
>::type
type;
};
: extension::struct_assoc_key<
typename remove_const<typename It::seq_type>::type
, It::index::value
>
{};
};
}}}

View File

@ -1,12 +1,13 @@
/*=============================================================================
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
#ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_PROXY_TYPE_HPP
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_PROXY_TYPE_HPP
#include <boost/preprocessor/dec.hpp>
#include <boost/preprocessor/control/if.hpp>

View File

@ -1,15 +1,14 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2009-2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_SIZE_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_SIZE_IMPL_HPP
#include <boost/type_traits/remove_const.hpp>
#ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_SIZE_IMPL_HPP
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_SIZE_IMPL_HPP
namespace boost { namespace fusion { namespace extension
{

View File

@ -1,15 +1,14 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2009-2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_AT_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_AT_IMPL_HPP
#include <boost/type_traits/remove_const.hpp>
#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
{

View File

@ -5,8 +5,8 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_OF_DATA_IMPL_HPP
#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
{
@ -14,8 +14,8 @@ namespace boost { namespace fusion { namespace extension
struct value_of_data_impl;
template <>
struct value_of_data_impl<assoc_struct_iterator_tag>
: value_of_impl<assoc_struct_iterator_tag>
struct value_of_data_impl<struct_iterator_tag>
: value_of_impl<struct_iterator_tag>
{};
}}}

View File

@ -5,10 +5,8 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_OF_IMPL_HPP
#define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_VALUE_OF_IMPL_HPP
#include <boost/type_traits/remove_const.hpp>
#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
{
@ -20,20 +18,12 @@ namespace boost { namespace fusion { namespace extension
{
template <typename It>
struct apply
{
typedef typename
extension::struct_member<
typename remove_const<typename It::seq_type>::type
, It::index::value
>::type
type;
};
: extension::struct_member<
typename remove_const<typename It::seq_type>::type
, It::index::value
>
{};
};
template <>
struct value_of_impl<assoc_struct_iterator_tag>
: value_of_impl<struct_iterator_tag>
{};
}}}
#endif