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