[英]C++ template determine function return type
How can I go about determining return type of a member generic function? 如何确定成员泛型函数的返回类型?
template<class E>
struct result<E> {
// E has member function data(), I need to know its return type
typedef typename &E::data type;
};
is it possible to do it in generic way? 是否可以通用方式进行? I know there is
boost:: result_of
but for my purposes it lacks specializations (if I understood correctly, return type must be specialized). 我知道有
boost:: result_of
但是为了我的目的它缺乏特化(如果我理解正确,返回类型必须是专门的)。 boost implementation would be great. 提升实施将是伟大的。
GCC的非标准的typeof运营商可以做到这一点,因为可以Boost.TypeOf 。
如果您至少使用VS2010或GCC 4.3,则可以使用C ++ 0x new关键字decltype
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.