|
Boost : |
Subject: Re: [boost] [config] gcc-4.4 and BOOST_NO_SFINAE_EXPR
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-09-24 19:51:26
On 09/24/2012 08:15 PM, Eric Niebler wrote:
> I confess to not understanding how the config tests work. When I run
> "bjam toolset=gcc-4.4 config_test" in libs/config/tests, the tests pass
> whether or not S_NO_SFINAE_EXPR is defined for gcc-4.4. I'm clearly
> doing something wrong.
Looks like the test is not good enough then.
(I was the one who wrote that particular test, but I don't quite
understand the Boost.Config testing mechanism either)
> Anyway, here is a test for sfinae-expr that fails with gcc-4.4:
>
> template<typename T> T declval();
>
> struct not_incrementable {};
>
> struct inc {
> template<typename T>
> auto operator()(T t) const -> decltype(t++)
> { return t++; }
> };
>
> template<typename T>
> struct wrap
> {};
>
> template<typename A>
> int try_inc(wrap<decltype(declval<inc>()(declval<A>()))> *) {
> return 0;
> }
>
> template<typename A>
> not_incrementable try_inc(...) {
> return not_incrementable();
> }
>
> struct X {};
>
> int main() {
> int x = try_inc<int>(0); // OK
> not_incrementable y = try_inc<X>(0); // OK, not_incrementable
> }
>
SFINAE for expressions also works in C++03, so it would be better if you
could have a C++03 testcase.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk