diff --git a/doc/adapted.qbk b/doc/adapted.qbk index f762a049..a370e373 100644 --- a/doc/adapted.qbk +++ b/doc/adapted.qbk @@ -89,6 +89,35 @@ __std_pair_doc__, __tr1_tuple_pair__ [endsect] +[section std::tuple] + +This module provides adapters for `std::tuple`. Including the module header +makes `std::tuple` a fully conforming __random_access_sequence__. + +[important To be fully conforming, compiler should support C++11 Variadic Templates.] + +[heading Header] + + #include + #include + +[heading Model of] + +* __random_access_sequence__ + +[heading Example] + + std::tuple p(123, "Hola!!!", 456.f); + std::cout << __at_c__<0>(p) << std::endl; + std::cout << __at_c__<1>(p) << std::endl; + std::cout << p << std::endl; + +[heading See also] + +__std_tuple_doc__ + +[endsect] + [section mpl sequence] This module provides adapters for __mpl__ sequences. Including the module @@ -168,8 +197,8 @@ header makes `boost::tuple` a fully conforming __forward_sequence__. [heading Example] boost::tuple example_tuple(101, "hello"); - std::cout << *boost::fusion::begin(example_tuple) << '\n'; - std::cout << *boost::fusion::next(boost::fusion::begin(example_tuple)) << '\n'; + std::cout << *__begin__(example_tuple) << '\n'; + std::cout << *__next__(__begin__(example_tuple)) << '\n'; [heading See also] @@ -185,10 +214,20 @@ necessary boilerplate to make an arbitrary struct a model of __random_access_sequence__. [heading Synopsis] + BOOST_FUSION_ADAPT_STRUCT( + struct_name, + member_name0, + member_name1, + member_name2, + ... + ) + + // Without BOOST_PP_VARIADICS support : BOOST_FUSION_ADAPT_STRUCT( struct_name, (member_type0, member_name0) (member_type1, member_name1) + (BOOST_FUSION_ADAPT_AUTO, member_name2) ... ) @@ -196,9 +235,13 @@ __random_access_sequence__. The above macro generates the necessary code to adapt `struct_name` as a model of __random_access_sequence__. -The sequence of `(member_typeN, member_nameN)` -pairs declares the type and names of each of the struct members that are -part of the sequence. + +The sequence of `member_nameN,` arguments or `(member_typeN, member_nameN)` +pairs declares the type and names of each of the struct members that are part of +the sequence. + +When member_typeN is omitted or set to BOOST_FUSION_ADAPT_AUTO, the type is +infered with Boost.TypeOf. The macro should be used at global scope, and `struct_name` should be the fully namespace qualified name of the struct to be adapted. @@ -208,7 +251,7 @@ namespace qualified name of the struct to be adapted. #include #include -[heading Example] +[heading Example: BOOST_FUSION_ADAPT_STRUCT ] namespace demo { struct employee @@ -221,8 +264,15 @@ namespace qualified name of the struct to be adapted. // demo::employee is now a Fusion sequence BOOST_FUSION_ADAPT_STRUCT( demo::employee, - (std::string, name) - (int, age)) + name, + age) + + // Without BOOST_PP_VARIADICS support : + BOOST_FUSION_ADAPT_STRUCT( + demo::employee, + (BOOST_FUSION_ADAPT_AUTO, name) + (BOOST_FUSION_ADAPT_AUTO, age) + ) [endsect] @@ -234,11 +284,21 @@ necessary boilerplate to make an arbitrary template struct a model of __random_access_sequence__. [heading Synopsis] + BOOST_FUSION_ADAPT_TPL_STRUCT( + (template_param0)(template_param1)..., + (struct_name) (specialization_param0)(specialization_param1)..., + member_name0, + member_name1 + ... + ) + + // Without BOOST_PP_VARIADICS support : BOOST_FUSION_ADAPT_TPL_STRUCT( (template_param0)(template_param1)..., (struct_name) (specialization_param0)(specialization_param1)..., (member_type0, member_name0) (member_type1, member_name1) + (BOOST_FUSION_ADAPT_AUTO, member_name2), ... ) @@ -252,9 +312,12 @@ the template type parameters used. The sequence `(specialization_param0)(specialization_param1)...` declares the template parameters of the actual specialization of `struct_name` that is adapted as a fusion sequence. -The sequence of `(member_typeN, member_nameN)` -pairs declares the type and names of each of the struct members that are -part of the sequence. +The sequence of `member_nameN,` arguments or `(member_typeN, member_nameN)` +pairs declares the type and names of each of the struct members that are part of +the sequence. + +When member_typeN is omitted or set to BOOST_FUSION_ADAPT_AUTO, the type is +infered with Boost.TypeOf. The macro should be used at global scope, and `struct_name` should be the fully namespace qualified name of the struct to be adapted. @@ -272,6 +335,7 @@ namespace qualified name of the struct to be adapted. { Name name; Age age; + int employment_timestamp; }; } @@ -280,7 +344,16 @@ namespace qualified name of the struct to be adapted. (Name)(Age), (demo::employee) (Name)(Age), (Name, name) - (Age, age)) + (Age, age) + (BOOST_FUSION_ADAPT_AUTO, employment_timestamp)) + + // Or by infering type completely + BOOST_FUSION_ADAPT_TPL_STRUCT( + (Name)(Age), + (demo::employee) (Name)(Age), + name, + age, + employment_timestamp) [endsect] @@ -293,10 +366,31 @@ arbitrary struct a model of __random_access_sequence__. The given struct is adapted using the given name. [heading Synopsis] + BOOST_FUSION_ADAPT_STRUCT_NAMED( + struct_name, adapted_name, + member_name0, + member_name1, + member_name2, + ... + ) + + BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( + struct_name, + (namespace0)(namespace1)..., + adapted_name, + member_name0, + member_name1, + member_name2, + ... + ) + + // Without BOOST_PP_VARIADICS support : + BOOST_FUSION_ADAPT_STRUCT_NAMED( struct_name, adapted_name, (member_type0, member_name0) (member_type1, member_name1) + (BOOST_FUSION_ADAPT_AUTO, member_name2), ... ) @@ -306,9 +400,12 @@ adapted using the given name. adapted_name, (member_type0, member_name0) (member_type1, member_name1) + (BOOST_FUSION_ADAPT_AUTO, member_name2), ... ) + + [heading Semantics] The above macros generate the necessary code to adapt `struct_name` @@ -321,9 +418,12 @@ If an empty namespace sequence is given (that is a macro that expands to nothing), the adapted view is placed in the global namespace. If no namespace sequence is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_NAMED`), the adapted view is placed in the namespace `boost::fusion::adapted`. -The sequence of `(member_typeN, member_nameN)` -pairs declares the type and names of each of the struct members that are -part of the sequence. +The sequence of `member_nameN,` arguments or `(member_typeN, member_nameN)` +pairs declares the type and names of each of the struct members that are part of +the sequence. + +When member_typeN is omitted or set to BOOST_FUSION_ADAPT_AUTO, the type is +infered with Boost.TypeOf. The macros should be used at global scope, and `struct_name` should be the fully namespace qualified name of the struct to be converted. @@ -347,8 +447,14 @@ namespace qualified name of the struct to be converted. // referring to demo::employee BOOST_FUSION_ADAPT_STRUCT_NAMED( demo::employee, adapted_employee, - (std::string, name) - (int, age)) + name, + age) + + // Without BOOST_PP_VARIADICS support : + BOOST_FUSION_ADAPT_STRUCT_NAMED( + demo::employee, adapted_employee, + (BOOST_FUSION_ADAPT_AUTO, name), + (BOOST_FUSION_ADAPT_AUTO, age)) [endsect] @@ -362,8 +468,8 @@ __random_access_sequence__ and __associative_sequence__. [heading Synopsis] BOOST_FUSION_ADAPT_ASSOC_STRUCT( struct_name, - (member_type0, member_name0, key_type0) - (member_type1, member_name1, key_type1) + ([member_type0,] member_name0, key_type0) + ([member_type1,] member_name1, key_type1) ... ) @@ -371,10 +477,13 @@ __random_access_sequence__ and __associative_sequence__. The above macro generates the necessary code to adapt `struct_name` as a model of __random_access_sequence__ and __associative_sequence__. -The sequence of `(member_typeN, member_nameN, key_typeN)` -triples declares the type, name and key type of each of the struct members +The sequence of `([member_typeN,] member_nameN, key_typeN)` tuples +declares the type, name and key type of each of the struct members that are part of the sequence. +When member_typeN is omitted or set to BOOST_FUSION_ADAPT_AUTO, the type is +infered with Boost.TypeOf. + The macro should be used at global scope, and `struct_name` should be the fully namespace qualified name of the struct to be adapted. @@ -404,8 +513,14 @@ namespace qualified name of the struct to be adapted. // keys keys::name and keys::age present. BOOST_FUSION_ADAPT_ASSOC_STRUCT( demo::employee, - (std::string, name, keys::name) - (int, age, keys::age)) + (name, keys::name) + (age, keys::age)) + + // Without BOOST_PP_VARIADICS support : + BOOST_FUSION_ADAPT_ASSOC_STRUCT( + demo::employee, + (BOOST_FUSION_ADAPT_AUTO, name, keys::name), + (BOOST_FUSION_ADAPT_AUTO, age, keys::name)) [endsect] @@ -420,8 +535,8 @@ __random_access_sequence__ and __associative_sequence__. BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( (template_param0)(template_param1)..., (struct_name) (specialization_param0)(specialization_param1)..., - (member_type0, member_name0, key_type0) - (member_type1, member_name1, key_type1) + ([member_type0,] member_name0, key_type0) + ([member_type1,] member_name1, key_type1) ... ) @@ -435,10 +550,13 @@ the template type parameters used. The sequence `(specialization_param0)(specialization_param1)...` declares the template parameters of the actual specialization of `struct_name` that is adapted as a fusion sequence. -The sequence of `(member_typeN, member_nameN, key_typeN)` -triples declares the type, name and key type of each of the struct members +The sequence of `([member_typeN,] member_nameN, key_typeN)` +tuples declares the type, name and key type of each of the struct members that are part of the sequence. +When member_typeN is omitted or set to BOOST_FUSION_ADAPT_AUTO, the type is +infered with Boost.TypeOf. + The macro should be used at global scope, and `struct_name` should be the fully namespace qualified name of the struct to be adapted. @@ -467,6 +585,13 @@ namespace qualified name of the struct to be adapted. // Any instantiated demo::employee is now a Fusion sequence. // It is also an associative sequence with // keys keys::name and keys::age present. + BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( + (Name)(Age), + (demo::employee) (Name)(Age), + (name, keys::name) + (age, keys::age)) + + // Without BOOST_PP_VARIADICS support : BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( (Name)(Age), (demo::employee) (Name)(Age), @@ -486,8 +611,8 @@ __associative_sequence__. The given struct is adapted using the given name. [heading Synopsis] BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED( struct_name, adapted_name, - (member_type0, member_name0, key_type0) - (member_type1, member_name1, key_type1) + ([member_type0,] member_name0, key_type0) + ([member_type1,] member_name1, key_type1) ... ) @@ -495,8 +620,8 @@ __associative_sequence__. The given struct is adapted using the given name. struct_name, (namespace0)(namespace1)..., adapted_name, - (member_type0, member_name0, key_type0) - (member_type1, member_name1, key_type1) + ([member_type0,] member_name0, key_type0) + ([member_type1,] member_name1, key_type1) ... ) @@ -516,6 +641,9 @@ The sequence of `(member_typeN, member_nameN, key_typeN)` triples declares the type, name and key type of each of the struct members that are part of the sequence. +When member_typeN is omitted or set to BOOST_FUSION_ADAPT_AUTO, the type is +infered with Boost.TypeOf. + The macros should be used at global scope, and `struct_name` should be the fully namespace qualified name of the struct to be converted. @@ -544,8 +672,14 @@ namespace qualified name of the struct to be converted. // referring to demo::employee BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED( demo::employee, adapted_employee, - (std::string, name, keys::name) - (int, age, keys::age)) + (name, keys::name) + (age, keys::age)) + + // Without BOOST_PP_VARIADICS support : + BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED( + demo::employee, adapted_employee, + (BOOST_FUSION_ADAPT_AUTO, name, keys::name) + (BOOST_FUSION_ADAPT_AUTO, age, keys::age)) [endsect] @@ -559,8 +693,8 @@ __random_access_sequence__. BOOST_FUSION_ADAPT_ADT( type_name, - (attribute_type0, attribute_const_type0, get_expr0, set_expr0) - (attribute_type1, attribute_const_type1, get_expr1, set_expr1) + ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0) + ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1) ... ) @@ -569,7 +703,7 @@ __random_access_sequence__. The above macro generates the necessary code to adapt `type_name` as a model of __random_access_sequence__. The sequence of -[^(attribute_type['N], attribute_const_type['N], get_expr['N], set_expr['N])] +[^([attribute_type['N], attribute_const_type['N],] get_expr['N], set_expr['N])] quadruples declares the types, const types, get-expressions and set-expressions of the elements that are part of the adapted fusion sequence. [^get_expr['N]] is the expression that is invoked to get the ['N]th element @@ -577,7 +711,9 @@ of an instance of `type_name`. This expression may access a variable named `obj` of type `type_name&` or `type_name const&` which represents the underlying instance of `type_name`. [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types -that [^get_expr['N]] denotes to. +that [^get_expr['N]] denotes to, when omitted the type is deduced from +[get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for +variadic macros BOOST_FUSION_ADAPT_AUTO can be used to avoid repeating the type. [^set_expr['N]] is the expression that is invoked to set the ['N]th element of an instance of `type_name`. This expression may access variables named `obj` of type `type_name&`, which represent the corresponding instance of @@ -635,8 +771,8 @@ namespace qualified name of the class type to be adapted. BOOST_FUSION_ADAPT_ADT( demo::employee, - (std::string const&, std::string const&, obj.get_name(), obj.set_name(val)) - (int, int, obj.get_age(), obj.set_age(val))) + (obj.get_name(), obj.set_name(val)) + (obj.get_age(), obj.set_age(val))) demo::employee e; front(e)="Edward Norton"; @@ -661,8 +797,8 @@ __random_access_sequence__. BOOST_FUSION_ADAPT_TPL_ADT( (template_param0)(template_param1)..., (type_name) (specialization_param0)(specialization_param1)..., - (attribute_type0, attribute_const_type0, get_expr0, set_expr0) - (attribute_type1, attribute_const_type1, get_expr1, set_expr1) + ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0) + ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1) ... ) @@ -685,7 +821,9 @@ of an instance of `type_name`. This expression may access a variable named `obj` of type `type_name&` or `type_name const&` which represents the underlying instance of `type_name`. [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types -that [^get_expr['N]] denotes to. +that [^get_expr['N]] denotes to, when omitted the type is deduced from +[get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for +variadic macros BOOST_FUSION_ADAPT_AUTO can be used to avoid repeating the type. [^set_expr['N]] is the expression that is invoked to set the ['N]th element of an instance of `type_name`. This expression may access variables named `obj` of type `type_name&`, which represent the corresponding instance of @@ -770,8 +908,8 @@ __random_access_sequence__ and __associative_sequence__. BOOST_FUSION_ADAPT_ASSOC_ADT( type_name, - (attribute_type0, attribute_const_type0, get_expr0, set_expr0, key_type0) - (attribute_type1, attribute_const_type1, get_expr1, set_expr1, key_type1) + ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0, key_type0) + ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1, key_type1) ... ) @@ -788,7 +926,9 @@ of an instance of `type_name`. This expression may access a variable named `obj` of type `type_name&` or `type_name const&` which represents the underlying instance of `type_name`. [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types -that [^get_expr['N]] denotes to. +that [^get_expr['N]] denotes to, when omitted the type is deduced from +[get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for +variadic macros BOOST_FUSION_ADAPT_AUTO can be used to avoid repeating the type. [^set_expr['N]] is the expression that is invoked to set the ['N]th element of an instance of `type_name`. This expression may access variables named `obj` of type `type_name&`, which represent the corresponding instance of @@ -852,8 +992,8 @@ namespace qualified name of the class type to be adapted. BOOST_FUSION_ADAPT_ASSOC_ADT( demo::employee, - (std::string const&, std::string const&, obj.get_name(), obj.set_name(val), keys::name) - (int, int, obj.get_age(), obj.set_age(val), keys::age)) + (obj.get_name(), obj.set_name(val), keys::name) + (obj.get_age(), obj.set_age(val), keys::age)) demo::employee e; at_key(e)="Edward Norton"; @@ -878,8 +1018,8 @@ __random_access_sequence__ and __associative_sequence__. BOOST_FUSION_ADAPT_ASSOC_TPL_ADT( (template_param0)(template_param1)..., (type_name) (specialization_param0)(specialization_param1)..., - (attribute_type0, attribute_const_type0, get_expr0, set_expr0, key_type0) - (attribute_type1, attribute_const_type1, get_expr1, set_expr1, key_type1) + ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0, key_type0) + ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1, key_type1) ... ) @@ -894,7 +1034,7 @@ The sequence `(specialization_param0)(specialization_param1)...` declares the template parameters of the actual specialization of `type_name` that is adapted as a fusion sequence. The sequence of -[^(attribute_type['N], attribute_const_type['N], get_expr['N], set_expr['N], key_type['N])] +[^([attribute_type['N], attribute_const_type['N],] get_expr['N], set_expr['N], key_type['N])] 5-tuples declares the types, const types, get-expressions, set-expressions and key types of the elements that are part of the adapted fusion sequence. [^get_expr['N]] is the expression that is invoked to get the ['N]th element @@ -902,7 +1042,9 @@ of an instance of `type_name`. This expression may access a variable named `obj` of type `type_name&` or `type_name const&` which represents the underlying instance of `type_name`. [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types -that [^get_expr['N]] denotes to. +that [^get_expr['N]] denotes to, when omitted the type is deduced from +[get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for +variadic macros BOOST_FUSION_ADAPT_AUTO can be used to avoid repeating the type. [^set_expr['N]] is the expression that is invoked to set the ['N]th element of an instance of `type_name`. This expression may access variables named `obj` of type `type_name&`, which represent the corresponding instance of diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index d902ebe4..f47fce5c 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -441,10 +441,10 @@ Linear, exactly `__result_of_size__::value` applications of `F`. [endsect] [section for_each] -A metafunction returning the result type of applying __for_each__ to a sequence. The -return type of __for_each__ is always `void`. [heading Description] +A metafunction returning the result type of applying __for_each__ to a sequence. The +return type of __for_each__ is always `void`. [heading Synopsis] template< @@ -724,8 +724,10 @@ or `__end__(seq)` if there is no such element. [heading Complexity] Linear. At most `__result_of_size__::value` comparisons. -#include -#include +[heading Header] + + #include + #include [heading Example] const __vector__ vec(1.0,2); @@ -1361,7 +1363,7 @@ Returns a new sequence, with all the elements of the original sequence, except t typename T, typename Sequence > - typename __result_of_remove__::type replace(Sequence const& seq); + typename __result_of_remove__::type remove(Sequence const& seq); [table Parameters [[Parameter][Requirement][Description]] @@ -1830,7 +1832,7 @@ Constant. Returns a view which is lazily evaluated. #include [heading Example] - assert(___pop_back__(__make_vector__(1,2,3)) == __make_vector__(1,2)); + assert(__pop_back__(__make_vector__(1,2,3)) == __make_vector__(1,2)); [endsect] @@ -2089,32 +2091,33 @@ Constant. [section transform] [heading Description] -For a sequence `seq` and function object or function pointer `f`, `transform` returns a new sequence -with elements created by applying `f(e)` to each element of `e` of `seq`. +Returns the result type of __transform__, given the types of the input sequence and unary __poly_func_obj__. [heading Unary version synopsis] template< typename Sequence, typename F > - typename __result_of_transform__::type transform( - Sequence const& seq, F f); + struct transform + { + typedef __unspecified__ type; + }; [table Parameters [[Parameter][Requirement][Description]] - [[`seq`][A model of __forward_sequence__][Operation's argument]] - [[`f`][`f(e)` is a valid expression for each element `e` of `seq`. `__boost_result_of_call__::type` is the return type of `f` when called with a value of each element type `E`.][Transformation function]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`F`][A model of unary __poly_func_obj__][Transformation metafunction]] ] [heading Expression Semantics] - __transform__(seq, f); + __result_of_transform__::type [*Return type]: * A model of __forward_sequence__ * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. -[*Semantics]: Returns a new sequence, containing the return values of `f(e)` for each element `e` within `seq`. +[*Semantics]: Returns a sequence that contains the types of `__result_of__::type` for each element `E` within `Sequence`. [heading Binary version synopsis] template< @@ -2122,41 +2125,33 @@ with elements created by applying `f(e)` to each element of `e` of `seq`. typename Sequence2, typename F > - typename __result_of_transform__::type transform( - Sequence1 const& seq1, Sequence2 const& seq2, F f); + struct transform + { + typedef __unspecified__ type; + }; [table Parameters [[Parameter][Requirement][Description]] - [[`seq1`][A model of __forward_sequence__][Operation's argument]] - [[`seq2`][A model of __forward_sequence__][Operation's argument]] - [[`f`][`f(e1,e2)` is a valid expression for each pair of elements `e1` of `seq1` and `e2` of `seq2`. `__boost_result_of_call__::type` is the return type of `f` when called with elements of type `E1` and `E2`][Transformation function]] + [[`Sequence1`][A model of __forward_sequence__][Operation's argument]] + [[`Sequence2`][A model of __forward_sequence__][Operation's argument]] + [[`F`][A model of binary __poly_func_obj__][Transformation metafunction]] ] +[heading Expression Semantics] + __result_of_transform__::type + [*Return type]: A model of __forward_sequence__. -[*Semantics]: Returns a new sequence, containing the return values of `f(e1, e2)` for each pair of elements `e1` and `e2` within `seq1` and `seq2` respectively. +[*Semantics]: Returns a sequence, that contains the types of `__result_of__::type` for each pair of elements `E1` and `E2` within `Sequence1` and `Sequence2` respectively. [heading Complexity] -Constant. Returns a view which is lazily evaluated. +Constant. [heading Header] #include #include -[heading Example] - struct triple - { - typedef int result_type; - - int operator()(int t) const - { - return t * 3; - }; - }; - ... - assert(__transform__(__make_vector__(1,2,3), triple()) == __make_vector__(3,6,9)); - [endsect] [section replace] @@ -2200,7 +2195,7 @@ Constant. [section replace_if] [heading Description] -Returns the result type of __replace_if__, given the types of the sequence, __poly_func_obj__ predicate and replacement object. +Returns the result type of __replace_if__, given the types of the sequence, unary __mpl_lambda_expression__ predicate and replacement object. [heading Synopsis] template< @@ -2215,7 +2210,7 @@ Returns the result type of __replace_if__, given the types of the sequence, __po [table Parameters [[Parameter][Requirement][Description]] [[`Sequence`][A model of __forward_sequence__][Operation's argument]] - [[`F`][A model of unary __poly_func_obj__][Replacement predicate]] + [[`F`][A model of unary __mpl_lambda_expression__][Replacement predicate]] [[`T`][Any type][The type of the replacement object]] ] @@ -2265,7 +2260,7 @@ Returns the result type of __remove__, given the sequence and removal types. * A model of __forward_sequence__. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. -[*Semantics]: Returns a sequence containing the elements of `Sequence` not of type `T`. Equivalent to `__result_of_replace_if__ >::type`. +[*Semantics]: Returns a sequence containing the elements of `Sequence` not of type `T`. Equivalent to `__result_of_remove_if__ >::type`. [heading Complexity] Constant. diff --git a/doc/container.qbk b/doc/container.qbk index 571c7f0a..270b184b 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -191,7 +191,7 @@ defined in __forward_sequence__. [[`__at__(l)`] [The Nth element from the beginning of the sequence; see __at__.]] ] -[blurb __note__ `__at__(l)` is provided for convenience and compatibility +[note `__at__(l)` is provided for convenience and compatibility with the original __tuple__ library, despite `cons` being a __forward_sequence__ only (`at` is supposed to be a __random_access_sequence__ requirement). The runtime complexity of __at__ is @@ -276,7 +276,7 @@ defined in __forward_sequence__. [[`__at__(l)`] [The Nth element from the beginning of the sequence; see __at__.]] ] -[blurb __note__ `__at__(l)` is provided for convenience and compatibility +[note `__at__(l)` is provided for convenience and compatibility with the original __tuple__ library, despite `list` being a __forward_sequence__ only (__at__ is supposed to be a __random_access_sequence__ requirement). The runtime complexity of __at__ is @@ -363,7 +363,7 @@ defined in __bidirectional_sequence__. [[`__at__(d)`] [The Nth element from the beginning of the sequence; see __at__.]] ] -[blurb __note__ `__at__(d)` is provided for convenience, despite +[note `__at__(d)` is provided for convenience, despite `deque` being a __bidirectional_sequence__ only (`at` is supposed to be a __random_access_sequence__ requirement). The runtime complexity of __at__ is constant (see __recursive_inline__). `deque` element access @@ -406,7 +406,7 @@ the same properties as the __deque__. [[`T`] [Element type] [ ]] ] -[blurb __note__ `Deque` can be a __deque__, a __front_extended_deque__ or a +[note `Deque` can be a __deque__, a __front_extended_deque__ or a __back_extended_deque__] [heading Model of] @@ -430,7 +430,7 @@ not defined in __bidirectional_sequence__. [[`__at__(d)`] [The Nth element from the beginning of the sequence; see __at__.]] ] -[blurb __note__ See __deque__ for further details.] +[note See __deque__ for further details.] [heading Example] @@ -467,7 +467,7 @@ the same properties as the __deque__. [[`T`] [Element type] [ ]] ] -[blurb __note__ `Deque` can be a __deque__, a __back_extended_deque__ or a +[note `Deque` can be a __deque__, a __back_extended_deque__ or a __back_extended_deque__] [heading Model of] @@ -491,7 +491,7 @@ not defined in __bidirectional_sequence__. [[`__at__(d)`] [The Nth element from the beginning of the sequence; see __at__.]] ] -[blurb __note__ See __deque__ for further details.] +[note See __deque__ for further details.] [heading Example] @@ -730,7 +730,7 @@ before including any Fusion header to change the default. Example: [heading See also] -__note_boost_ref__ +__note_ref_wrappers__ [endsect] @@ -778,7 +778,7 @@ __result_of_make_cons__`::type` [heading See also] -__note_boost_ref__ +__note_ref_wrappers__ [endsect] @@ -828,7 +828,7 @@ default. Example: [heading See also] -__note_boost_ref__ +__note_ref_wrappers__ [endsect] @@ -880,7 +880,7 @@ Fusion header to change the default. Example: [heading See also] -__note_boost_ref__ +__note_ref_wrappers__ [endsect] @@ -932,7 +932,7 @@ default. Example: [heading See also] -__note_boost_ref__ +__note_ref_wrappers__ [endsect] @@ -990,7 +990,7 @@ default. Example: [heading See also] -__note_boost_ref__, __fusion_pair__ +__note_ref_wrappers__, __fusion_pair__ [endsect] diff --git a/doc/extension.qbk b/doc/extension.qbk index 96e5ef61..cbb61ce5 100644 --- a/doc/extension.qbk +++ b/doc/extension.qbk @@ -323,7 +323,7 @@ For our __random_access_sequence__ we will also need to implement `size_impl`, In order for `example_struct` to serve as an associative forward sequence, we need to adapt the traversal category of our sequence and our iterator accordingly and enable 3 intrinsic sequence lookup features, __at_key__, -__value_at_key__ and __has_key__. We also need to enable 3 iterator lookup +__result_of_value_at_key__ and __has_key__. We also need to enable 3 iterator lookup features, __result_of_key_of__, __result_of_value_of_data__ and __deref_data__. To implement `at_key_impl` we need to associate the `fields::name` and `fields::age` diff --git a/doc/functional.qbk b/doc/functional.qbk index 9bfdaa63..4a8e3d81 100644 --- a/doc/functional.qbk +++ b/doc/functional.qbk @@ -931,11 +931,11 @@ reference. Const qualification is preserved and propagated appropriately the target function object is const - or, in case the target function object is held by value, the adapter is const). -[blurb __note__ For Microsoft Visual C++ 7.1 (Visual Studio 2003) the detection +[note For Microsoft Visual C++ 7.1 (Visual Studio 2003) the detection of the Function Object's const qualification easily causes an internal error. Therefore the adapter is always treated as if it was const. ] -[blurb __tip__ If the type sequence passed to this template contains +[tip If the type sequence passed to this template contains non-reference elements, the element is copied only once - the call operator's signature is optimized automatically to avoid by-value parameters.] diff --git a/doc/fusion.qbk b/doc/fusion.qbk index f6c5f654..81542f02 100644 --- a/doc/fusion.qbk +++ b/doc/fusion.qbk @@ -20,11 +20,6 @@ ] ] -[def __note__ [$images/note.png]] -[def __alert__ [$images/alert.png]] -[def __tip__ [$images/tip.png]] -[def __caution__ [$images/caution.png]] - [def __spirit__ [@http://spirit.sourceforge.net Spirit]] [def __phoenix__ [@http://www.boost.org/libs/phoenix/index.html Phoenix]] [def __mpl__ [@http://www.boost.org/libs/mpl/index.html MPL]] @@ -55,6 +50,7 @@ [def __boost_func_factory__ [@http://www.boost.org/libs/functional/factory/doc/html/index.html Boost.Functional/Factory]] [def __boost_func_hash__ [@http://www.boost.org/doc/html/hash.html Boost.Functional/Hash]] [def __std_pair_doc__ [@http://www.sgi.com/tech/stl/pair.html `std::pair`]] +[def __std_tuple_doc__ [@http://en.cppreference.com/w/cpp/utility/tuple `std::tuple`]] [def __std_plus_doc__ [@http://www.sgi.com/tech/stl/plus.html `std::plus`]] [def __std_minus_doc__ [@http://www.sgi.com/tech/stl/minus.html `std::minus`]] @@ -321,17 +317,17 @@ [def __result_of_invoke__ [link fusion.functional.invocation.metafunctions.invoke `result_of::invoke`]] [def __result_of_invoke_procedure__ [link fusion.functional.invocation.metafunctions.invoke_proc `result_of::invoke_procedure`]] [def __result_of_invoke_function_object__ [link fusion.functional.invocation.metafunctions.invoke_fobj `result_of::invoke_function_object`]] -[def __result_of_make_fused__ [link fusion.functional.generation.metafunctions.mk_fused `make_fused`]] -[def __result_of_make_fused_procedure__ [link fusion.functional.generation.metafunctions.mk_fused_proc `make_fused_procedure`]] -[def __result_of_make_fused_function_object__ [link fusion.functional.generation.metafunctions.mk_fused_fobj `make_fused_function_object`]] -[def __result_of_make_unfused__ [link fusion.functional.generation.metafunctions.mk_unfused `make_unfused`]] +[def __result_of_make_fused__ [link fusion.functional.generation.metafunctions.mk_fused `result_of::make_fused`]] +[def __result_of_make_fused_procedure__ [link fusion.functional.generation.metafunctions.mk_fused_proc `result_of::make_fused_procedure`]] +[def __result_of_make_fused_function_object__ [link fusion.functional.generation.metafunctions.mk_fused_fobj `result_of::make_fused_function_object`]] +[def __result_of_make_unfused__ [link fusion.functional.generation.metafunctions.mk_unfused `result_of::make_unfused`]] [def __recursive_inline__ [link fusion.notes.recursive_inlined_functions Recursive Inlined Functions]] [def __overloaded_functions__ [link fusion.notes.overloaded_functions Overloaded Functions]] [def __tag_dispatching__ [link fusion.notes.tag_dispatching /tag dispatching/]] [def __element_conversion__ [link fusion.notes.element_conversion /element conversion/]] [def __see_element_conversion__ [link fusion.notes.element_conversion /see element conversion/]] -[def __note_boost_ref__ [link fusion.notes.boost__ref `boost::ref`]] +[def __note_ref_wrappers__ [link fusion.notes.reference_wrappers `Reference Wrappers`]] [def __quick_start__ [link fusion.quick_start Quick Start]] [def __organization__ [link fusion.organization Organization]] diff --git a/doc/html/images/alert.png b/doc/html/images/alert.png deleted file mode 100755 index b4645bc7..00000000 Binary files a/doc/html/images/alert.png and /dev/null differ diff --git a/doc/html/images/caution.png b/doc/html/images/caution.png deleted file mode 100644 index 5b7809ca..00000000 Binary files a/doc/html/images/caution.png and /dev/null differ diff --git a/doc/html/images/home.png b/doc/html/images/home.png deleted file mode 100755 index 5584aacb..00000000 Binary files a/doc/html/images/home.png and /dev/null differ diff --git a/doc/html/images/important.png b/doc/html/images/important.png deleted file mode 100644 index 12c90f60..00000000 Binary files a/doc/html/images/important.png and /dev/null differ diff --git a/doc/html/images/next.png b/doc/html/images/next.png deleted file mode 100755 index 59800b4e..00000000 Binary files a/doc/html/images/next.png and /dev/null differ diff --git a/doc/html/images/note.png b/doc/html/images/note.png deleted file mode 100755 index 3ed047ca..00000000 Binary files a/doc/html/images/note.png and /dev/null differ diff --git a/doc/html/images/prev.png b/doc/html/images/prev.png deleted file mode 100755 index d88a40f9..00000000 Binary files a/doc/html/images/prev.png and /dev/null differ diff --git a/doc/html/images/smiley.png b/doc/html/images/smiley.png deleted file mode 100755 index 30a77f71..00000000 Binary files a/doc/html/images/smiley.png and /dev/null differ diff --git a/doc/html/images/tip.png b/doc/html/images/tip.png deleted file mode 100755 index 9f596b0b..00000000 Binary files a/doc/html/images/tip.png and /dev/null differ diff --git a/doc/html/images/up.png b/doc/html/images/up.png deleted file mode 100755 index 17d9c3ec..00000000 Binary files a/doc/html/images/up.png and /dev/null differ diff --git a/doc/html/images/warning.png b/doc/html/images/warning.png deleted file mode 100644 index 1c33db8f..00000000 Binary files a/doc/html/images/warning.png and /dev/null differ diff --git a/doc/html/index.html b/doc/html/index.html index 03b417ee..0fd880b6 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -167,6 +167,7 @@
Array
std::pair
+
std::tuple
mpl sequence
boost::array
boost::tuple
diff --git a/doc/iterator.qbk b/doc/iterator.qbk index 50430a4d..d400003c 100644 --- a/doc/iterator.qbk +++ b/doc/iterator.qbk @@ -67,8 +67,7 @@ the following expressions are valid: ] [heading Expression Semantics] -[ -table +[table [[Expression] [Semantics]] [[`__next__(i)`] [An iterator to the element following `i`]] [[`i == j`] [Iterator equality comparison]] @@ -418,15 +417,15 @@ Moves an iterator by a specified distance. [heading Synopsis] template< - typename I, - typename M + typename M, + typename I > typename __result_of_advance__::type advance(I const& i); [table Parameters [[Parameter] [Requirement] [Description]] [[`i`] [Model of __forward_iterator__] [Iterator to move relative to]] - [[`N`] [An __mpl_integral_constant__] [Number of positions to move]] + [[`M`] [An __mpl_integral_constant__] [Number of positions to move]] ] [heading Expression Semantics] @@ -455,8 +454,8 @@ Moves an iterator by a specified distance. [heading Synopsis] template< - typename I, - int N + int N, + typename I > typename __result_of_advance_c__::type advance_c(I const& i); @@ -537,7 +536,7 @@ Dereferences an iterator. template< typename I > - typename __result_of_deref__::type operator*(__unspecified__ const& i); + typename __result_of_deref__::type operator*(I const& i); [table Parameters [[Parameter] [Requirement] [Description]] diff --git a/doc/notes.qbk b/doc/notes.qbk index 26a938fb..02b1437f 100644 --- a/doc/notes.qbk +++ b/doc/notes.qbk @@ -100,7 +100,7 @@ Array arguments are deduced to reference to const types. For example [footnote Note that the type of a string literal is an array of const characters, not `const char*`. To get __make_list__ to create a __list__ with an element of a non-const array type one must use the `ref` wrapper -(see __note_boost_ref__).]: +(see __note_ref_wrappers__).]: __make_list__("Donald", "Daisy") @@ -121,7 +121,7 @@ creates a __list__ of type __list__ -[heading boost::ref] +[heading Reference Wrappers] Fusion's generation functions (e.g. __make_list__) by default stores the element types as plain non-reference types. Example: @@ -151,6 +151,8 @@ For example: See __boost_ref__ for details. +Since C++11, the standard reference wrappers (`std::ref` and `std::cref`) work as well. + [heading adt_attribute_proxy] To adapt arbitrary data types that do not allow direct access to their members, diff --git a/doc/organization.qbk b/doc/organization.qbk index e3dd7fb4..b7166f5d 100644 --- a/doc/organization.qbk +++ b/doc/organization.qbk @@ -36,20 +36,26 @@ link against. * tuple * algorithm + * auxiliary * iteration * query * transformation * adapted + * adt * array - * mpl + * boost::array * boost::tuple + * mpl * std_pair + * std_tuple * struct - * variant * view * filter_view + * flatten_view * iterator_range * joint_view + * nview + * repetitive_view * reverse_view * single_view * transform_view @@ -63,6 +69,9 @@ link against. * generation * mpl * functional + * adapter + * generation + * invocation * sequence * comparison * intrinsic diff --git a/doc/preface.qbk b/doc/preface.qbk index 635b3bde..2fff963a 100644 --- a/doc/preface.qbk +++ b/doc/preface.qbk @@ -49,16 +49,11 @@ and traversal routines. It was an instant /AHA!/ moment. Some icons are used to mark certain topics indicative of their relevance. These icons precede some text to indicate: -[table Icons - [[Icon] [Name] [Meaning]] - [[__note__] [Note] [Information provided is auxiliary but will - give the reader a deeper insight into a specific - topic. May be skipped.]] - [[__alert__] [Alert] [Information provided is of utmost importance.]] - [[__caution__] [Caution] [A mild warning.]] - [[__tip__] [Tip] [A potentially useful and helpful piece of - information.]] -] +[note Information provided is auxiliary but will give the reader a deeper +insight into a specific topic. May be skipped.] +[important Information provided is of utmost importance.] +[caution A mild warning.] +[tip A potentially useful and helpful piece of information.] This documentation is automatically generated by Boost QuickBook documentation tool. QuickBook can be found in the __boost_tools__. diff --git a/doc/sequence.qbk b/doc/sequence.qbk index 2d323e37..5957a6e1 100644 --- a/doc/sequence.qbk +++ b/doc/sequence.qbk @@ -249,15 +249,18 @@ any Random Access Sequence the following must be met: [[Expression] [Compile Time Complexity]] [[`__result_of_begin__::type`] [Amortized constant time]] [[`__result_of_end__::type`] [Amortized constant time]] - [[`__result_of_at__::type`] [Amortized constant time]] - [[`__result_of_value_at__::type`] [Amortized constant time]] + [[`__result_of_at__::type`] [Amortized constant time]] + [[`__result_of_at_c__::type`] [Amortized constant time]] + [[`__result_of_value_at__::type`] [Amortized constant time]] + [[`__result_of_value_at_c__::type`] [Amortized constant time]] ] -[blurb __note__ `__result_of_at__` returns the actual type returned by -`__at__(s)`. In most cases, this is a reference. Hence, there is no way to -know the exact element type using `__result_of_at__`.The element at `N` +[note `__result_of_at__` returns the actual type returned by +`__at__(s)`. In most cases, this is a reference. Hence, there is no way to +know the exact element type using `__result_of_at__`.The element at `M` may actually be a reference to begin with. For this purpose, you can use -`__result_of_value_at__`.] +`__result_of_value_at__` (Note that, `__result_of_value_at_c__` +is a counterpart of `__result_of_at_c__` as well).] [heading Expression Semantics] @@ -327,11 +330,11 @@ For any Associative Sequence the following expressions must be valid: [[`__result_of_value_at_key__::type`] [Amortized constant time]] ] -[blurb __note__ `__result_of_at_key__` returns the actual type returned +[note `__result_of_at_key__` returns the actual type returned by `__at_key__(s)`. In most cases, this is a reference. Hence, there is no way to know the exact element type using `__result_of_at_key__`.The element at `K` may actually be a reference to begin with. For this purpose, -you can use `__result_of_value_at_key__`.] +you can use `__result_of_value_at_key__`.] [heading Expression Semantics] @@ -1323,7 +1326,7 @@ Returns the result type of __has_key__. [heading Description] Returns the result type of __at_key__[footnote __result_of_at_key__ -reflects the actual return type of the function __at_key__. __sequence__s +reflects the actual return type of the function __at_key__. __sequence__(s) typically return references to its elements via the __at_key__ function. If you want to get the actual element type, use __result_of_value_at_key__]. @@ -1445,7 +1448,7 @@ operators for free. The I/O operators: `<<` and `>>` work generically on all Fusion sequences. The I/O operators are overloaded in namespace `boost::fusion` -[footnote __sequences__ and __views__ residing in different namespaces +[footnote __sequence__(s) and __views__ residing in different namespaces will have to either provide their own I/O operators (possibly forwarding to fusion's I/O operators) or hoist fusion's I/O operators (using declaration), in their own namespaces for proper argument dependent @@ -1637,7 +1640,7 @@ compile time error. [*Semantics]: For each element, `e1`, in sequence `a`, and for each element, `e2`, in -sequence `b`, `e1 == e2` returns true. For any 2 zero length __sequence__s, +sequence `b`, `e1 == e2` returns true. For any 2 zero length __sequence__(s), e and f, e == f returns true. [heading Header] diff --git a/doc/support.qbk b/doc/support.qbk index 8c2ef1de..3e7b7a70 100644 --- a/doc/support.qbk +++ b/doc/support.qbk @@ -254,7 +254,8 @@ Metafunction to apply __element_conversion__ to the full argument type. It removes references to `const`, references to array types are kept, even if the array is `const`. Reference wrappers are removed (see -__note_boost_ref__). +__note_ref_wrappers__)[footnote Since C++11, the standard reference wrappers +are also removed.]. [heading Header] diff --git a/include/boost/fusion/adapted/adt/adapt_adt.hpp b/include/boost/fusion/adapted/adt/adapt_adt.hpp index 3be25b1e..7ff6f4ee 100644 --- a/include/boost/fusion/adapted/adt/adapt_adt.hpp +++ b/include/boost/fusion/adapted/adt/adapt_adt.hpp @@ -2,6 +2,7 @@ Copyright (c) 2001-2009 Joel de Guzman Copyright (c) 2009-2010 Hartmut Kaiser Copyright (c) 2010-2011 Christopher Schmidt + Copyright (c) 2013-2014 Damien Buhl 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) @@ -13,6 +14,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -22,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -32,17 +37,21 @@ #include #include #include +#include -#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_ADT_C( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, IS_VIEW, I, ATTRIBUTE) \ + BOOST_FUSION_ADAPT_ADT_C_BASE( \ + TEMPLATE_PARAMS_SEQ, \ + NAME_SEQ, \ + I, \ + BOOST_PP_IF(IS_VIEW, BOOST_FUSION_PROXY_PREFIX, BOOST_PP_EMPTY), \ + BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE), \ + BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ + BOOST_PP_IF( \ + BOOST_PP_LESS( \ + BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), 4) \ + , 1, 0)) #define BOOST_FUSION_ADAPT_TPL_ADT(TEMPLATE_PARAMS_SEQ, NAME_SEQ , ATTRIBUTES) \ BOOST_FUSION_ADAPT_STRUCT_BASE( \ diff --git a/include/boost/fusion/adapted/adt/adapt_assoc_adt.hpp b/include/boost/fusion/adapted/adt/adapt_assoc_adt.hpp index 12bf6aa2..49a8805d 100644 --- a/include/boost/fusion/adapted/adt/adapt_assoc_adt.hpp +++ b/include/boost/fusion/adapted/adt/adapt_assoc_adt.hpp @@ -2,6 +2,7 @@ Copyright (c) 2001-2009 Joel de Guzman Copyright (c) 2007 Dan Marsden Copyright (c) 2010-2011 Christopher Schmidt + Copyright (c) 2013-2014 Damien Buhl 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) @@ -22,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -35,25 +37,29 @@ #include #include #include - -#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 +#include #define BOOST_FUSION_ADAPT_ASSOC_ADT_C( \ - TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE) \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, IS_VIEW, I, ATTRIBUTE) \ \ - BOOST_FUSION_ADAPT_ADT_C_BASE(TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,ATTRIBUTE,5) \ + BOOST_FUSION_ADAPT_ADT_C_BASE( \ + TEMPLATE_PARAMS_SEQ, \ + NAME_SEQ, \ + I, \ + BOOST_PP_IF(IS_VIEW, BOOST_FUSION_PROXY_PREFIX, BOOST_PP_EMPTY), \ + BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE), \ + BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ + BOOST_PP_IF( \ + BOOST_PP_LESS( \ + BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), 5) \ + , 1, 0)) \ \ template< \ BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ > \ struct struct_assoc_key \ { \ - typedef BOOST_PP_TUPLE_ELEM(5, 4, ATTRIBUTE) type; \ + typedef BOOST_FUSION_ADAPT_ASSOC_ADT_WRAPPEDATTR_GET_KEY(ATTRIBUTE) type;\ }; #define BOOST_FUSION_ADAPT_ASSOC_TPL_ADT( \ diff --git a/include/boost/fusion/adapted/adt/detail/adapt_base.hpp b/include/boost/fusion/adapted/adt/detail/adapt_base.hpp index 23673886..dec17251 100644 --- a/include/boost/fusion/adapted/adt/detail/adapt_base.hpp +++ b/include/boost/fusion/adapted/adt/detail/adapt_base.hpp @@ -11,17 +11,18 @@ #define BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_HPP #include +#include +#include + #include #include #include #include #include +#include +#include -#if defined(BOOST_GCC) -#define BOOST_FUSION_ADT_CONSTEXPR BOOST_CXX14_CONSTEXPR -#else -#define BOOST_FUSION_ADT_CONSTEXPR BOOST_CONSTEXPR -#endif +#include #define BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_TEMPLATE_IMPL(TEMPLATE_PARAMS_SEQ) \ typename detail::get_identity< \ @@ -34,8 +35,72 @@ \ boost::remove_const::type>::type +#define BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR(ATTRIBUTE, \ + ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE) \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, \ + BOOST_PP_IF(DEDUCE_TYPE, 0, 2), ATTRIBUTE) + +#define BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_SETEXPR(ATTRIBUTE, \ + ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE) \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, \ + BOOST_PP_IF(DEDUCE_TYPE, 1, 3), ATTRIBUTE) + +#ifdef BOOST_MSVC +# define BOOST_FUSION_DEDUCED_ATTR_TYPE(NAME_SEQ, ATTRIBUTE, \ + ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \ + \ + BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + \ + struct deduced_attr_type { \ + static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \ + typedef \ + BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \ + BOOST_TYPEOF( PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR( \ + ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, 1)) type; \ + }; + +#else +# define BOOST_FUSION_DEDUCED_ATTR_TYPE(NAME_SEQ, ATTRIBUTE, \ + ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \ + struct deduced_attr_type { \ + static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \ + typedef BOOST_TYPEOF( PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR( \ + ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, 1)) type; \ + }; + +#endif + +#define BOOST_FUSION_ADT_ATTRIBUTE_TYPEOF( \ + NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \ + \ + BOOST_FUSION_DEDUCED_ATTR_TYPE( \ + NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \ + \ + typedef \ + BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \ + boost::remove_const< \ + BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \ + deduced_attr_type::type \ + >::type type; \ + \ + typedef \ + BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \ + boost::add_const< \ + BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \ + deduced_attr_type::type \ + >::type const_type; + +#define BOOST_FUSION_ADT_ATTRIBUTE_GIVENTYPE( \ + NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \ + \ + typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \ + typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) const_type; + + #define BOOST_FUSION_ADAPT_ADT_C_BASE( \ - TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,ATTRIBUTE,ATTRIBUTE_TUPEL_SIZE) \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,PREFIX, \ + ATTRIBUTE,ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE) \ \ template< \ BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ @@ -45,6 +110,16 @@ , I \ > \ { \ + \ + BOOST_PP_IF(DEDUCE_TYPE, \ + BOOST_FUSION_ADT_ATTRIBUTE_TYPEOF, \ + BOOST_FUSION_ADT_ATTRIBUTE_GIVENTYPE)( \ + NAME_SEQ, \ + ATTRIBUTE, \ + ATTRIBUTE_TUPEL_SIZE, \ + PREFIX, \ + TEMPLATE_PARAMS_SEQ) \ + \ template \ BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ static void \ @@ -52,23 +127,26 @@ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj, \ Val const& val) \ { \ - BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 3, ATTRIBUTE); \ + PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_SETEXPR(ATTRIBUTE, \ + ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE); \ } \ \ - BOOST_FUSION_ADT_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ - static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \ + BOOST_FUSION_GPU_ENABLED \ + static type \ 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); \ + return PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR(ATTRIBUTE, \ + ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE); \ } \ \ - BOOST_FUSION_ADT_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ - static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) \ + BOOST_FUSION_GPU_ENABLED \ + static const_type \ 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); \ + return PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR(ATTRIBUTE, \ + ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE); \ } \ }; \ \ @@ -81,7 +159,12 @@ , true \ > \ { \ - typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) type; \ + typedef \ + BOOST_PP_IF(BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), typename, ) \ + access::adt_attribute_access< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + >::const_type type; \ \ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ explicit \ @@ -90,7 +173,7 @@ : obj(&o) \ {} \ \ - BOOST_FUSION_ADT_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ + BOOST_FUSION_GPU_ENABLED \ type get() const \ { \ return access::adt_attribute_access< \ @@ -99,7 +182,7 @@ >::boost_fusion_adapt_adt_impl_get(*obj); \ } \ \ - BOOST_FUSION_ADT_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ + BOOST_FUSION_GPU_ENABLED \ operator type() const \ { \ return get(); \ @@ -117,7 +200,12 @@ , false \ > \ { \ - typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \ + typedef \ + BOOST_PP_IF(BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), typename, ) \ + access::adt_attribute_access< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + >::type type; \ \ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ explicit \ @@ -138,7 +226,7 @@ return *this; \ } \ \ - BOOST_FUSION_ADT_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ + BOOST_FUSION_GPU_ENABLED \ type get() const \ { \ return access::adt_attribute_access< \ @@ -147,7 +235,7 @@ >::boost_fusion_adapt_adt_impl_get(*obj); \ } \ \ - BOOST_FUSION_ADT_CONSTEXPR BOOST_FUSION_GPU_ENABLED \ + BOOST_FUSION_GPU_ENABLED \ operator type() const \ { \ return get(); \ @@ -164,7 +252,13 @@ , I \ > \ { \ - typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) lvalue; \ + typedef BOOST_PP_IF(BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), typename, ) \ + adt_attribute_proxy< \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ + , I \ + , false \ + >::type lvalue; \ + \ BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \ TEMPLATE_PARAMS_SEQ) \ \ diff --git a/include/boost/fusion/adapted/adt/detail/adapt_base_assoc_attr_filler.hpp b/include/boost/fusion/adapted/adt/detail/adapt_base_assoc_attr_filler.hpp new file mode 100644 index 00000000..b9c93b7d --- /dev/null +++ b/include/boost/fusion/adapted/adt/detail/adapt_base_assoc_attr_filler.hpp @@ -0,0 +1,61 @@ +/*============================================================================= + Copyright (c) 2013-2014 Damien Buhl + + 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_ADAPTER_ADT_DETAIL_ADAPT_BASE_ASSOC_ATTR_FILLER_HPP +#define BOOST_FUSION_ADAPTER_ADT_DETAIL_ADAPT_BASE_ASSOC_ATTR_FILLER_HPP + +#include + +#include + +#include +#include +#include +#include + +#if BOOST_PP_VARIADICS + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(...) \ + BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(__VA_ARGS__) \ + BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1 + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1(...) \ + BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(__VA_ARGS__) \ + BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0 + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(...) \ + ((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))) + +#else // BOOST_PP_VARIADICS + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(A, B, C, D, E) \ + BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(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) \ + BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(A, B, C, D, E) \ + BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0 + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(A, B, C, D, E) \ + BOOST_PP_IF(BOOST_PP_IS_EMPTY(A), \ + ((3, (C,D,E))), \ + ((5, (A,B,C,D,E))) \ + ) + +#endif // BOOST_PP_VARIADICS + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0_END +#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1_END + + +#define BOOST_FUSION_ADAPT_ASSOC_ADT_WRAPPEDATTR_GET_KEY(ATTRIBUTE) \ + BOOST_PP_TUPLE_ELEM( \ + BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ + BOOST_PP_SUB(BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), 1), \ + BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE)) + +#endif diff --git a/include/boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp b/include/boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp new file mode 100644 index 00000000..09bd4014 --- /dev/null +++ b/include/boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp @@ -0,0 +1,90 @@ +/*============================================================================= + Copyright (c) 2013-2014 Damien Buhl + + 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_ATTR_FILLER_HPP +#define BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +#define BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE) \ + BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE) + +#define BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE) \ + BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE) + +#if BOOST_PP_VARIADICS + +# define BOOST_FUSION_ADAPT_ADT_FILLER_0(...) \ + BOOST_FUSION_ADAPT_ADT_FILLER(__VA_ARGS__) \ + BOOST_FUSION_ADAPT_ADT_FILLER_1 + +# define BOOST_FUSION_ADAPT_ADT_FILLER_1(...) \ + BOOST_FUSION_ADAPT_ADT_FILLER(__VA_ARGS__) \ + 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_FILLER(...) \ + BOOST_PP_IF( \ + BOOST_PP_OR( \ + BOOST_PP_IS_EMPTY(BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)), \ + BOOST_PP_IS_EMPTY(BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__))), \ + BOOST_FUSION_ADAPT_ADT_WRAP_ATTR( \ + BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__), \ + BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(__VA_ARGS__) \ + ), \ + BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(__VA_ARGS__)) + +# define BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(...) \ + ((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))) + +# define BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(...) \ + BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_REST_N( \ + BOOST_PP_SUB(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 1), \ + BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))) + +#else // BOOST_PP_VARIADICS + +# define BOOST_FUSION_ADAPT_ADT_FILLER_0(A, B, C, D) \ + BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A,B,C,D) \ + BOOST_FUSION_ADAPT_ADT_FILLER_1 + +# define BOOST_FUSION_ADAPT_ADT_FILLER_1(A, B, C, D) \ + BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(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_WRAP_ATTR(A, B, C, D) \ + BOOST_PP_IF(BOOST_PP_IS_EMPTY(A), \ + ((2, (C,D))), \ + ((4, (A,B,C,D))) \ + ) + +#endif // BOOST_PP_VARIADICS + +#endif diff --git a/include/boost/fusion/adapted/boost_array/array_iterator.hpp b/include/boost/fusion/adapted/boost_array/array_iterator.hpp index 8d85ba9c..ca8da0a2 100644 --- a/include/boost/fusion/adapted/boost_array/array_iterator.hpp +++ b/include/boost/fusion/adapted/boost_array/array_iterator.hpp @@ -109,4 +109,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::array_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp b/include/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp index 40c5d79c..850eef5f 100644 --- a/include/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp +++ b/include/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp @@ -207,6 +207,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::boost_tuple_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/adapted/mpl/mpl_iterator.hpp b/include/boost/fusion/adapted/mpl/mpl_iterator.hpp index 43748d98..87de32ad 100644 --- a/include/boost/fusion/adapted/mpl/mpl_iterator.hpp +++ b/include/boost/fusion/adapted/mpl/mpl_iterator.hpp @@ -114,6 +114,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::mpl_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp b/include/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp index d5803f9c..a3421e0f 100644 --- a/include/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp +++ b/include/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp @@ -107,6 +107,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::std_tuple_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/adapted/struct/adapt_assoc_struct.hpp b/include/boost/fusion/adapted/struct/adapt_assoc_struct.hpp index eca77d61..eab4e1bb 100644 --- a/include/boost/fusion/adapted/struct/adapt_assoc_struct.hpp +++ b/include/boost/fusion/adapted/struct/adapt_assoc_struct.hpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -35,32 +36,35 @@ #include #include -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(X, Y, Z) \ - ((X, Y, Z)) BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1 -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1(X, Y, Z) \ - ((X, Y, Z)) BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0 -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0_END -#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1_END - #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_C_BASE( \ - TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,PREFIX,ATTRIBUTE) \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,IS_VIEW,I,PREFIX,ATTRIBUTE) \ \ BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ - TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, PREFIX, ATTRIBUTE, 3) \ + TEMPLATE_PARAMS_SEQ, \ + NAME_SEQ, \ + IS_VIEW, \ + I, \ + PREFIX, \ + BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE), \ + BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ + BOOST_PP_IF(BOOST_PP_LESS( \ + BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE),3), 1, 0)) \ \ template< \ BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ > \ struct struct_assoc_key \ { \ - typedef BOOST_PP_TUPLE_ELEM(3, 2, ATTRIBUTE) type; \ + typedef \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAPPEDATTR_GET_KEY(ATTRIBUTE) type; \ }; #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_C( \ - TEMPLATE_PARAMS_SEQ,NAME_SEQ, I, ATTRIBUTE) \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,IS_VIEW, I, ATTRIBUTE) \ \ BOOST_FUSION_ADAPT_ASSOC_STRUCT_C_BASE( \ - TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,BOOST_PP_EMPTY,ATTRIBUTE) + TEMPLATE_PARAMS_SEQ,NAME_SEQ,IS_VIEW,I,BOOST_PP_EMPTY,ATTRIBUTE) + #define BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( \ TEMPLATE_PARAMS_SEQ, NAME_SEQ, ATTRIBUTES) \ diff --git a/include/boost/fusion/adapted/struct/adapt_struct.hpp b/include/boost/fusion/adapted/struct/adapt_struct.hpp index f60ca03e..e96e7c76 100644 --- a/include/boost/fusion/adapted/struct/adapt_struct.hpp +++ b/include/boost/fusion/adapted/struct/adapt_struct.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2001-2007 Joel de Guzman Copyright (c) 2009-2011 Christopher Schmidt + Copyright (c) 2013-2014 Damien Buhl 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) @@ -10,8 +11,12 @@ #define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_HPP #include +#include #include #include +#include +#include +#include #include #include #include @@ -19,6 +24,7 @@ #include #include +#include #include #include #include @@ -30,43 +36,88 @@ #include #include -#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(X, Y) \ - ((X, Y)) BOOST_FUSION_ADAPT_STRUCT_FILLER_1 -#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(X, Y) \ - ((X, Y)) BOOST_FUSION_ADAPT_STRUCT_FILLER_0 -#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0_END -#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1_END +#define BOOST_FUSION_ADAPT_STRUCT_C( \ + TEMPLATE_PARAMS_SEQ, NAME_SEQ, IS_VIEW, I, ATTRIBUTE) \ + BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ + TEMPLATE_PARAMS_SEQ, \ + NAME_SEQ, \ + IS_VIEW, \ + I, \ + BOOST_PP_IF(IS_VIEW, BOOST_FUSION_PROXY_PREFIX, BOOST_PP_EMPTY), \ + BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE), \ + BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ + BOOST_PP_IF( \ + BOOST_PP_LESS( \ + BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), 2) \ + , 1, 0)) -#define BOOST_FUSION_ADAPT_STRUCT_C(TEMPLATE_PARAMS_SEQ, NAME_SEQ, I, ATTRIBUTE)\ - BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ - TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,BOOST_PP_EMPTY,ATTRIBUTE,2) -#define BOOST_FUSION_ADAPT_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) +#if BOOST_PP_VARIADICS -#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) +# define BOOST_FUSION_ADAPT_TPL_STRUCT(TEMPLATE_PARAMS_SEQ,NAME_SEQ, ...) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (1)TEMPLATE_PARAMS_SEQ, \ + (1)NAME_SEQ, \ + struct_tag, \ + 0, \ + BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(__VA_ARGS__), \ + BOOST_FUSION_ADAPT_STRUCT_C) + +# define BOOST_FUSION_ADAPT_STRUCT(NAME, ...) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + struct_tag, \ + 0, \ + BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(__VA_ARGS__), \ + BOOST_FUSION_ADAPT_STRUCT_C) + +# define BOOST_FUSION_ADAPT_STRUCT_AS_VIEW(NAME, ...) \ + BOOST_FUSION_ADAPT_STRUCT_BASE( \ + (0), \ + (0)(NAME), \ + struct_tag, \ + 1, \ + BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(__VA_ARGS__), \ + BOOST_FUSION_ADAPT_STRUCT_C) + +#else // BOOST_PP_VARIADICS + +# 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, \ + BOOST_PP_CAT( \ + BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,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 // BOOST_PP_VARIADICS #endif diff --git a/include/boost/fusion/adapted/struct/adapt_struct_named.hpp b/include/boost/fusion/adapted/struct/adapt_struct_named.hpp index 3f29f3a3..791fb5b0 100644 --- a/include/boost/fusion/adapted/struct/adapt_struct_named.hpp +++ b/include/boost/fusion/adapted/struct/adapt_struct_named.hpp @@ -15,26 +15,41 @@ #include #include -#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 +#ifdef BOOST_PP_VARIADICS -#define BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( \ - WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ +# define BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( \ + WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ...) \ \ - BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \ - WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \ + 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)) + BOOST_FUSION_ADAPT_STRUCT_AS_VIEW( \ + BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION( \ + (0)NAMESPACE_SEQ)NAME, \ + __VA_ARGS__) -#define BOOST_FUSION_ADAPT_STRUCT_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \ - BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( \ - WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES) +# define BOOST_FUSION_ADAPT_STRUCT_NAMED(WRAPPED_TYPE, NAME, ...) \ + BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( \ + WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,__VA_ARGS__) + + +#else // BOOST_PP_VARIADICS + +# 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, \ + ATTRIBUTES) + +# define BOOST_FUSION_ADAPT_STRUCT_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \ + BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( \ + WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES) + +#endif #endif diff --git a/include/boost/fusion/adapted/struct/define_assoc_struct.hpp b/include/boost/fusion/adapted/struct/define_assoc_struct.hpp index 1f5ce8dc..f4a3679d 100644 --- a/include/boost/fusion/adapted/struct/define_assoc_struct.hpp +++ b/include/boost/fusion/adapted/struct/define_assoc_struct.hpp @@ -12,6 +12,13 @@ #include #include +#define BOOST_FUSION_DEFINE_ASSOC_STRUCT_FILLER_0(X, Y, Z) \ + ((X, Y, Z)) BOOST_FUSION_DEFINE_ASSOC_STRUCT_FILLER_1 +#define BOOST_FUSION_DEFINE_ASSOC_STRUCT_FILLER_1(X, Y, Z) \ + ((X, Y, Z)) BOOST_FUSION_DEFINE_ASSOC_STRUCT_FILLER_0 +#define BOOST_FUSION_DEFINE_ASSOC_STRUCT_FILLER_0_END +#define BOOST_FUSION_DEFINE_ASSOC_STRUCT_FILLER_1_END + #define BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT( \ TEMPLATE_PARAMS_SEQ, NAMESPACE_SEQ, NAME, ATTRIBUTES) \ \ @@ -20,7 +27,7 @@ (0)NAMESPACE_SEQ, \ NAME, \ BOOST_PP_CAT( \ - BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_DEFINE_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ 3) \ \ BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( \ @@ -34,7 +41,7 @@ (0)NAMESPACE_SEQ, \ NAME, \ BOOST_PP_CAT( \ - BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ + BOOST_FUSION_DEFINE_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ 3) \ \ BOOST_FUSION_ADAPT_ASSOC_STRUCT( \ diff --git a/include/boost/fusion/adapted/struct/define_struct.hpp b/include/boost/fusion/adapted/struct/define_struct.hpp index fa1f549f..29785436 100644 --- a/include/boost/fusion/adapted/struct/define_struct.hpp +++ b/include/boost/fusion/adapted/struct/define_struct.hpp @@ -19,7 +19,7 @@ TEMPLATE_PARAMS_SEQ, \ (0)NAMESPACE_SEQ, \ NAME, \ - BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ + BOOST_PP_CAT(BOOST_FUSION_DEFINE_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ 2) \ \ BOOST_FUSION_ADAPT_TPL_STRUCT( \ @@ -32,7 +32,7 @@ BOOST_FUSION_DEFINE_STRUCT_IMPL( \ (0)NAMESPACE_SEQ, \ NAME, \ - BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ + BOOST_PP_CAT(BOOST_FUSION_DEFINE_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ 2) \ \ BOOST_FUSION_ADAPT_STRUCT( \ diff --git a/include/boost/fusion/adapted/struct/detail/adapt_auto.hpp b/include/boost/fusion/adapted/struct/detail/adapt_auto.hpp new file mode 100644 index 00000000..5178150b --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/adapt_auto.hpp @@ -0,0 +1,15 @@ +/*============================================================================= + Copyright (c) 2013-2014 Damien Buhl + + 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_AUTO_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_AUTO_HPP + +#include + +#define BOOST_FUSION_ADAPT_AUTO BOOST_PP_EMPTY() + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/adapt_base.hpp b/include/boost/fusion/adapted/struct/detail/adapt_base.hpp index 2a0fcf7c..8ec467ae 100644 --- a/include/boost/fusion/adapted/struct/detail/adapt_base.hpp +++ b/include/boost/fusion/adapted/struct/detail/adapt_base.hpp @@ -2,6 +2,7 @@ Copyright (c) 2001-2009 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden Copyright (c) 2009-2011 Christopher Schmidt + Copyright (c) 2013-2014 Damien Buhl 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) @@ -13,6 +14,8 @@ #include #include #include +#include +#include #include #include @@ -25,12 +28,16 @@ #include #include #include +#include #include #include #include #include #include +#include + + #define BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME_TEMPLATE_PARAMS(SEQ) \ BOOST_PP_SEQ_HEAD(SEQ) \ BOOST_PP_EMPTY() @@ -55,6 +62,49 @@ BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL, \ BOOST_PP_TUPLE_EAT(1))(SEQ) +#ifdef BOOST_MSVC +# define BOOST_FUSION_ATTRIBUTE_TYPEOF( \ + NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \ + \ + BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \ + TEMPLATE_PARAMS_SEQ) \ + \ + struct deduced_attr_type { \ + static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \ + typedef \ + BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), typename, ) \ + BOOST_TYPEOF( PREFIX() obj.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, \ + 0, ATTRIBUTE)) \ + type; \ + }; \ + \ + typedef \ + BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), typename, ) \ + deduced_attr_type::type attribute_type; + +#else +# define BOOST_FUSION_ATTRIBUTE_TYPEOF( \ + NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \ + \ + struct deduced_attr_type { \ + static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \ + typedef BOOST_TYPEOF( \ + PREFIX() obj.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE)) \ + type; \ + }; \ + \ + typedef \ + BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), typename, ) \ + deduced_attr_type::type attribute_type; + +#endif + +#define BOOST_FUSION_ATTRIBUTE_GIVENTYPE( \ + NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \ + typedef \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) attribute_type; + + #ifdef BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS # define BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \ MODIFIER, TEMPLATE_PARAMS_SEQ, NAME_SEQ, TAG) \ @@ -83,9 +133,10 @@ #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), \ + BOOST_PP_TUPLE_ELEM(4,0,DATA)( \ + BOOST_PP_TUPLE_ELEM(4,1,DATA), \ + BOOST_PP_TUPLE_ELEM(4,2,DATA), \ + BOOST_PP_TUPLE_ELEM(4,3,DATA), \ I, \ ATTRIBUTE) @@ -107,7 +158,9 @@ #endif #define BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ - TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,PREFIX,ATTRIBUTE,ATTRIBUTE_TUPEL_SIZE) \ + TEMPLATE_PARAMS_SEQ,NAME_SEQ,IS_VIEW, \ + I,PREFIX,ATTRIBUTE,ATTRIBUTE_TUPEL_SIZE, \ + DEDUCE_TYPE) \ \ template< \ BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ @@ -117,9 +170,14 @@ , I \ > \ { \ - typedef \ - BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \ - attribute_type; \ + BOOST_PP_IF(DEDUCE_TYPE, \ + BOOST_FUSION_ATTRIBUTE_TYPEOF, BOOST_FUSION_ATTRIBUTE_GIVENTYPE)( \ + NAME_SEQ, \ + ATTRIBUTE, \ + ATTRIBUTE_TUPEL_SIZE, \ + PREFIX, \ + TEMPLATE_PARAMS_SEQ) \ + \ BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \ TEMPLATE_PARAMS_SEQ) \ \ @@ -143,7 +201,8 @@ call(Seq& seq) \ { \ return seq.PREFIX() \ - BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE); \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, \ + BOOST_PP_IF(DEDUCE_TYPE, 0, 1), ATTRIBUTE); \ } \ }; \ }; \ @@ -163,7 +222,9 @@ call() \ { \ return BOOST_PP_STRINGIZE( \ - BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)); \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, \ + BOOST_PP_IF(DEDUCE_TYPE, 0, 1), \ + ATTRIBUTE)); \ } \ }; @@ -195,7 +256,7 @@ namespace boost BOOST_PP_TUPLE_EAT(4))( \ 1, \ BOOST_FUSION_ADAPT_STRUCT_BASE_UNPACK_AND_CALL, \ - (ATTRIBUTES_CALLBACK,TEMPLATE_PARAMS_SEQ,NAME_SEQ), \ + (ATTRIBUTES_CALLBACK,TEMPLATE_PARAMS_SEQ,NAME_SEQ, IS_VIEW),\ BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ)) \ \ template< \ diff --git a/include/boost/fusion/adapted/struct/detail/adapt_base_assoc_attr_filler.hpp b/include/boost/fusion/adapted/struct/detail/adapt_base_assoc_attr_filler.hpp new file mode 100644 index 00000000..c75e83c3 --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/adapt_base_assoc_attr_filler.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2013-2014 Damien Buhl + + 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_ASSOC_ATTR_FILLER_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ASSOC_ATTR_FILLER_HPP + +#include + +#include + +#include +#include +#include +#include +#include + +#if BOOST_PP_VARIADICS + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(...) \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(__VA_ARGS__) \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1 + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1(...) \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(__VA_ARGS__) \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0 + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(...) \ + ((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))) + +#else // BOOST_PP_VARIADICS + + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(X, Y, Z) \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z) \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1 + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1(X, Y, Z) \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z) \ + BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0 + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z) \ + BOOST_PP_IF(BOOST_PP_IS_EMPTY(X), \ + ((2, (Y,Z))), \ + ((3, (X,Y,Z))) \ + ) + +#endif // BOOST_PP_VARIADICS + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0_END +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1_END + + +#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAPPEDATTR_GET_KEY(ATTRIBUTE) \ + BOOST_PP_TUPLE_ELEM( \ + BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ + BOOST_PP_SUB(BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), 1), \ + BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE)) + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp b/include/boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp new file mode 100644 index 00000000..69d5b204 --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp @@ -0,0 +1,64 @@ +/*============================================================================= + Copyright (c) 2013-2014 Damien Buhl + + 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_ATTR_FILLER_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +#define BOOST_FUSION_ADAPT_STRUCT_FILLER_0(X, Y) \ + BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(X,Y) \ + BOOST_FUSION_ADAPT_STRUCT_FILLER_1 + +#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1(X, Y) \ + BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(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_WRAP_ATTR(X, Y) \ + BOOST_PP_IF(BOOST_PP_IS_EMPTY(X), \ + ((1, (Y))), \ + ((2, (X,Y))) \ + ) + +#define BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE) \ + BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE) + +#define BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE) \ + BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE) + + +#if BOOST_PP_VARIADICS + +# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER_OP(r, unused, elem) \ + BOOST_PP_IF(BOOST_FUSION_PP_IS_SEQ(elem), \ + BOOST_PP_CAT( BOOST_FUSION_ADAPT_STRUCT_FILLER_0 elem ,_END), \ + BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(BOOST_FUSION_ADAPT_AUTO, \ + elem)) + +# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(...) \ + BOOST_PP_SEQ_PUSH_FRONT( \ + BOOST_PP_SEQ_FOR_EACH( \ + BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER_OP, \ + unused, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)), \ + (0,0)) + +#endif // BOOST_PP_VARIADICS + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/adapt_is_tpl.hpp b/include/boost/fusion/adapted/struct/detail/adapt_is_tpl.hpp new file mode 100644 index 00000000..2b54a2c0 --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/adapt_is_tpl.hpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2013-2014 Damien Buhl + + 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_IS_TPL_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_IS_TPL_HPP + +#define BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ) \ + BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ) + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/define_struct.hpp b/include/boost/fusion/adapted/struct/detail/define_struct.hpp index 3b4d1e3f..25542920 100644 --- a/include/boost/fusion/adapted/struct/detail/define_struct.hpp +++ b/include/boost/fusion/adapted/struct/detail/define_struct.hpp @@ -34,6 +34,13 @@ #include #include +#define BOOST_FUSION_DEFINE_STRUCT_FILLER_0(X, Y) \ + ((X, Y)) BOOST_FUSION_DEFINE_STRUCT_FILLER_1 +#define BOOST_FUSION_DEFINE_STRUCT_FILLER_1(X, Y) \ + ((X, Y)) BOOST_FUSION_DEFINE_STRUCT_FILLER_0 +#define BOOST_FUSION_DEFINE_STRUCT_FILLER_0_END +#define BOOST_FUSION_DEFINE_STRUCT_FILLER_1_END + #define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I( \ R, ATTRIBUTE_TUPEL_SIZE, I, ATTRIBUTE) \ \ diff --git a/include/boost/fusion/adapted/struct/detail/define_struct_inline.hpp b/include/boost/fusion/adapted/struct/detail/define_struct_inline.hpp index d721feb8..a5a3ae06 100644 --- a/include/boost/fusion/adapted/struct/detail/define_struct_inline.hpp +++ b/include/boost/fusion/adapted/struct/detail/define_struct_inline.hpp @@ -302,7 +302,7 @@ #define BOOST_FUSION_DEFINE_STRUCT_INLINE_MEMBERS(NAME, ATTRIBUTES) \ BOOST_FUSION_DEFINE_STRUCT_MEMBERS_IMPL( \ NAME, \ - BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0 ATTRIBUTES,_END)) + BOOST_PP_CAT(BOOST_FUSION_DEFINE_STRUCT_FILLER_0 ATTRIBUTES,_END)) // Note: can't compute BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ) directly because // ATTRIBUTES_SEQ may be empty and calling BOOST_PP_SEQ_SIZE on an empty @@ -316,7 +316,7 @@ #define BOOST_FUSION_DEFINE_STRUCT_INLINE_ITERATOR(NAME, ATTRIBUTES) \ BOOST_FUSION_DEFINE_STRUCT_ITERATOR_IMPL( \ NAME, \ - BOOST_PP_CAT(BOOST_FUSION_ADAPT_STRUCT_FILLER_0 ATTRIBUTES,_END)) + BOOST_PP_CAT(BOOST_FUSION_DEFINE_STRUCT_FILLER_0 ATTRIBUTES,_END)) #define BOOST_FUSION_DEFINE_STRUCT_ITERATOR_IMPL(NAME, ATTRIBUTES_SEQ) \ BOOST_FUSION_DEFINE_STRUCT_INLINE_ITERATOR_IMPL_IMPL( \ diff --git a/include/boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp b/include/boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp new file mode 100644 index 00000000..95f11050 --- /dev/null +++ b/include/boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + BOOST_PP_VARIADICS version of BOOST_PP_IS_SEQ inspired from + boost/mpl/aux_/preprocessor/is_seq.hpp, original copyrights goes to : + + Copyright Paul Mensonides 2003 + Copyright Aleksey Gurtovoy 2003-2004 + + 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_PREPROCESSOR_IS_SEQ_HPP +#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_PREPROCESSOR_IS_SEQ_HPP + +#include +#include +#include +#include +#include + +#if BOOST_PP_VARIADICS + +#define BOOST_FUSION_PP_IS_SEQ(seq) BOOST_PP_CAT(BOOST_FUSION_PP_IS_SEQ_, \ + BOOST_FUSION_PP_IS_SEQ_0 seq BOOST_PP_RPAREN()) + +#define BOOST_FUSION_PP_IS_SEQ_0(...) \ + BOOST_FUSION_PP_IS_SEQ_1(__VA_ARGS__ + +#define BOOST_FUSION_PP_IS_SEQ_ALWAYS_0(...) \ + 0 + +#define BOOST_FUSION_PP_IS_SEQ_BOOST_FUSION_PP_IS_SEQ_0 \ + BOOST_FUSION_PP_IS_SEQ_ALWAYS_0( + +#define BOOST_FUSION_PP_IS_SEQ_BOOST_FUSION_PP_IS_SEQ_1(...) \ + 1 + +#endif // BOOST_PP_VARIADICS + +#endif diff --git a/include/boost/fusion/adapted/struct/detail/proxy_type.hpp b/include/boost/fusion/adapted/struct/detail/proxy_type.hpp index fcee36ee..b4cb55bb 100644 --- a/include/boost/fusion/adapted/struct/detail/proxy_type.hpp +++ b/include/boost/fusion/adapted/struct/detail/proxy_type.hpp @@ -12,6 +12,8 @@ #include #include +#define BOOST_FUSION_PROXY_PREFIX() obj. + #define BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \ WRAPPED_TYPE,NAMESPACE_SEQ,NAME) \ \ diff --git a/include/boost/fusion/container/deque/deque_iterator.hpp b/include/boost/fusion/container/deque/deque_iterator.hpp index e9a79de2..c2203796 100644 --- a/include/boost/fusion/container/deque/deque_iterator.hpp +++ b/include/boost/fusion/container/deque/deque_iterator.hpp @@ -118,4 +118,13 @@ namespace boost { namespace fusion { }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::deque_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/container/deque/detail/cpp03/deque.hpp b/include/boost/fusion/container/deque/detail/cpp03/deque.hpp index b5bacbcf..7c9417e5 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/deque.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/deque.hpp @@ -141,7 +141,10 @@ FUSION_HASH if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) {} template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - deque(deque&& seq) + deque(deque&& seq + , typename disable_if< + is_convertible, T0> + >::type* /*dummy*/ = 0) : base(std::forward>(seq)) {} template diff --git a/include/boost/fusion/container/deque/detail/keyed_element.hpp b/include/boost/fusion/container/deque/detail/keyed_element.hpp index 834ef152..24b5979d 100644 --- a/include/boost/fusion/container/deque/detail/keyed_element.hpp +++ b/include/boost/fusion/container/deque/detail/keyed_element.hpp @@ -66,7 +66,8 @@ namespace boost { namespace fusion { namespace detail template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - keyed_element(keyed_element const& rhs) + keyed_element(keyed_element const& rhs + , typename enable_if >::type* = 0) : Rest(rhs.get_base()), value_(rhs.value_) {} diff --git a/include/boost/fusion/container/list/cons_iterator.hpp b/include/boost/fusion/container/list/cons_iterator.hpp index 1308d987..58b7fd9e 100644 --- a/include/boost/fusion/container/list/cons_iterator.hpp +++ b/include/boost/fusion/container/list/cons_iterator.hpp @@ -99,4 +99,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::cons_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/container/map/detail/cpp03/map.hpp b/include/boost/fusion/container/map/detail/cpp03/map.hpp index 25178fe8..e2f471b5 100644 --- a/include/boost/fusion/container/map/detail/cpp03/map.hpp +++ b/include/boost/fusion/container/map/detail/cpp03/map.hpp @@ -24,6 +24,15 @@ #include #include #include +#include +#include +#include +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \ + defined(BOOST_MSVC) && (BOOST_MSVC == 1700) +// see map_forward_ctor.hpp +#include +#include +#endif #if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) #include @@ -45,6 +54,8 @@ #pragma wave option(preserve: 1) #endif +#define FUSION_HASH # + namespace boost { namespace fusion { struct void_; @@ -69,6 +80,10 @@ namespace boost { namespace fusion map() : data() {} + BOOST_FUSION_GPU_ENABLED + map(map const& rhs) + : data(rhs.data) {} + template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED map(Sequence const& rhs) @@ -91,6 +106,34 @@ namespace boost { namespace fusion return *this; } +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +#endif +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \ + (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + map(map&& rhs) + : data(std::move(rhs.data)) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + map& operator=(T&& rhs) + { + data = BOOST_FUSION_FWD_ELEM(T, rhs); + return *this; + } + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + map& operator=(map&& rhs) + { + data = std::move(rhs.data); + return *this; + } +#endif +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH endif +#endif + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED storage_type& get_data() { return data; } BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -102,6 +145,8 @@ namespace boost { namespace fusion }; }} +#undef FUSION_HASH + #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) #pragma wave option(output: null) #endif diff --git a/include/boost/fusion/container/map/detail/cpp03/map_forward_ctor.hpp b/include/boost/fusion/container/map/detail/cpp03/map_forward_ctor.hpp index 8cf9fa48..18864e87 100644 --- a/include/boost/fusion/container/map/detail/cpp03/map_forward_ctor.hpp +++ b/include/boost/fusion/container/map/detail/cpp03/map_forward_ctor.hpp @@ -8,15 +8,14 @@ #if !defined(FUSION_MAP_FORWARD_CTOR_07222005_0106) #define FUSION_MAP_FORWARD_CTOR_07222005_0106 -#include -#include -#include +#define FUSION_FORWARD_CTOR_FORWARD(z, n, _) BOOST_FUSION_FWD_ELEM(U##n, _##n) #define BOOST_PP_FILENAME_1 \ #define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_MAP_SIZE) #include BOOST_PP_ITERATE() +#undef FUSION_FORWARD_CTOR_FORWARD #endif #else // defined(BOOST_PP_IS_ITERATING) /////////////////////////////////////////////////////////////////////////////// @@ -34,6 +33,31 @@ map(BOOST_PP_ENUM_BINARY_PARAMS(N, typename detail::call_param::type arg)) : data(BOOST_PP_ENUM_PARAMS(N, arg)) {} +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +#endif +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \ + (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) + template + BOOST_FUSION_GPU_ENABLED +#if N == 1 + explicit +#endif + map(BOOST_PP_ENUM_BINARY_PARAMS(N, U, && arg) +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) && \ + N == 1 + // workaround for MSVC 10 +FUSION_HASH if defined(BOOST_MSVC) && (BOOST_MSVC == 1700) + , typename enable_if >::type* = 0 +FUSION_HASH endif +#endif + ) + : data(BOOST_PP_ENUM(N, FUSION_FORWARD_CTOR_FORWARD, arg)) {} +#endif +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH endif +#endif + #undef N #endif // defined(BOOST_PP_IS_ITERATING) diff --git a/include/boost/fusion/container/map/map_iterator.hpp b/include/boost/fusion/container/map/map_iterator.hpp index 99f8add0..b229cf55 100644 --- a/include/boost/fusion/container/map/map_iterator.hpp +++ b/include/boost/fusion/container/map/map_iterator.hpp @@ -163,4 +163,13 @@ namespace boost { namespace fusion }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::map_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/container/vector/vector_iterator.hpp b/include/boost/fusion/container/vector/vector_iterator.hpp index a53a8ca7..150530d1 100644 --- a/include/boost/fusion/container/vector/vector_iterator.hpp +++ b/include/boost/fusion/container/vector/vector_iterator.hpp @@ -49,5 +49,14 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::vector_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/iterator/basic_iterator.hpp b/include/boost/fusion/iterator/basic_iterator.hpp index 5d484132..eae46e63 100644 --- a/include/boost/fusion/iterator/basic_iterator.hpp +++ b/include/boost/fusion/iterator/basic_iterator.hpp @@ -144,4 +144,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::basic_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/iterator/iterator_adapter.hpp b/include/boost/fusion/iterator/iterator_adapter.hpp index 7e860c77..de8938f6 100644 --- a/include/boost/fusion/iterator/iterator_adapter.hpp +++ b/include/boost/fusion/iterator/iterator_adapter.hpp @@ -135,4 +135,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::iterator_adapter > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/iterator/iterator_facade.hpp b/include/boost/fusion/iterator/iterator_facade.hpp index a2c659ab..1760957e 100644 --- a/include/boost/fusion/iterator/iterator_facade.hpp +++ b/include/boost/fusion/iterator/iterator_facade.hpp @@ -56,4 +56,13 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::iterator_facade > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/support/config.hpp b/include/boost/fusion/support/config.hpp index 15d4be6e..924c2ff1 100644 --- a/include/boost/fusion/support/config.hpp +++ b/include/boost/fusion/support/config.hpp @@ -68,4 +68,23 @@ namespace boost { namespace fusion { namespace detail # define BOOST_FUSION_FWD_ELEM(type, value) std::forward(value) #endif + +// Workaround for LWG 2408: C++17 SFINAE-friendly std::iterator_traits. +// http://cplusplus.github.io/LWG/lwg-defects.html#2408 +// +// - GCC 4.5 enables the feature under C++11. +// https://gcc.gnu.org/ml/gcc-patches/2014-11/msg01105.html +// +// - Only MSVC 12.0 doesn't have the feature. +#if (defined(BOOST_LIBSTDCXX_VERSION) && (BOOST_LIBSTDCXX_VERSION < 40500) && \ + defined(BOOST_LIBSTDCXX11)) || \ + (defined(BOOST_MSVC) && (BOOST_MSVC == 1800)) +# define BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits; +} +#endif + #endif diff --git a/include/boost/fusion/support/deduce.hpp b/include/boost/fusion/support/deduce.hpp index 8d53115f..b75381c5 100644 --- a/include/boost/fusion/support/deduce.hpp +++ b/include/boost/fusion/support/deduce.hpp @@ -12,6 +12,10 @@ #include #include +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL +#include +#endif + namespace boost { namespace fusion { namespace traits { template struct deduce; @@ -86,6 +90,21 @@ namespace boost { namespace fusion { namespace traits typedef T& type; }; + // Also unwrap C++11 std::ref if available (referencee cv is deduced) +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL + template + struct deduce &> + { + typedef T& type; + }; + + template + struct deduce const &> + { + typedef T& type; + }; +#endif + // Keep references on arrays, even if const template diff --git a/include/boost/fusion/support/detail/as_fusion_element.hpp b/include/boost/fusion/support/detail/as_fusion_element.hpp index 628dca4d..2af960ee 100644 --- a/include/boost/fusion/support/detail/as_fusion_element.hpp +++ b/include/boost/fusion/support/detail/as_fusion_element.hpp @@ -11,6 +11,10 @@ #include #include +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL +#include +#endif + namespace boost { namespace fusion { namespace detail { template @@ -25,6 +29,14 @@ namespace boost { namespace fusion { namespace detail typedef T& type; }; +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL + template + struct as_fusion_element > + { + typedef T& type; + }; +#endif + template struct as_fusion_element { diff --git a/include/boost/fusion/view/filter_view/filter_view_iterator.hpp b/include/boost/fusion/view/filter_view/filter_view_iterator.hpp index 1a4197c5..f1b9f54d 100644 --- a/include/boost/fusion/view/filter_view/filter_view_iterator.hpp +++ b/include/boost/fusion/view/filter_view/filter_view_iterator.hpp @@ -67,6 +67,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::filter_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp b/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp index f82a5266..1ecf6928 100644 --- a/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp +++ b/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp @@ -204,6 +204,15 @@ namespace boost { namespace fusion { namespace extension }; }}} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::flatten_view_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/joint_view/joint_view_iterator.hpp b/include/boost/fusion/view/joint_view/joint_view_iterator.hpp index d75ca90d..ddd1341e 100644 --- a/include/boost/fusion/view/joint_view/joint_view_iterator.hpp +++ b/include/boost/fusion/view/joint_view/joint_view_iterator.hpp @@ -56,6 +56,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::joint_view_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/nview/nview_iterator.hpp b/include/boost/fusion/view/nview/nview_iterator.hpp index cb2541b5..aeaf4620 100644 --- a/include/boost/fusion/view/nview/nview_iterator.hpp +++ b/include/boost/fusion/view/nview/nview_iterator.hpp @@ -55,6 +55,15 @@ namespace boost { namespace fusion }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::nview_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/repetitive_view/repetitive_view_iterator.hpp b/include/boost/fusion/view/repetitive_view/repetitive_view_iterator.hpp index df2f228c..74cc723e 100644 --- a/include/boost/fusion/view/repetitive_view/repetitive_view_iterator.hpp +++ b/include/boost/fusion/view/repetitive_view/repetitive_view_iterator.hpp @@ -53,5 +53,14 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::repetitive_view_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp b/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp index d1d023a2..a73e4eea 100644 --- a/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp +++ b/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp @@ -54,5 +54,14 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::reverse_view_iterator > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/single_view/single_view_iterator.hpp b/include/boost/fusion/view/single_view/single_view_iterator.hpp index 4ab620a5..0f3e2744 100644 --- a/include/boost/fusion/view/single_view/single_view_iterator.hpp +++ b/include/boost/fusion/view/single_view/single_view_iterator.hpp @@ -51,6 +51,15 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::single_view_iterator > + { }; +} +#endif + #if defined (BOOST_MSVC) # pragma warning(pop) #endif diff --git a/include/boost/fusion/view/transform_view/transform_view_iterator.hpp b/include/boost/fusion/view/transform_view/transform_view_iterator.hpp index 1e56639e..ab40bd74 100644 --- a/include/boost/fusion/view/transform_view/transform_view_iterator.hpp +++ b/include/boost/fusion/view/transform_view/transform_view_iterator.hpp @@ -76,5 +76,17 @@ namespace boost { namespace fusion }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::transform_view_iterator > + { }; + template + struct iterator_traits< ::boost::fusion::transform_view_iterator2 > + { }; +} +#endif + #endif diff --git a/include/boost/fusion/view/zip_view/zip_view_iterator.hpp b/include/boost/fusion/view/zip_view/zip_view_iterator.hpp index 49c2dc78..cf2d7630 100644 --- a/include/boost/fusion/view/zip_view/zip_view_iterator.hpp +++ b/include/boost/fusion/view/zip_view/zip_view_iterator.hpp @@ -46,4 +46,13 @@ namespace boost { namespace fusion { }; }} +#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 +namespace std +{ + template + struct iterator_traits< ::boost::fusion::zip_view_iterator > + { }; +} +#endif + #endif diff --git a/test/algorithm/pop_back.cpp b/test/algorithm/pop_back.cpp index e374152f..b594f6c8 100644 --- a/test/algorithm/pop_back.cpp +++ b/test/algorithm/pop_back.cpp @@ -95,7 +95,7 @@ main() #endif { - boost::array a = { 10, 50 }; + boost::array a = {{ 10, 50 }}; BOOST_TEST(back(pop_back(a)) == 10); } diff --git a/test/functional/invoke.cpp b/test/functional/invoke.cpp index 67e65feb..fa93332c 100644 --- a/test/functional/invoke.cpp +++ b/test/functional/invoke.cpp @@ -7,6 +7,7 @@ http://www.boost.org/LICENSE_1_0.txt). ==============================================================================*/ +#include #include #include @@ -146,11 +147,28 @@ class members int binary_c(int i, object) const { return data + 6 + i; } }; +#ifdef BOOST_NO_CXX11_SMART_PTR +typedef std::auto_ptr members_ptr; +typedef std::auto_ptr const_members_ptr; +#else +typedef std::unique_ptr members_ptr; +typedef std::unique_ptr const_members_ptr; +#endif + struct derived : members { }; +#ifdef BOOST_NO_CXX11_SMART_PTR +typedef std::auto_ptr derived_ptr; +typedef std::auto_ptr const_derived_ptr; +#else +typedef std::unique_ptr derived_ptr; +typedef std::unique_ptr const_derived_ptr; +#endif + + typedef int element1_type; typedef object element2_type; typedef object_nc & element3_type; @@ -161,8 +179,8 @@ object_nc element3; members that; -std::auto_ptr spt_that(new members); -std::auto_ptr spt_that_c(new members); +members_ptr spt_that(new members); +const_members_ptr spt_that_c(new members); fusion::single_view sv_obj_ctx( that); fusion::single_view sv_ref_ctx( that); @@ -170,13 +188,13 @@ fusion::single_view sv_ptr_ctx(& that); fusion::single_view sv_obj_c_ctx( that); fusion::single_view sv_ref_c_ctx( that); fusion::single_view sv_ptr_c_ctx(& that); -fusion::single_view const &> sv_spt_ctx(spt_that); -fusion::single_view< std::auto_ptr const &> sv_spt_c_ctx(spt_that_c); +fusion::single_view sv_spt_ctx(spt_that); +fusion::single_view sv_spt_c_ctx(spt_that_c); derived derived_that; -std::auto_ptr spt_derived_that(new derived); -std::auto_ptr spt_derived_that_c(new derived); +derived_ptr spt_derived_that(new derived); +const_derived_ptr spt_derived_that_c(new derived); fusion::single_view sv_obj_d_ctx( derived_that); fusion::single_view sv_ref_d_ctx( derived_that); @@ -184,8 +202,8 @@ fusion::single_view sv_ptr_d_ctx(& derived_that); fusion::single_view sv_obj_c_d_ctx( derived_that); fusion::single_view sv_ref_c_d_ctx( derived_that); fusion::single_view sv_ptr_c_d_ctx(& derived_that); -fusion::single_view const &> sv_spt_d_ctx(spt_derived_that); -fusion::single_view< std::auto_ptr const &> sv_spt_c_d_ctx(spt_derived_that_c); +fusion::single_view sv_spt_d_ctx(spt_derived_that); +fusion::single_view sv_spt_c_d_ctx(spt_derived_that_c); template void test_sequence_n(Sequence & seq, mpl::int_<0>) diff --git a/test/functional/invoke_procedure.cpp b/test/functional/invoke_procedure.cpp index 49c35d37..2ee8354d 100644 --- a/test/functional/invoke_procedure.cpp +++ b/test/functional/invoke_procedure.cpp @@ -7,6 +7,7 @@ http://www.boost.org/LICENSE_1_0.txt). ==============================================================================*/ +#include #include #include @@ -65,9 +66,17 @@ class members int binary_c(int & i, object) const { return i = data + 6; } }; +#ifdef BOOST_NO_CXX11_SMART_PTR +typedef std::auto_ptr members_ptr; +typedef std::auto_ptr const_members_ptr; +#else +typedef std::unique_ptr members_ptr; +typedef std::unique_ptr const_members_ptr; +#endif + members that; -std::auto_ptr spt_that(new members); -std::auto_ptr spt_that_c(new members); +members_ptr spt_that(new members); +const_members_ptr spt_that_c(new members); fusion::single_view sv_obj_ctx( that); fusion::single_view sv_ref_ctx( that); @@ -75,8 +84,8 @@ fusion::single_view sv_ptr_ctx(& that); fusion::single_view sv_obj_c_ctx( that); fusion::single_view sv_ref_c_ctx( that); fusion::single_view sv_ptr_c_ctx(& that); -fusion::single_view const &> sv_spt_ctx(spt_that); -fusion::single_view< std::auto_ptr const &> sv_spt_c_ctx(spt_that_c); +fusion::single_view sv_spt_ctx(spt_that); +fusion::single_view sv_spt_c_ctx(spt_that_c); struct fobj { diff --git a/test/sequence/adapt_adt.cpp b/test/sequence/adapt_adt.cpp index d4f4a8c2..265cfca5 100644 --- a/test/sequence/adapt_adt.cpp +++ b/test/sequence/adapt_adt.cpp @@ -38,18 +38,21 @@ namespace ns { public: - point() : x(0), y(0) {} - point(int in_x, int in_y) : x(in_x), y(in_y) {} + point() : x(0), y(0), z(0) {} + point(int in_x, int in_y, int in_z) : x(in_x), y(in_y), z(in_z) {} int get_x() const { return x; } int get_y() const { return y; } + int get_z() const { return z; } void set_x(int x_) { x = x_; } void set_y(int y_) { y = y_; } + void set_z(int z_) { z = z_; } private: int x; int y; + int z; }; #if !BOOST_WORKAROUND(__GNUC__,<4) @@ -58,17 +61,22 @@ namespace ns friend struct boost::fusion::extension::access; public: - point_with_private_members() : x(0), y(0) {} - point_with_private_members(int x, int y) : x(x), y(y) {} - - private: + point_with_private_members() : x(0), y(0), z(0) {} + point_with_private_members(int in_x, int in_y, int in_z) + : x(in_x), y(in_y), z(in_z) {} + int get_x() const { return x; } int get_y() const { return y; } + int get_z() const { return z; } void set_x(int x_) { x = x_; } void set_y(int y_) { y = y_; } - + void set_z(int z_) { z = z_; } + + private: + int x; int y; + int z; }; #endif @@ -91,26 +99,56 @@ namespace ns }; } -BOOST_FUSION_ADAPT_ADT( - ns::point, - (int, int, obj.get_x(), obj.set_x(val)) - (int, int, obj.get_y(), obj.set_y(val)) -) +#if BOOST_PP_VARIADICS + BOOST_FUSION_ADAPT_ADT( + ns::point, + (int, int, obj.get_x(), obj.set_x(val)) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_y(), obj.set_y(val)) + (obj.get_z(), obj.set_z(val)) + ) + +# if !BOOST_WORKAROUND(__GNUC__,<4) + BOOST_FUSION_ADAPT_ADT( + ns::point_with_private_members, + (obj.get_x(), obj.set_x(val)) + (obj.get_y(), obj.set_y(val)) + (obj.get_z(), obj.set_z(val)) + ) +# endif + + + BOOST_FUSION_ADAPT_ADT( + ns::name, + (obj.get_last(), obj.set_last(val)) + (obj.get_first(), obj.set_first(val)) + ) + + +#else // BOOST_PP_VARIADICS + BOOST_FUSION_ADAPT_ADT( + ns::point, + (int, int, obj.get_x(), obj.set_x(val)) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_y(), obj.set_y(val)) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val)) + ) + +# if !BOOST_WORKAROUND(__GNUC__,<4) + BOOST_FUSION_ADAPT_ADT( + ns::point_with_private_members, + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_x(), obj.set_x(val)) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_y(), obj.set_y(val)) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val)) + ) +# endif + + BOOST_FUSION_ADAPT_ADT( + ns::name, + (const std::string&, const std::string&, obj.get_last(), obj.set_last(val)) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_first(), obj.set_first(val)) + ) -#if !BOOST_WORKAROUND(__GNUC__,<4) -BOOST_FUSION_ADAPT_ADT( - ns::point_with_private_members, - (int, int, obj.get_x(), obj.set_x(val)) - (int, int, obj.get_y(), obj.set_y(val)) -) #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() { @@ -123,28 +161,30 @@ main() { BOOST_MPL_ASSERT_NOT((traits::is_view)); - ns::point p(123, 456); + ns::point p(123, 456, 789); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - fusion::vector v1(4, 2); - ns::point v2(5, 3); - fusion::vector v3(5, 4); + fusion::vector v1(4, 2, 2); + ns::point v2(5, 3, 3); + fusion::vector v3(5, 4, 4); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -171,15 +211,15 @@ main() { // conversion from ns::point to vector - ns::point p(5, 3); - fusion::vector v(p); + ns::point p(5, 3, 3); + fusion::vector v(p); v = p; } { // conversion from ns::point to list - ns::point p(5, 3); - fusion::list l(p); + ns::point p(5, 3, 3); + fusion::list l(p); l = p; } @@ -193,26 +233,29 @@ main() #if !BOOST_WORKAROUND(__GNUC__,<4) { BOOST_MPL_ASSERT_NOT((traits::is_view)); - ns::point_with_private_members p(123, 456); + ns::point_with_private_members p(123, 456, 789); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } #endif { + // Check types provided in case it's provided BOOST_MPL_ASSERT(( boost::is_same< boost::fusion::result_of::front::type, @@ -233,6 +276,28 @@ main() boost::fusion::result_of::front::type::type, int >)); + + // Check types provided in case it's deduced + BOOST_MPL_ASSERT(( + boost::is_same< + boost::fusion::result_of::back::type, + boost::fusion::extension::adt_attribute_proxy + >)); + BOOST_MPL_ASSERT(( + boost::is_same< + boost::fusion::result_of::back::type::type, + int + >)); + BOOST_MPL_ASSERT(( + boost::is_same< + boost::fusion::result_of::back::type, + boost::fusion::extension::adt_attribute_proxy + >)); + BOOST_MPL_ASSERT(( + boost::is_same< + boost::fusion::result_of::back::type::type, + const int + >)); } return boost::report_errors(); diff --git a/test/sequence/adapt_adt_named.cpp b/test/sequence/adapt_adt_named.cpp index 38415633..8924ce41 100644 --- a/test/sequence/adapt_adt_named.cpp +++ b/test/sequence/adapt_adt_named.cpp @@ -37,28 +37,46 @@ namespace ns { public: - point() : x(0), y(0) {} - point(int in_x, int in_y) : x(in_x), y(in_y) {} + point() : x(0), y(0), z(0) {} + point(int in_x, int in_y, int in_z) : x(in_x), y(in_y), z(in_z) {} int get_x() const { return x; } int get_y() const { return y; } + int get_z() const { return z; } void set_x(int x_) { x = x_; } void set_y(int y_) { y = y_; } + void set_z(int z_) { z = z_; } private: int x; int y; + int z; }; } +#if BOOST_PP_VARIADICS + // this creates a fusion view: boost::fusion::adapted::point BOOST_FUSION_ADAPT_ADT_NAMED( ns::point, point, - (int, int, obj.obj.get_x(), obj.obj.set_x(val)) - (int, int, obj.obj.get_y(), obj.obj.set_y(val)) + (int, int, obj.get_x(), obj.set_x(val)) + (int, int, obj.get_y(), obj.set_y(val)) + (obj.get_z(), obj.set_z(val)) ) +#else // BOOST_PP_VARIADICS + +// this creates a fusion view: boost::fusion::adapted::point +BOOST_FUSION_ADAPT_ADT_NAMED( + ns::point, point, + (int, int, obj.get_x(), obj.set_x(val)) + (int, int, obj.get_y(), obj.set_y(val)) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val)) +) + +#endif // BOOST_PP_VARIADICS + int main() { @@ -71,31 +89,33 @@ main() { BOOST_MPL_ASSERT((traits::is_view)); - ns::point basep(123, 456); + ns::point basep(123, 456, 789); adapted::point p(basep); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - fusion::vector v1(4, 2); - ns::point basep(5, 3); + fusion::vector v1(4, 2, 2); + ns::point basep(5, 3, 3); adapted::point v2(basep); - fusion::vector v3(5, 4); + fusion::vector v3(5, 4, 4); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -108,19 +128,19 @@ main() { // conversion from ns::point to vector - ns::point basep(5, 3); + ns::point basep(5, 3, 3); adapted::point p(basep); - fusion::vector v(p); + fusion::vector v(p); v = p; } { // conversion from ns::point to list - ns::point basep(5, 3); + ns::point basep(5, 3, 3); adapted::point p(basep); - fusion::list l(p); + fusion::list l(p); l = p; } diff --git a/test/sequence/adapt_assoc_adt.cpp b/test/sequence/adapt_assoc_adt.cpp index c97e84b0..a03605f1 100644 --- a/test/sequence/adapt_assoc_adt.cpp +++ b/test/sequence/adapt_assoc_adt.cpp @@ -26,31 +26,50 @@ namespace ns struct y_member; struct z_member; + struct non_member; + class point { public: - point() : x(0), y(0) {} - point(int in_x, int in_y) : x(in_x), y(in_y) {} + point() : x(0), y(0), z(0) {} + point(int in_x, int in_y, int in_z) : x(in_x), y(in_y), z(in_z) {} int get_x() const { return x; } int get_y() const { return y; } + int get_z() const { return z; } void set_x(int x_) { x = x_; } void set_y(int y_) { y = y_; } + void set_z(int z_) { z = z_; } private: int x; int y; + int z; }; } +#if BOOST_PP_VARIADICS + BOOST_FUSION_ADAPT_ASSOC_ADT( ns::point, (int, int, obj.get_x(), obj.set_x(val), ns::x_member) (int, int, obj.get_y(), obj.set_y(val), ns::y_member) + (obj.get_z(), obj.set_z(val), ns::z_member) ) +#else // BOOST_PP_VARIADICS + +BOOST_FUSION_ADAPT_ASSOC_ADT( + ns::point, + (int, int, obj.get_x(), obj.set_x(val), ns::x_member) + (int, int, obj.get_y(), obj.set_y(val), ns::y_member) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val), ns::z_member) +) + +#endif + int main() { @@ -62,28 +81,30 @@ main() { BOOST_MPL_ASSERT_NOT((traits::is_view)); - ns::point p(123, 456); + ns::point p(123, 456, 789); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - boost::fusion::vector v1(4, 2); - ns::point v2(5, 3); - boost::fusion::vector v3(5, 4); + boost::fusion::vector v1(4, 2, 2); + ns::point v2(5, 3, 3); + boost::fusion::vector v3(5, 4, 4); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -96,15 +117,15 @@ main() { // conversion from ns::point to vector - ns::point p(5, 3); - boost::fusion::vector v(p); + ns::point p(5, 3, 3); + boost::fusion::vector v(p); v = p; } { // conversion from ns::point to list - ns::point p(5, 3); - boost::fusion::list l(p); + ns::point p(5, 3, 3); + boost::fusion::list l(p); l = p; } @@ -119,15 +140,19 @@ main() // assoc stuff BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); - BOOST_MPL_ASSERT((boost::mpl::not_ >)); + BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); + BOOST_MPL_ASSERT((boost::mpl::not_ >)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); - ns::point p(5, 3); + ns::point p(5, 3, 1); BOOST_TEST(at_key(p) == 5); BOOST_TEST(at_key(p) == 3); + BOOST_TEST(at_key(p) == 1); } return boost::report_errors(); diff --git a/test/sequence/adapt_assoc_adt_named.cpp b/test/sequence/adapt_assoc_adt_named.cpp index d68d9904..8ef9aa27 100644 --- a/test/sequence/adapt_assoc_adt_named.cpp +++ b/test/sequence/adapt_assoc_adt_named.cpp @@ -48,8 +48,8 @@ namespace ns BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED( ns::point, point, - (int, int, obj.obj.get_x(), obj.obj.set_x(val), ns::x_member) - (int, int, obj.obj.get_y(), obj.obj.set_y(val), ns::y_member) + (int, int, obj.get_x(), obj.set_x(val), ns::x_member) + (int, int, obj.get_y(), obj.set_y(val), ns::y_member) ) int diff --git a/test/sequence/adapt_assoc_struct.cpp b/test/sequence/adapt_assoc_struct.cpp index 62574a7e..4cdabb87 100644 --- a/test/sequence/adapt_assoc_struct.cpp +++ b/test/sequence/adapt_assoc_struct.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -42,19 +43,33 @@ namespace ns struct x_member; struct y_member; struct z_member; + struct non_member; struct point { int x; int y; + int z; }; } -BOOST_FUSION_ADAPT_ASSOC_STRUCT( - ns::point, - (int, x, ns::x_member) - (int, y, ns::y_member) -) +#if BOOST_PP_VARIADICS + BOOST_FUSION_ADAPT_ASSOC_STRUCT( + ns::point, + (x, ns::x_member) + (y, ns::y_member) + (int, z, ns::z_member) + ) + +#else // BOOST_PP_VARIADICS + BOOST_FUSION_ADAPT_ASSOC_STRUCT( + ns::point, + (BOOST_FUSION_ADAPT_AUTO, x, ns::x_member) + (BOOST_FUSION_ADAPT_AUTO, y, ns::y_member) + (int, z, ns::z_member) + ) + +#endif int main() @@ -68,28 +83,30 @@ main() { BOOST_MPL_ASSERT_NOT((traits::is_view)); - ns::point p = {123, 456}; + ns::point p = {123, 456, 789}; std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - fusion::vector v1(4, 2); - ns::point v2 = {5, 3}; - fusion::vector v3(5, 4); + fusion::vector v1(4, 2, 2); + ns::point v2 = {5, 3, 3}; + fusion::vector v3(5, 4, 4); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -102,15 +119,15 @@ main() { // conversion from ns::point to vector - ns::point p = {5, 3}; - fusion::vector v(p); + ns::point p = {5, 3, 3}; + fusion::vector v(p); v = p; } { // conversion from ns::point to list - ns::point p = {5, 3}; - fusion::list l(p); + ns::point p = {5, 3, 3}; + fusion::list l(p); l = p; } @@ -118,15 +135,18 @@ main() // assoc stuff BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); - BOOST_MPL_ASSERT((mpl::not_ >)); + BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); + BOOST_MPL_ASSERT((mpl::not_ >)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type, int>)); - ns::point p = {5, 3}; + ns::point p = {5, 3, 9}; BOOST_TEST(at_key(p) == 5); BOOST_TEST(at_key(p) == 3); + BOOST_TEST(at_key(p) == 9); } { @@ -134,6 +154,9 @@ main() BOOST_MPL_ASSERT((boost::is_same< boost::fusion::result_of::value_at_c::type , mpl::front::type>)); + BOOST_MPL_ASSERT((boost::is_same< + boost::fusion::result_of::value_at_c::type + , mpl::back::type>)); } return boost::report_errors(); diff --git a/test/sequence/adapt_assoc_tpl_adt.cpp b/test/sequence/adapt_assoc_tpl_adt.cpp index 15e2124c..8aa600ff 100644 --- a/test/sequence/adapt_assoc_tpl_adt.cpp +++ b/test/sequence/adapt_assoc_tpl_adt.cpp @@ -26,39 +26,57 @@ namespace ns struct y_member; struct z_member; - template + struct non_member; + + template class point { public: - point() : x(0), y(0) {} - point(X in_x, Y in_y) : x(in_x), y(in_y) {} + point() : x(0), y(0), z(0) {} + point(X in_x, Y in_y, Z in_z) : x(in_x), y(in_y), z(in_z) {} X get_x() const { return x; } Y get_y() const { return y; } + Z get_z() const { return z; } void set_x(X x_) { x = x_; } void set_y(Y y_) { y = y_; } + void set_z(Z z_) { z = z_; } private: X x; Y y; + Z z; }; } +#if BOOST_PP_VARIADICS BOOST_FUSION_ADAPT_ASSOC_TPL_ADT( - (X)(Y), - (ns::point)(X)(Y), + (X)(Y)(Z), + (ns::point)(X)(Y)(Z), (X, X, obj.get_x(), obj.set_x(val), ns::x_member) (Y, Y, obj.get_y(), obj.set_y(val), ns::y_member) + (obj.get_z(), obj.set_z(val), ns::z_member) ) + +#else // BOOST_PP_VARIADICS +BOOST_FUSION_ADAPT_ASSOC_TPL_ADT( + (X)(Y)(Z), + (ns::point)(X)(Y)(Z), + (X, X, obj.get_x(), obj.set_x(val), ns::x_member) + (Y, Y, obj.get_y(), obj.set_y(val), ns::y_member) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val), ns::z_member) +) + +#endif int main() { using namespace boost::fusion; - typedef ns::point point; + typedef ns::point point; std::cout << tuple_open('['); std::cout << tuple_close(']'); @@ -66,28 +84,30 @@ main() { BOOST_MPL_ASSERT_NOT((traits::is_view)); - point p(123, 456); + point p(123, 456, 789); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - boost::fusion::vector v1(4, 2); - point v2(5, 3); - boost::fusion::vector v3(5, 4); + boost::fusion::vector v1(4, 2, 2); + point v2(5, 3, 3); + boost::fusion::vector v3(5, 4, 4); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -100,15 +120,15 @@ main() { // conversion from point to vector - point p(5, 3); - boost::fusion::vector v(p); + point p(5, 3, 3); + boost::fusion::vector v(p); v = p; } { // conversion from point to list - point p(5, 3); - boost::fusion::list l(p); + point p(5, 3, 3); + boost::fusion::list l(p); l = p; } @@ -123,15 +143,18 @@ main() // assoc stuff BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); - BOOST_MPL_ASSERT((boost::mpl::not_ >)); + BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); + BOOST_MPL_ASSERT((boost::mpl::not_ >)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type, long>)); - point p(5, 3); + point p(5, 3, 1); BOOST_TEST(at_key(p) == 5); BOOST_TEST(at_key(p) == 3); + BOOST_TEST(at_key(p) == 1); } return boost::report_errors(); diff --git a/test/sequence/adapt_assoc_tpl_struct.cpp b/test/sequence/adapt_assoc_tpl_struct.cpp index a327f9e8..6adcc931 100644 --- a/test/sequence/adapt_assoc_tpl_struct.cpp +++ b/test/sequence/adapt_assoc_tpl_struct.cpp @@ -39,27 +39,42 @@ namespace ns struct y_member; struct z_member; - template + struct non_member; + + template struct point { X x; Y y; + Z z; }; } -BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( - (X)(Y), - (ns::point)(X)(Y), - (int, x, ns::x_member) - (int, y, ns::y_member) -) +#if BOOST_PP_VARIADICS + BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( + (X)(Y)(Z), + (ns::point)(X)(Y)(Z), + (int, x, ns::x_member) + (Y, y, ns::y_member) + (z, ns::z_member) + ) + +#else // BOOST_PP_VARIADICS + BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( + (X)(Y)(Z), + (ns::point)(X)(Y)(Z), + (int, x, ns::x_member) + (Y, y, ns::y_member) + (BOOST_FUSION_ADAPT_AUTO, z, ns::z_member) + ) +#endif int main() { using namespace boost::fusion; - typedef ns::point point; + typedef ns::point point; std::cout << tuple_open('['); std::cout << tuple_close(']'); @@ -67,28 +82,30 @@ main() { BOOST_MPL_ASSERT_NOT((traits::is_view)); - point p = {123, 456}; + point p = {123, 456, 789.43f}; std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789.43f)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - vector v1(4, 2); - point v2 = {5, 3}; - vector v3(5, 4); + vector v1(4, 2, 2); + point v2 = {5, 3, 3}; + vector v3(5, 4, 4.13f); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -101,15 +118,15 @@ main() { // conversion from point to vector - point p = {5, 3}; - vector v(p); + point p = {5, 3, 3}; + vector v(p); v = p; } { // conversion from point to list - point p = {5, 3}; - list l(p); + point p = {5, 3, 3}; + list l(p); l = p; } @@ -117,15 +134,18 @@ main() // assoc stuff BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); - BOOST_MPL_ASSERT((boost::mpl::not_ >)); + BOOST_MPL_ASSERT((boost::fusion::result_of::has_key)); + BOOST_MPL_ASSERT((boost::mpl::not_ >)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); BOOST_MPL_ASSERT((boost::is_same::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type, float>)); - point p = {5, 3}; + point p = {5, 3, 9}; BOOST_TEST(at_key(p) == 5); BOOST_TEST(at_key(p) == 3); + BOOST_TEST(at_key(p) == 9); } return boost::report_errors(); diff --git a/test/sequence/adapt_struct.cpp b/test/sequence/adapt_struct.cpp index e64507cf..c0cd3049 100644 --- a/test/sequence/adapt_struct.cpp +++ b/test/sequence/adapt_struct.cpp @@ -38,6 +38,7 @@ namespace ns { int x; int y; + int z; }; #if !BOOST_WORKAROUND(__GNUC__,<4) @@ -48,9 +49,10 @@ namespace ns private: int x; int y; + int z; public: - point_with_private_attributes(int x, int y):x(x),y(y) + point_with_private_attributes(int x, int y, int z):x(x),y(y),z(z) {} }; #endif @@ -67,63 +69,99 @@ namespace ns }; } -BOOST_FUSION_ADAPT_STRUCT( - ns::point, - (int, x) - (int, y) -) +#if BOOST_PP_VARIADICS + + BOOST_FUSION_ADAPT_STRUCT( + ns::point, + x, + y, + z + ) + +# if !BOOST_WORKAROUND(__GNUC__,<4) + BOOST_FUSION_ADAPT_STRUCT( + ns::point_with_private_attributes, + x, + y, + z + ) +# endif + + struct s { int m; }; + BOOST_FUSION_ADAPT_STRUCT(s, m) + + BOOST_FUSION_ADAPT_STRUCT( + ns::bar, + foo_.x, // test that adapted members can actually be expressions + y + ) + +#else // BOOST_PP_VARIADICS + + BOOST_FUSION_ADAPT_STRUCT( + ns::point, + (int, x) + (int, y) + (BOOST_FUSION_ADAPT_AUTO, z) + ) + +# if !BOOST_WORKAROUND(__GNUC__,<4) + BOOST_FUSION_ADAPT_STRUCT( + ns::point_with_private_attributes, + (int, x) + (int, y) + (BOOST_FUSION_ADAPT_AUTO, z) + ) +# endif + + struct s { int m; }; + BOOST_FUSION_ADAPT_STRUCT(s, (BOOST_FUSION_ADAPT_AUTO, m)) + + BOOST_FUSION_ADAPT_STRUCT( + ns::bar, + (BOOST_FUSION_ADAPT_AUTO, foo_.x) // test that adapted members can actually be expressions + (BOOST_FUSION_ADAPT_AUTO, y) + ) -#if !BOOST_WORKAROUND(__GNUC__,<4) -BOOST_FUSION_ADAPT_STRUCT( - ns::point_with_private_attributes, - (int, x) - (int, y) -) #endif -struct s { int m; }; -BOOST_FUSION_ADAPT_STRUCT(s, (int, m)) - -BOOST_FUSION_ADAPT_STRUCT( - ns::bar, - (int, foo_.x) // test that adapted members can actually be expressions - (int, y) -) - int main() { using namespace boost::fusion; using namespace boost; + using ns::point; std::cout << tuple_open('['); std::cout << tuple_close(']'); std::cout << tuple_delimiter(", "); { - BOOST_MPL_ASSERT_NOT((traits::is_view)); - ns::point p = {123, 456}; + BOOST_MPL_ASSERT_NOT((traits::is_view)); + point p = {123, 456, 789}; std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); - BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); + BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - fusion::vector v1(4, 2); - ns::point v2 = {5, 3}; - fusion::vector v3(5, 4); + vector v1(4, 2, 2); + point v2 = {5, 3, 3}; + vector v3(5, 4, 4); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -135,16 +173,16 @@ main() } { - // conversion from ns::point to vector - ns::point p = {5, 3}; - fusion::vector v(p); + // conversion from point to vector + point p = {5, 3, 3}; + vector v(p); v = p; } { - // conversion from ns::point to list - ns::point p = {5, 3}; - fusion::list l(p); + // conversion from point to list + point p = {5, 3, 3}; + list l(p); l = p; } @@ -167,18 +205,19 @@ main() #if !BOOST_WORKAROUND(__GNUC__,<4) { - ns::point_with_private_attributes p(123, 456); + ns::point_with_private_attributes p(123, 456, 789); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); } #endif { fusion::vector v1(4, 2); - ns::bar v2 = {5, 3}; + ns::bar v2 = {{5}, 3}; BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); diff --git a/test/sequence/adapt_struct_named.cpp b/test/sequence/adapt_struct_named.cpp index ef859655..aab11d2d 100644 --- a/test/sequence/adapt_struct_named.cpp +++ b/test/sequence/adapt_struct_named.cpp @@ -37,19 +37,39 @@ namespace ns { int x; int y; + int z; }; } -// this creates a fusion view: boost::fusion::adapted::point -BOOST_FUSION_ADAPT_STRUCT_NAMED( - ns::point, point, - (int, x) - (int, y) -) +#if BOOST_PP_VARIADICS -// this creates a fusion view: ns1::s1 -struct s { int m; }; -BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(s, (ns1), s1, (int, m)) + // this creates a fusion view: boost::fusion::adapted::point + BOOST_FUSION_ADAPT_STRUCT_NAMED( + ns::point, point, + x, + y, + z + ) + + // this creates a fusion view: ns1::s1 + struct s { int m; }; + BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(s, (ns1), s1, m) + +#else // BOOST_PP_VARIADICS + + // this creates a fusion view: boost::fusion::adapted::point + BOOST_FUSION_ADAPT_STRUCT_NAMED( + ns::point, point, + (int, x) + (int, y) + (BOOST_FUSION_ADAPT_AUTO, z) + ) + + // this creates a fusion view: ns1::s1 + struct s { int m; }; + BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(s, (ns1), s1, (BOOST_FUSION_ADAPT_AUTO, m)) + +#endif int main() @@ -63,31 +83,33 @@ main() { BOOST_MPL_ASSERT((traits::is_view)); - ns::point basep = {123, 456}; + ns::point basep = {123, 456, 789}; adapted::point p(basep); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - fusion::vector v1(4, 2); - ns::point p = {5, 3}; + fusion::vector v1(4, 2, 2); + ns::point p = {5, 3, 3}; adapted::point v2(p); - fusion::vector v3(5, 4); + fusion::vector v3(5, 4, 4); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -100,17 +122,17 @@ main() { // conversion from adapted::point to vector - ns::point basep = {5, 3}; + ns::point basep = {5, 3, 3}; adapted::point p(basep); - fusion::vector v(p); + fusion::vector v(p); v = p; } { // conversion from adapted::point to list - ns::point basep = {5, 3}; + ns::point basep = {5, 3, 3}; adapted::point p(basep); - fusion::list l(p); + fusion::list l(p); l = p; } diff --git a/test/sequence/adapt_tpl_adt.cpp b/test/sequence/adapt_tpl_adt.cpp index aeb0f721..bbd1d07f 100644 --- a/test/sequence/adapt_tpl_adt.cpp +++ b/test/sequence/adapt_tpl_adt.cpp @@ -39,27 +39,45 @@ namespace ns { public: - point() : x(0), y(0) {} - point(X x_, Y y_) : x(x_), y(y_) {} + point() : x(0), y(0), z(0) {} + point(X x_, Y y_, int z_) : x(x_), y(y_), z(z_) {} X get_x() const { return x; } Y get_y() const { return y; } + int get_z() const { return z; } void set_x(X x_) { x = x_; } void set_y(Y y_) { y = y_; } + void set_z(int z_) { z = z_; } private: X x; Y y; + int z; }; } -BOOST_FUSION_ADAPT_TPL_ADT( - (X)(Y), - (ns::point)(X)(Y), - (X, X, obj.get_x(), obj.set_x(val)) - (Y, Y, obj.get_y(), obj.set_y(val)) -) + +#if BOOST_PP_VARIADICS + + BOOST_FUSION_ADAPT_TPL_ADT( + (X)(Y), + (ns::point)(X)(Y), + (X, X, obj.get_x(), obj.set_x(val)) + (Y, Y, obj.get_y(), obj.set_y(val)) + (obj.get_z(), obj.set_z(val)) + ) + +#else // BOOST_PP_VARIADICS + + BOOST_FUSION_ADAPT_TPL_ADT( + (X)(Y), + (ns::point)(X)(Y), + (X, X, obj.get_x(), obj.set_x(val)) + (Y, Y, obj.get_y(), obj.set_y(val)) + (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val)) + ) +#endif int main() @@ -75,28 +93,30 @@ main() { BOOST_MPL_ASSERT_NOT((traits::is_view)); - point p(123, 456); + point p(123, 456, 789); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - boost::fusion::vector v1(4, 2); - point v2(5, 3); - boost::fusion::vector v3(5, 4); + boost::fusion::vector v1(4, 2, 2); + point v2(5, 3, 3); + boost::fusion::vector v3(5, 4, 4); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -108,9 +128,9 @@ main() } { - boost::fusion::vector v1("Lincoln", "Abraham"); - name v2("Roosevelt", "Franklin"); - name v3("Roosevelt", "Theodore"); + boost::fusion::vector v1("Lincoln", "Abraham", 3); + name v2("Roosevelt", "Franklin", 3); + name v3("Roosevelt", "Theodore", 3); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -123,15 +143,15 @@ main() { // conversion from point to vector - point p(5, 3); - boost::fusion::vector v(p); + point p(5, 3, 3); + boost::fusion::vector v(p); v = p; } { // conversion from point to list - point p(5, 3); - boost::fusion::list l(p); + point p(5, 3, 3); + boost::fusion::list l(p); l = p; } diff --git a/test/sequence/adapt_tpl_struct.cpp b/test/sequence/adapt_tpl_struct.cpp index 352cf995..86face6d 100644 --- a/test/sequence/adapt_tpl_struct.cpp +++ b/test/sequence/adapt_tpl_struct.cpp @@ -35,19 +35,40 @@ namespace ns { X x; Y y; + int z; }; } -BOOST_FUSION_ADAPT_TPL_STRUCT( - (X)(Y), - (ns::point)(X)(Y), - (X, x) - (Y, y) -) +#if BOOST_PP_VARIADICS + + BOOST_FUSION_ADAPT_TPL_STRUCT( + (X)(Y), + (ns::point)(X)(Y), + x, + (BOOST_FUSION_ADAPT_AUTO, y) + (int, z) + ) + + template + struct s { M m; }; + BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), m) + +#else // BOOST_PP_VARIADICS + + BOOST_FUSION_ADAPT_TPL_STRUCT( + (X)(Y), + (ns::point)(X)(Y), + (X, x) + (Y, y) + (BOOST_FUSION_ADAPT_AUTO, z) + ) + + template + struct s { M m; }; + BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), (BOOST_FUSION_ADAPT_AUTO, m)) + +#endif -template -struct s { M m; }; -BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), (M, m)) int main() @@ -62,28 +83,30 @@ main() { BOOST_MPL_ASSERT_NOT((traits::is_view)); - point p = {123, 456}; + point p = {123, 456, 789}; std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; + std::cout << at_c<2>(p) << std::endl; std::cout << p << std::endl; - BOOST_TEST(p == make_vector(123, 456)); + BOOST_TEST(p == make_vector(123, 456, 789)); at_c<0>(p) = 6; at_c<1>(p) = 9; - BOOST_TEST(p == make_vector(6, 9)); + at_c<2>(p) = 12; + BOOST_TEST(p == make_vector(6, 9, 12)); - BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 2); + BOOST_STATIC_ASSERT(boost::fusion::result_of::size::value == 3); BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty::value); BOOST_TEST(front(p) == 6); - BOOST_TEST(back(p) == 9); + BOOST_TEST(back(p) == 12); } { - vector v1(4, 2); - point v2 = {5, 3}; - vector v3(5, 4); + vector v1(4, 2, 2); + point v2 = {5, 3, 3}; + vector v3(5, 4, 4); BOOST_TEST(v1 < v2); BOOST_TEST(v1 <= v2); BOOST_TEST(v2 > v1); @@ -96,14 +119,14 @@ main() { // conversion from point to vector - point p = {5, 3}; - vector v(p); + point p = {5, 3, 3}; + vector v(p); v = p; } { // conversion from point to list - point p = {5, 3}; + point p = {5, 3, 3}; list l(p); l = p; } diff --git a/test/sequence/deduce_sequence.cpp b/test/sequence/deduce_sequence.cpp index ea661662..a1569f46 100644 --- a/test/sequence/deduce_sequence.cpp +++ b/test/sequence/deduce_sequence.cpp @@ -6,6 +6,7 @@ http://www.boost.org/LICENSE_1_0.txt). ==============================================================================*/ +#include #include #include #include @@ -13,6 +14,9 @@ #include #include +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL +#include +#endif using boost::is_same; using boost::reference_wrapper; @@ -66,6 +70,13 @@ int main() TEST_SAME_TYPE(deduce< reference_wrapper const & >::type, int &); TEST_SAME_TYPE(deduce< reference_wrapper const & >::type, int const &); +#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL + TEST_SAME_TYPE(deduce< std::reference_wrapper & >::type, int &); + TEST_SAME_TYPE(deduce< std::reference_wrapper & >::type, int const &); + TEST_SAME_TYPE(deduce< std::reference_wrapper const & >::type, int &); + TEST_SAME_TYPE(deduce< std::reference_wrapper const & >::type, int const &); +#endif + TEST_SAME_TYPE(deduce< int(&)[2] >::type, int(&)[2]); TEST_SAME_TYPE(deduce< int const (&)[2] >::type, int const (&)[2]); TEST_SAME_TYPE(deduce< int volatile (&)[2] >::type, int volatile (&)[2]); diff --git a/test/sequence/move.hpp b/test/sequence/move.hpp index febbc2bb..8636604f 100644 --- a/test/sequence/move.hpp +++ b/test/sequence/move.hpp @@ -38,12 +38,12 @@ namespace test_detail return *this; } - x(x const& rhs) + x(x const& /*rhs*/) { incr_copy(); } - x& operator=(x const& rhs) + x& operator=(x const& /*rhs*/) { incr_copy(); return *this; diff --git a/test/sequence/size.cpp b/test/sequence/size.cpp index f8254dad..8c4c5a55 100644 --- a/test/sequence/size.cpp +++ b/test/sequence/size.cpp @@ -19,7 +19,8 @@ #include #include #include -#if !defined(BOOST_NO_CXX11_HDR_TUPLE) +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \ + !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include #include #endif @@ -89,7 +90,8 @@ void test() check >(); } -#if !defined(BOOST_NO_CXX11_HDR_TUPLE) +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \ + !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) { check >(); check >(); diff --git a/test/sequence/std_tuple_iterator.cpp b/test/sequence/std_tuple_iterator.cpp index 202fb7a5..e33db386 100644 --- a/test/sequence/std_tuple_iterator.cpp +++ b/test/sequence/std_tuple_iterator.cpp @@ -8,7 +8,8 @@ // The std_tuple_iterator adaptor only supports implementations // using variadic templates -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \ + !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include