Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2004-01-09 19:52:33

Peter Dimov wrote:
> Lars Gullik Bjønnes wrote:
>>"Lucas Galfaso" <lgalfaso_at_[hidden]> writes:
>>>Actually, type qualifier on the return type of member functions is
>>>meaningless (if they are not returned by referece.)
>>Why? I've found them useful.
> Rvalues of built-in types are never cv-qualified, so when you write, for
> example,
> double const f();
> void const * const g();
> you get a warning from EDG (and maybe others.)

That may be true for built-in types, but certainly not for user
defined types. The context of the issue is phoenix's value objects.
Removing the const makes meaningless lambda code such as:

    value(x) += arg1

(where x is a user defined type with a += operator) pass but
silently do nothing.

It is possible to suppress the warning by adding the const only
for user defined types, say:

     apply_if<is_builtin<T>, identity<T>, add_const<T> >::type

but... is the extra compile time computation worth it?


Joel de Guzman

Boost list run by bdawes at, gregod at, cpdaniel at, john at