Hi, Again thanks a lot! I allready got my first small success after scanning the file. I figured that what i needed was BOOST_FUSION_DEFINE_STRUCT_INLINE_MEMBERS Now i can write: struct MyType{ struct type : boost::fusion::sequence_facade< type, boost::fusion::random_access_traversal_tag
{ #define attributes (vector<T>,a)(vector<U>,b)(vector<V>,c) BOOST_FUSION_DEFINE_STRUCT_INLINE_MEMBERS(type, attributes) //add own methods here...
//however, does this work? struct reference{ #define refAttributes (T&,a)(U&,b)(V&,c) BOOST_FUSION_DEFINE_STRUCT_INLINE_MEMBERS(reference, refAttributes) }; }; }; I am not sure whether i can put reference types into the structure. because in the macro there is a ctor created as: #define BOOST_FUSION_MAKE_COPY_CONSTRUCTOR(NAME, ATTRIBUTES_SEQ) \ NAME(BOOST_PP_SEQ_FOR_EACH_I( \ BOOST_FUSION_MAKE_CONST_REF_PARAM, \ ~, \ ATTRIBUTES_SEQ)) \ ... \ #define BOOST_FUSION_MAKE_CONST_REF_PARAM(R, DATA, N, ATTRIBUTE) \ BOOST_PP_COMMA_IF(N) \ BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE) const& \ BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE) so there is an assumption that ATTRIBUTE is not a reference type. Is there a reason why it is implemented that way? If not, i would like to change the argument type to something like(not compiled): (with ELEM = BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE)) typename mpl::if_<is_reference<ELEM>, ELEM, typename add_const<typename remove_reference<ELEM>::type>::type& >::type (if ELEM is a reference use ELEM as argument type, else try to get a const reference in a safe way) Anyways, Keep up the good work! Fusion is great :) Gretings, Oswin Krause On 2012-09-21 09:52, Nathan Ridge wrote:
thanks for the reply. Is it possible to just copy and rename the macro, or does it depend on newer features of fusion? I need to be compatible with boost 1.45 so i can't use it directly (also i need to add a few more functions to the structure later on)
BOOST_FUSION_DEFINE_STRUCT_INLINE is implemented using the sequence_facade and iterator_facade extension mechanisms, which were present in Boost 1.45 [1] [2]. So, it should be straightforward to back-port the macro to 1.45.
Regards, Nate
[1]
http://www.boost.org/doc/libs/1_45_0/libs/fusion/doc/html/fusion/extension/s... [2]
http://www.boost.org/doc/libs/1_45_0/libs/fusion/doc/html/fusion/extension/i...
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users