Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-01-16 19:20:30


Hi List,

The code below fails to compile with MSVC8 when the macro MAKE_THINGS_FAIL is defined.

I hope the code reads well enough to communicate the problem and why it would be
quite hot to get it fixed ;-).

Thanks a lot for your help,

Tobias

   #include <boost/spirit/core.hpp>
   #include <boost/typeof/typeof.hpp>

   #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
   BOOST_TYPEOF_REGISTER_TYPE(boost::spirit::anychar_parser)
   BOOST_TYPEOF_REGISTER_TEMPLATE(boost::spirit::action, 2)
   BOOST_TYPEOF_REGISTER_TEMPLATE(boost::spirit::positive, 1)

   #define an_expression +anychar_p[ a_placeholder ]

   typedef void (* fptr)(char const * from, char const * to);

   void echo(char const * from, char const * to)
   {
     // [...]
   }

   #ifndef MAKE_THINGS_FAIL

   using boost::spirit::anychar_p;

   class a_rule_parser
     : boost::spirit::parser<a_rule_parser>
   {
     fptr a_placeholder;

     struct __rule
     {
       // hide the placeholder member variable of the outer class with a static
       // variable of the same type
       static fptr & a_placeholder;

       typedef BOOST_TYPEOF( an_expression ) type;
     };

     __rule::type __expr;
   public:

     a_rule_parser(fptr placeholder)
       : a_placeholder( placeholder )
       , __expr( an_expression )
     { }

     // [...] (it's stripped down code to show a bug)
   };

   int main()
   {
     a_rule_parser x(& echo);
     return 0;
   }

   // so far, so good...

   #else

   // ...but the same code in templated form makes msvc8 do strange things

   // using boost::spirit::anychar_p;
   using namespace boost::spirit;
   // ADL doesn't seem to work, either but I could live with this problem ;-)

   template<typename T>
   class a_rule_parser_template
     : boost::spirit::parser< a_rule_parser_template<T> >
   {
     T a_placeholder;

     struct __rule
     {
       // hide the placeholder member variable of the outer class with a static
       // variable of the same type
       static T & a_placeholder;

       typedef BOOST_TYPEOF_TPL( an_expression ) type;
     };

     typename __rule::type __expr;
   public:

     a_rule_parser_template(T const & placeholder)
       : a_placeholder( placeholder )
       , __expr( an_expression )
     { }

     // [...] (it's stripped down code to show a bug)
   };

   int main()
   {
     a_rule_parser_template<fptr> x(& echo);
     return 0;
   }
   #endif


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk