Re: [Boost-bugs] [Boost C++ Libraries] #3742: Fusion does not define mpl::sequence_tag for adapted structures

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3742: Fusion does not define mpl::sequence_tag for adapted structures
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-12-10 09:41:39


#3742: Fusion does not define mpl::sequence_tag for adapted structures
-----------------------------------------+----------------------------------
 Reporter: no.spam.mole@… | Owner: djowel
     Type: Bugs | Status: new
Milestone: Boost 1.42.0 | Component: fusion
  Version: Boost 1.41.0 | Severity: Problem
 Keywords: Fusion |
-----------------------------------------+----------------------------------

Comment(by anonymous):

 Here is a cpp file to reproduce the problem:

 {{{
 #include <typeinfo>
 #include <iostream>
 #include <boost/type_traits.hpp>
 #include <boost/array.hpp>
 #include <boost/mpl/char.hpp>
 #include <boost/mpl/or.hpp>
 #include <boost/mpl/is_sequence.hpp>
 #include <boost/mpl/vector_c.hpp>
 #include <boost/mpl/fold.hpp>
 #include <boost/mpl/push_back.hpp>
 #include <boost/mpl/string.hpp>
 #include <boost/fusion/include/vector.hpp>
 #include <boost/fusion/include/fold.hpp>
 #include <boost/fusion/include/mpl.hpp>
 #include <boost/fusion/adapted.hpp>

 namespace mpl = boost::mpl;
 namespace fusion = boost::fusion;

 template<typename T> struct Tr;

 template<> struct Tr<int> : mpl::char_<'i'> { };
 template<> struct Tr<char> : mpl::char_<'c'> { };
 template<> struct Tr<double> : mpl::char_<'d'> { };

 template<typename Sequence, typename State>
 struct Fold;

 struct F
 {
     template<typename S, typename E>
     struct apply :
         mpl::if_
         < mpl::is_sequence<E>
         , typename mpl::push_back
           < typename mpl::fold
             < E
             , typename mpl::push_back<S, mpl::char_<'('> >::type
             , F
>::type
           , mpl::char_<')'>
>::type
         , mpl::push_back<S, Tr<E> >
>::type
     {
     };
 };

 template<typename Sequence, typename State>
 struct Fold :
     mpl::fold
     < Sequence
     , State
     , F
>
 {
 };
 struct s
 {
     // uncomment this line to make the program compile.
     //typedef boost::fusion::fusion_sequence_tag tag;
     double i;
     double j;
     int k;
 };

 BOOST_FUSION_ADAPT_STRUCT(
         s,
         (double, i)
         (double, j)
         (int, k)
         )

 int main()
 {
     typedef fusion::vector<int, s, fusion::vector<int> > Seq;
     typedef Fold<Seq, mpl::vector_c<char> >::type f;

     std::cout << mpl::c_str<f>::value << std::endl;

 }
 }}}

 {{{
 /usr/include/boost/mpl/string.hpp: In instantiation of âconst char
 boost::mpl::c_str<boost::mpl::v_item<mpl_::char_<')'>,
 boost::mpl::v_item<Tr<int>, boost::mpl::v_item<mpl_::char_<'('>,
 boost::mpl::v_item<Tr<s>, boost::mpl::v_item<Tr<int>,
 boost::mpl::vector_c<char, 2147483647l, etc...
 test.cpp:78: instantiated from here
 /usr/include/boost/mpl/string.hpp:548: error: incomplete type âTr<s>â used
 in nested name specifier
 }}}

 This error is because the fusion adapted struct is not being recognised by
 the is_sequence function which always returns false in the struct case.
 You can uncomment the typedef tag line and it works. Output should be:
 {{{
 i(ddi)(i)
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3742#comment:4>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC