【发布时间】:2012-08-08 14:07:49
【问题描述】:
假设您尝试执行以下操作:
template</* args */>
typename std::enable_if< /*conditional*/ , /*type*/ >::type
static auto hope( /*args*/) -> decltype( /*return expr*/ )
{
}
是否可以将条件包含/重载 (std::enable_if) 与尾随返回类型 (auto ... -> decltype()) 结合起来?
我不会对使用预处理器的解决方案感兴趣。我总是可以做类似的事情
#define RET(t) --> decltype(t) { return t; }
并将其扩展为也采用整个条件。相反,如果语言支持它而不使用返回类型的另一个特征,即ReturnType<A,B>::type_t 或函数体中使用的任何内容,我感兴趣。
【问题讨论】:
标签: c++ templates c++11 sfinae trailing-return-type