Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2004-12-02 00:09:21

Jonathan Turkanis wrote:
> The case you're interested in is
> const std::string h() { return "hello"; }
> which now fails, except on GCC 3.4 :( Are you sure GCC is wrong here?

Not 100% sure, but I'm inclined to think so. The reason is the second
overload of lvalue_test2:

template<typename T>
lvalue_test2( T&, int,
>::type* = 0 );

Given an expression of type "const rvalue-type", the expression will
successfully bind to the T& with T deduced as "const rvalue-type". Then,
enable_if< is_const<T> > will succeed, so this overload is chosen over
the one with the elipses. That's causing the false positive (true negative).

Seems to me that Arkadiy has run up against the same problem with
BOOST_TYPEOF_PRESERVE_LVALUE, which also gets this case wrong (according
to the docs).

Eric Niebler
Boost Consulting

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