mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 03:57:36 +02:00
update from trunk fixing http://boost.2283326.n4.nabble.com/fusion-g-4-6-deque-and-c-0x-compile-error-td4632499.html
[SVN r79958]
This commit is contained in:
@ -658,7 +658,7 @@ __random_access_sequence__.
|
||||
|
||||
[heading Synopsis]
|
||||
|
||||
BOOST_FUSION_ADAPT_ADT(
|
||||
BOOST_FUSION_ADAPT_TPL_ADT(
|
||||
(template_param0)(template_param1)...,
|
||||
(type_name) (specialization_param0)(specialization_param1)...,
|
||||
(attribute_type0, attribute_const_type0, get_expr0, set_expr0)
|
||||
@ -1115,6 +1115,100 @@ defined in __random_access_sequence__.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:define_struct_inline BOOST_FUSION_DEFINE_STRUCT_INLINE]
|
||||
|
||||
[heading Description]
|
||||
|
||||
BOOST_FUSION_DEFINE_STRUCT_INLINE is a macro that can be used to generate all
|
||||
the necessary boilerplate to define and adapt an arbitrary struct as a model of
|
||||
__random_access_sequence__. Unlike BOOST_FUSION_DEFINE_STRUCT, it can be used
|
||||
at class or namespace scope.
|
||||
|
||||
[heading Synopsis]
|
||||
|
||||
BOOST_FUSION_DEFINE_STRUCT_INLINE(
|
||||
struct_name,
|
||||
(member_type0, member_name0)
|
||||
(member_type1, member_name1)
|
||||
...
|
||||
)
|
||||
|
||||
[heading Expression Semantics]
|
||||
|
||||
The semantics of BOOST_FUSION_DEFINE_STRUCT_INLINE are identical to those of
|
||||
BOOST_FUSION_DEFINE_STRUCT, with two differences:
|
||||
|
||||
# BOOST_FUSION_DEFINE_STRUCT_INLINE can be used at class or namespace scope, and
|
||||
thus does not take a namespace list parameter.
|
||||
# The structure generated by BOOST_FUSION_DEFINE_STRUCT_INLINE has a base class,
|
||||
and is thus not POD in C++03.
|
||||
|
||||
[heading Header]
|
||||
|
||||
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
|
||||
#include <boost/fusion/include/define_struct_inline.hpp>
|
||||
|
||||
[heading Example]
|
||||
|
||||
// enclosing::employee is a Fusion sequence
|
||||
class enclosing
|
||||
{
|
||||
BOOST_FUSION_DEFINE_STRUCT_INLINE(
|
||||
employee,
|
||||
(std::string, name)
|
||||
(int, age))
|
||||
};
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:define_tpl_struct_inline BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE]
|
||||
|
||||
[heading Description]
|
||||
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE is a macro that can be used to generate
|
||||
all the necessary boilerplate to define and adapt an arbitrary template struct
|
||||
as a model of __random_access_sequence__. Unlike BOOST_FUSION_DEFINE_TPL_STRUCT,
|
||||
it can be used at class or namespace scope.
|
||||
|
||||
[heading Synopsis]
|
||||
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
|
||||
(template_param0)(template_param1)...,
|
||||
struct_name,
|
||||
(member_type0, member_name0)
|
||||
(member_type1, member_name1)
|
||||
...
|
||||
)
|
||||
|
||||
[heading Expression Semantics]
|
||||
|
||||
The semantics of BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE are identical to those of
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT, with two differences:
|
||||
|
||||
# BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE can be used at class or namespace scope,
|
||||
and thus does not take a namespace list parameter.
|
||||
# The structure generated by BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE has a base
|
||||
class, and is thus not POD in C++03.
|
||||
|
||||
[heading Header]
|
||||
|
||||
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
|
||||
#include <boost/fusion/include/define_struct_inline.hpp>
|
||||
|
||||
[heading Example]
|
||||
|
||||
// Any instantiated enclosing::employee is a Fusion sequence
|
||||
class enclosing
|
||||
{
|
||||
BOOST_FUSION_DEFINE_TPL_STRUCT(
|
||||
(Name)(Age), employee,
|
||||
(Name, name)
|
||||
(Age, age))
|
||||
};
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:define_assoc_struct BOOST_FUSION_DEFINE_ASSOC_STRUCT]
|
||||
|
||||
[heading Description]
|
||||
|
@ -29,6 +29,27 @@
|
||||
#define BOOST_FUSION_MAKE_DEFAULT_INIT_LIST_ENTRY(R, DATA, N, ATTRIBUTE) \
|
||||
BOOST_PP_COMMA_IF(N) BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE)()
|
||||
|
||||
#define BOOST_FUSION_MAKE_DEFAULT_INIT_LIST(ATTRIBUTES_SEQ) \
|
||||
: BOOST_PP_SEQ_FOR_EACH_I( \
|
||||
BOOST_FUSION_MAKE_DEFAULT_INIT_LIST_ENTRY, \
|
||||
~, \
|
||||
ATTRIBUTES_SEQ) \
|
||||
|
||||
#define BOOST_FUSION_IGNORE_1(ARG1)
|
||||
#define BOOST_FUSION_IGNORE_2(ARG1, ARG2)
|
||||
|
||||
#define BOOST_FUSION_MAKE_COPY_CONSTRUCTOR(NAME, ATTRIBUTES_SEQ) \
|
||||
NAME(BOOST_PP_SEQ_FOR_EACH_I( \
|
||||
BOOST_FUSION_MAKE_CONST_REF_PARAM, \
|
||||
~, \
|
||||
ATTRIBUTES_SEQ)) \
|
||||
: BOOST_PP_SEQ_FOR_EACH_I( \
|
||||
BOOST_FUSION_MAKE_INIT_LIST_ENTRY, \
|
||||
~, \
|
||||
ATTRIBUTES_SEQ) \
|
||||
{ \
|
||||
} \
|
||||
|
||||
#define BOOST_FUSION_MAKE_CONST_REF_PARAM(R, DATA, N, ATTRIBUTE) \
|
||||
BOOST_PP_COMMA_IF(N) \
|
||||
BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE) const& \
|
||||
@ -162,23 +183,19 @@
|
||||
NAME, ATTRIBUTES_SEQ, ATTRIBUTES_SEQ_SIZE) \
|
||||
\
|
||||
NAME() \
|
||||
: BOOST_PP_SEQ_FOR_EACH_I( \
|
||||
BOOST_FUSION_MAKE_DEFAULT_INIT_LIST_ENTRY, \
|
||||
~, \
|
||||
ATTRIBUTES_SEQ) \
|
||||
BOOST_PP_IF( \
|
||||
BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ), \
|
||||
BOOST_FUSION_MAKE_DEFAULT_INIT_LIST, \
|
||||
BOOST_FUSION_IGNORE_1) \
|
||||
(ATTRIBUTES_SEQ) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
NAME(BOOST_PP_SEQ_FOR_EACH_I( \
|
||||
BOOST_FUSION_MAKE_CONST_REF_PARAM, \
|
||||
~, \
|
||||
ATTRIBUTES_SEQ)) \
|
||||
: BOOST_PP_SEQ_FOR_EACH_I( \
|
||||
BOOST_FUSION_MAKE_INIT_LIST_ENTRY, \
|
||||
~, \
|
||||
ATTRIBUTES_SEQ) \
|
||||
{ \
|
||||
} \
|
||||
BOOST_PP_IF( \
|
||||
BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ), \
|
||||
BOOST_FUSION_MAKE_COPY_CONSTRUCTOR, \
|
||||
BOOST_FUSION_IGNORE_2) \
|
||||
(NAME, ATTRIBUTES_SEQ) \
|
||||
\
|
||||
template <typename boost_fusion_uglified_Seq> \
|
||||
NAME(const boost_fusion_uglified_Seq& rhs) \
|
||||
|
@ -1,102 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-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_DEQUE_DETAIL_DEQUE_KEYED_VALUES_26112006_1330)
|
||||
#define BOOST_FUSION_DEQUE_DETAIL_DEQUE_KEYED_VALUES_26112006_1330
|
||||
|
||||
#include <boost/fusion/container/deque/limits.hpp>
|
||||
#include <boost/fusion/container/deque/detail/keyed_element.hpp>
|
||||
|
||||
#include <boost/preprocessor/iterate.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
|
||||
#include <boost/mpl/plus.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/print.hpp>
|
||||
|
||||
#define FUSION_VOID(z, n, _) void_
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
}}
|
||||
|
||||
#if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES)
|
||||
#include <boost/fusion/container/deque/detail/preprocessed/deque_keyed_values.hpp>
|
||||
#else
|
||||
#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
|
||||
#pragma wave option(preserve: 2, line: 0, output: "preprocessed/deque_keyed_values" FUSION_MAX_DEQUE_SIZE_STR ".hpp")
|
||||
#endif
|
||||
|
||||
/*=============================================================================
|
||||
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)
|
||||
|
||||
This is an auto-generated file. Do not edit!
|
||||
==============================================================================*/
|
||||
|
||||
#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
|
||||
#pragma wave option(preserve: 1)
|
||||
#endif
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template<typename Key, typename Value, typename Rest>
|
||||
struct keyed_element;
|
||||
|
||||
struct nil_keyed_element;
|
||||
|
||||
template<typename N, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(FUSION_MAX_DEQUE_SIZE, typename T, void_)>
|
||||
struct deque_keyed_values_impl;
|
||||
|
||||
template<typename N>
|
||||
struct deque_keyed_values_impl<N, BOOST_PP_ENUM(FUSION_MAX_DEQUE_SIZE, FUSION_VOID, _)>
|
||||
{
|
||||
typedef nil_keyed_element type;
|
||||
|
||||
static type call()
|
||||
{
|
||||
return type();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename N, BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, typename T)>
|
||||
struct deque_keyed_values_impl
|
||||
{
|
||||
typedef mpl::int_<mpl::plus<N, mpl::int_<1> >::value> next_index;
|
||||
|
||||
typedef typename deque_keyed_values_impl<
|
||||
next_index,
|
||||
BOOST_PP_ENUM_SHIFTED_PARAMS(FUSION_MAX_DEQUE_SIZE, T)>::type tail;
|
||||
typedef keyed_element<N, T0, tail> type;
|
||||
|
||||
#include <boost/fusion/container/deque/detail/deque_keyed_values_call.hpp>
|
||||
|
||||
};
|
||||
|
||||
template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(FUSION_MAX_DEQUE_SIZE, typename T, void_)>
|
||||
struct deque_keyed_values
|
||||
: deque_keyed_values_impl<mpl::int_<0>, BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)>
|
||||
{};
|
||||
|
||||
}}}
|
||||
|
||||
#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
|
||||
#pragma wave option(output: null)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_FUSION_DONT_USE_PREPROCESSED_FILES
|
||||
|
||||
#undef FUSION_VOID
|
||||
|
||||
#endif
|
@ -71,6 +71,24 @@ namespace ns
|
||||
int y;
|
||||
};
|
||||
#endif
|
||||
|
||||
// A sequence that has data members defined in an unrelated namespace
|
||||
// (std, in this case). This allows testing ADL issues.
|
||||
class name
|
||||
{
|
||||
public:
|
||||
name() {}
|
||||
name(const std::string& last, const std::string& first)
|
||||
: last(last), first(first) {}
|
||||
|
||||
const std::string& get_last() const { return last; }
|
||||
const std::string& get_first() const { return first; }
|
||||
void set_last(const std::string& last_) { last = last_; }
|
||||
void set_first(const std::string& first_) { first = first_; }
|
||||
private:
|
||||
std::string last;
|
||||
std::string first;
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_ADT(
|
||||
@ -87,6 +105,12 @@ BOOST_FUSION_ADAPT_ADT(
|
||||
)
|
||||
#endif
|
||||
|
||||
BOOST_FUSION_ADAPT_ADT(
|
||||
ns::name,
|
||||
(const std::string&, const std::string&, obj.get_last(), obj.set_last(val))
|
||||
(const std::string&, const std::string&, obj.get_first(), obj.set_first(val))
|
||||
)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@ -131,6 +155,20 @@ main()
|
||||
BOOST_TEST(v3 >= v2);
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<std::string, std::string> v1("Lincoln", "Abraham");
|
||||
ns::name v2("Roosevelt", "Franklin");
|
||||
ns::name v3("Roosevelt", "Theodore");
|
||||
BOOST_TEST(v1 < v2);
|
||||
BOOST_TEST(v1 <= v2);
|
||||
BOOST_TEST(v2 > v1);
|
||||
BOOST_TEST(v2 >= v1);
|
||||
BOOST_TEST(v2 < v3);
|
||||
BOOST_TEST(v2 <= v3);
|
||||
BOOST_TEST(v3 > v2);
|
||||
BOOST_TEST(v3 >= v2);
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to vector
|
||||
ns::point p(5, 3);
|
||||
|
@ -67,6 +67,7 @@ main()
|
||||
using namespace boost::fusion;
|
||||
|
||||
typedef ns::point<int, int> point;
|
||||
typedef ns::point<std::string, std::string> name;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
@ -106,6 +107,20 @@ main()
|
||||
BOOST_TEST(v3 >= v2);
|
||||
}
|
||||
|
||||
{
|
||||
boost::fusion::vector<std::string, std::string> v1("Lincoln", "Abraham");
|
||||
name v2("Roosevelt", "Franklin");
|
||||
name v3("Roosevelt", "Theodore");
|
||||
BOOST_TEST(v1 < v2);
|
||||
BOOST_TEST(v1 <= v2);
|
||||
BOOST_TEST(v2 > v1);
|
||||
BOOST_TEST(v2 >= v1);
|
||||
BOOST_TEST(v2 < v3);
|
||||
BOOST_TEST(v2 <= v3);
|
||||
BOOST_TEST(v3 > v2);
|
||||
BOOST_TEST(v3 >= v2);
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from point to vector
|
||||
point p(5, 3);
|
||||
|
Reference in New Issue
Block a user