|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2007-05-20 22:44:44
I've noticed something odd about the specification of tr1::result_of. In
result_of<F()>::type, if F is a class type that doesn't have a nested
result_type typedef, the result is "void". This is only true for F();
that is, when there are no arguments. That leads to the following
strangeness:
struct foo {
typedef int result_type;
};
struct bar {
template<class Sig> struct result {
typedef int type;
};
};
result_of<foo()>::type == int // 1
result_of<bar()>::type == void // 2 huh?
result_of<foo(int)>::type == int // 3
result_of<bar(int)>::type == int // 4
This is the way it's specified in TR1, and boost::result_of implements
this behavior faithfully, but I just can't understand why (2) is void
instead of int. Can somebody explain it to me?
-- 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