Opened 14 years ago

Closed 13 years ago

#2234 closed Bugs (fixed)

Spirit2/Phoenix compilation error (front on iterator_range)

Reported by: François Barel <frabar666@…> Owned by: Joel de Guzman
Milestone: Boost 1.37.0 Component: spirit
Version: Boost 1.36.0 Severity: Regression
Keywords: spirit phoenix action attribute const front iterator_range Cc:

Description

The following source:

#include <boost/spirit/include/qi.hpp>
using namespace ::boost::spirit;
using namespace ::boost::spirit::qi;
using namespace ::boost::spirit::arg_names;

#include <boost/spirit/include/phoenix_stl.hpp>
using namespace ::boost::phoenix;

int main()
{
        rule< const wchar_t* > r;
        r = raw[ wchar ][ front(_1) ];

        return 0;
}

worked several months ago (before Spirit2 was brought in Boost svn), but no longer compiles with current svn-trunk, gcc gives the following error:

.../boost/spirit/home/phoenix/stl/container/detail/container.hpp:42:
  error: no type named ‘const_reference’
         in ‘const class boost::iterator_range<const wchar_t*>’


It seems due to r44555 which made attributes const in actions, as boost::iterator_range does not contain a const_reference typedef.

Note that replacing front with *begin works around the problem, since boost::iterator_range does contain a const_iterator typedef.


I don't know enough about iterator_range and Phoenix type deduction to know in which one this should be fixed... please tell me if I should submit a feature request ticket to add a const_reference typedef to iterator_range.

Change History (4)

comment:1 by Joel de Guzman, 14 years ago

Re:

I don't know enough about iterator_range and Phoenix type deduction to know in which one this should be fixed... please tell me if I should submit a feature request ticket to add a const_reference typedef to iterator_range.

Perhaps it's a good idea to minimize the problem to something that calls iterator_range directly and ask the author (Thorsten Ottosen & Pavol Droba) about it on the devel list.

comment:2 by anonymous, 13 years ago

I think this has been fixed somewhere. The following compiles:

#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_char_.hpp>
using namespace ::boost::spirit;
using namespace ::boost::spirit::qi;

#include <boost/spirit/include/phoenix_stl.hpp>
using namespace ::boost::phoenix;

int main()
{
        rule< const wchar_t* > r;
        r = raw[ char_ ][ front(_1) ];

        return 0;
}

comment:3 by Marshall Clow, 13 years ago

I can confirm that the code in the second comment compiles [ Mac OS X 10.6.2 / gcc 4.2.1/ boost trunk ], but the original poster's code does not.

junk.cpp:4: error: ‘arg_names’ is not a namespace-name
junk.cpp:4: error: expected namespace-name before ‘;’ token
junk.cpp: In function ‘int main()’:
junk.cpp:12: error: ‘wchar’ was not declared in this scope

comment:4 by François Barel <frabar666@…>, 13 years ago

Resolution: fixed
Status: newclosed

The original code was for Spirit 2.0. As reported by commenter #2, it now works on trunk (r58133).

The issue must have been solved when Spirit 2.1 was merged.

Note: See TracTickets for help on using tickets.