Merge acceleration and qi boost - compile-time error

I can not compile the following code:

#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/spirit/include/qi.hpp>

#include <string>

struct function
{
  std::string ret_type;
  std::string name;
};

BOOST_FUSION_ADAPT_STRUCT(
  function,
  (std::string, ret_type)
  (std::string, name)
)

int main() {}

MSVC-11.0 with a boost of 1.54 gives me the following errors:

1>main.cpp(6084): error C3203: 'function' : unspecialized class template can't be used as a template argument for template parameter 'Sequence', expected a real type
1>main.cpp(6084): error C2955: 'boost::function' : use of class template requires template argument list
1>          e:\libs\boost_1_54_0\boost\function\function_fwd.hpp(33) : see declaration of 'boost::function'
1>main.cpp(6084): error C2913: explicit specialization; 'boost::fusion::traits::tag_of' is not a specialization of a class template
1>main.cpp(6084): error C3203: 'function' : unspecialized class template can't be used as a template argument for template parameter 'Seq', expected a real type
1>          e:\libs\boost_1_54_0\boost\function\function_fwd.hpp(33) : see declaration of 'boost::function'
1>main.cpp(6084): error C2913: explicit specialization; 'boost::fusion::extension::access::struct_member' is not a specialization of a class template
1>          e:\libs\boost_1_54_0\boost\function\function_fwd.hpp(33) : see declaration of 'boost::function'
1>main.cpp(6084): error C2913: explicit specialization; 'boost::fusion::extension::struct_member_name' is not a specialization of a class template
1>          e:\libs\boost_1_54_0\boost\function\function_fwd.hpp(33) : see declaration of 'boost::function'
1>main.cpp(6084): error C2913: explicit specialization; 'boost::fusion::extension::struct_size' is not a specialization of a class template
1>          e:\libs\boost_1_54_0\boost\function\function_fwd.hpp(33) : see declaration of 'boost::function'
1>main.cpp(6084): error C2913: explicit specialization; 'boost::fusion::extension::struct_is_view' is not a specialization of a class template
1>          e:\libs\boost_1_54_0\boost\function\function_fwd.hpp(33) : see declaration of 'boost::function'
1>main.cpp(6084): error C2913: explicit specialization; 'boost::mpl::sequence_tag' is not a specialization of a class template

Everything is fine if I remove "boost / spirit / include / qi.hpp", including or explicitly reports that the structure of functions is placed inside the global namespace:

BOOST_FUSION_ADAPT_STRUCT(
  ::function,
  (std::string, ret_type)
  (std::string, name)
)
+4
source share
2 answers

When you use a macro BOOST_FUSION_ADAPT_STRUCT, it creates some types and puts them in the namespace boost. The definition of these types will refer to the name of the structure you gave it.

struct , , boost: boost::function, , -, boost qi. boost, , boost::function, ::function.

: "struct_name , ". , :: .

+5

, function, , . , :

#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/spirit/include/qi.hpp>

#include <string>

struct my_function
{
  std::string ret_type;
  std::string name;
};

BOOST_FUSION_ADAPT_STRUCT(
  my_function,
  (std::string, ret_type)
  (std::string, name)
)

int main() {}
+2

Source: https://habr.com/ru/post/1525614/


All Articles