Subject: Re: [boost] is_range metafunction
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-10-06 06:58:03
Daniel Walker wrote:
> That's great news! That would do the trick!
Indeed, it's pretty cool.
In C++0x, if you write
auto foo(T&& t) -> decltype(t.foo())
Then that definition is only visible if T has a nullary foo member function.
It's basically the same as type inference in functional programming.
As of today, in GCC 4.4, you can do something equivalent but have to be
significantly more verbose:
template<typename T, size_t Cond>
typedef decltype(((T*)0)->foo()) type;
typename foo_type<T, sizeof(((T*)0)->foo() > 0)>::type foo(T&& t)
(You cannot put decltype directly in the return type because of name
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk