Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2005-04-09 17:34:08


"Stephen Gross" <sgross_at_[hidden]> writes:

> To review:
>
>> When including "boost/iterator/indirect_iterator.hpp", I get:
>>
>> "/usr/local/sagedev/apis/include/boost_1_32_0/boost/detail/is_incrementable.hpp",
>> line 56: error:
>>
>> expression must have arithmetic, enum, or pointer type
>>
>> BOOST_STATIC_CONSTANT(
>> ^
>
> Some new thoughts upon investigation:
>
> It is not in the BOOST_STATIC_CAST.

There is no such symbol in use.

> Doing manual compiler preprocessing has resulted in the following
> code, which is what the compiler is complaining about:
>
> template <class T>
> struct impl
> {
> static typename remove_cv<T>::type& x;
>
> static const bool value = sizeof(is_incrementable_::check(++x,0)) ==
> 1;

If that's the code it generated, your preprocessor is seriously
broken.

It should be generating an extra set of parens around "++x,0".

> };
>
> The problem is the ++x, not the static cast.

There's no static cast. How do you know the problem isn't in the
use of the comma operator?

> The problem seems to be a question of that x variable.
>
> If I replace the typename of x with, say int&, it works with one
> additional modification (see below), and if I replace it with a
> non-incrementable object, say 'foo', that also works. My theory was it
> might be in the remove_cv, but replacing the type with T& does not
> work. We still get the 'must be of XXX' type message despite T being
> known to be a type.

I suggest you find the line in is_incrementable.hpp that says:

# if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) \

and change it to:

# if 1 || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) \

> So, it would seem to be something about the templates.

Well, _that_ was sort of obvious from the beginning ;-)

> I'm stuck at this point.
>
> What I had to do to make known types work:
>
> With known types (int, foo), the compile only works when I add an
> additional set of parentheses around the ++x,0 in the check. I assume
> this is an order of evaluations thing,

Technically it's a "are there one or two arguments to check?" thing,
although that appears to be what you mean by "order of evaluation."
The fact is that the parens control how the call is parsed. As I said
those parens should be in the preprocessed output. If they really
aren't you might need to additionally change:

  BOOST_comma(++x,0)

to

  (BOOST_comma(++x,0))

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net