Peter Dimov wrote:
Peter Dimov wrote:
Ian McCulloch wrote:
Peter Dimov wrote:
[...]
I don't get it: can't you detect whether nested::result
::type exists? As long as the primary template of nested::result is defined as an empty struct this should work fine(?). No, consider what happens when 'nested' is int (*) (), for example.
Hm, it can't be int (*) (), because result_of will not attempt to look for a nested result, but it can be an user-defined type with no nested result, or a member named result.
Wouldn't both those cases (no nested result, or a member named result) cause
a substitution failure?
#include <iostream>
struct foo
{
template <typename T>
struct result { typedef int type; };
};
struct bar
{
template <typename T>
struct result {};
};
struct baz
{
void result() {}
};
struct bat
{
};
void func(...)
{
std::cout << "func(...)\n";
}
template <typename T>
typename T::result