Opened 6 years ago

Last modified 6 years ago

#12436 new Bugs

BOOST_FUSION_DEFINE_STRUCT fails if a member type starts with "::"

Reported by: jaredgrubb Owned by: Joel de Guzman
Milestone: To Be Determined Component: fusion
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description

The following code compiles fine in boost-1.57 but fails in boost-1.59 and later.

Example:

#include <string>
#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <boost/fusion/include/define_struct.hpp>
#include <boost/fusion/include/adapt_struct.hpp>

BOOST_FUSION_DEFINE_STRUCT(
    (demo), employee,
    (::std::size_t, age))

The error shown by clang:

fusion.cpp:6:1: error: pasting formed 'BOOST_PP_IS_EMPTY_DEF_::', an invalid preprocessing token
BOOST_FUSION_DEFINE_STRUCT(
^
/Users/grubber/src/work/boost-1.59.0/boost/fusion/adapted/struct/define_struct.hpp:38:5: note: expanded from macro 'BOOST_FUSION_DEFINE_STRUCT'
    BOOST_FUSION_ADAPT_STRUCT(                                                  \
    ^
/Users/grubber/src/work/boost-1.59.0/boost/fusion/adapted/struct/adapt_struct.hpp:110:17: note: expanded from macro 'BOOST_FUSION_ADAPT_STRUCT'
                BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,              \
                ^
/Users/grubber/src/work/boost-1.59.0/boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp:25:5: note: expanded from macro 'BOOST_FUSION_ADAPT_STRUCT_FILLER_0'
    BOOST_FUSION_ADAPT_STRUCT_FILLER_1
    ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Users/grubber/src/work/boost-1.59.0/boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp:35:17: note: expanded from macro 'BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR'
    BOOST_PP_IF(BOOST_PP_IS_EMPTY(X),                                           \
                ^
/Users/grubber/src/work/boost-1.59.0/boost/preprocessor/facilities/is_empty.hpp:35:34: note: expanded from macro 'BOOST_PP_IS_EMPTY'
#    define BOOST_PP_IS_EMPTY(x) BOOST_PP_IS_EMPTY_I(x BOOST_PP_IS_EMPTY_HELPER)
                                 ^
/Users/grubber/src/work/boost-1.59.0/boost/preprocessor/facilities/is_empty.hpp:36:93: note: expanded from macro 'BOOST_PP_IS_EMPTY_I'
#    define BOOST_PP_IS_EMPTY_I(contents) BOOST_PP_TUPLE_ELEM(2, 1, (BOOST_PP_IS_EMPTY_DEF_ ## contents()))
                                                                                            ^
1 error generated.

Change History (3)

comment:1 by anonymous, 6 years ago

Summary: Fusion fails if a member type starts with "::"BOOST_FUSION_DEFINE_STRUCT fails if a member type starts with "::"

comment:2 by Joel de Guzman, 6 years ago

I think this is more or an issue with Boost preprocessor instead of Fusion. no? It's not perfect. The workaround of corse is to declare a typedef outside of the macro.

comment:3 by jaredgrubb+boosttrac@…, 6 years ago

Doing a quick diff between 1.57 and 1.59, I don't see many changes to the MPL macros, but I see a lot of changes in Fusion in the Adapted part, so it's probably Fusion that changed.

Although the workaround is to use a typedef (or to avoid a situation where leading colons are required), the sample code seems like it should be supported -- especially given that it used to be.

Note: See TracTickets for help on using tickets.