Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 流操作器过载的标准(或最佳外观)SFINAE实现_C++_Templates_C++14_Sfinae - Fatal编程技术网

C++ 流操作器过载的标准(或最佳外观)SFINAE实现

C++ 流操作器过载的标准(或最佳外观)SFINAE实现,c++,templates,c++14,sfinae,C++,Templates,C++14,Sfinae,我有以下代码 template<typename S, typename T, bool h = is_class< decltype(T::children)>::value > S& operator<<(S& s, const T& t ) { return s; } template::value> S&operatorstatic\u断言或依赖编译器来发现错误。坏鸭子键入-T::children太普遍了当它失

我有以下代码

template<typename S, typename T, bool h = is_class< decltype(T::children)>::value >
    S& operator<<(S& s, const T& t )
{
    return s;
}
template::value>

S&operator
static\u断言
或依赖编译器来发现错误。坏鸭子键入-
T::children
太普遍了当它失败时,你会“与
运算符不匹配为什么不能为SFINAE使用返回类型?t.C.好问题。在回顾原因时,我想到了像typename enable\u if,S>这样的方法。这就是你的想法-对吗?谢谢你的提问,这让我重新思考我的假设。