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"; }
> BOOST_STATIC_ASSERT(!BOOST_IS_LVALUE(h()));
>
> 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>
type_traits::yes_type
lvalue_test2( T&, int,
               typename
               enable_if<
                   is_const<T>
>::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
www.boost-consulting.com

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