据我所知,SFINAE意味着替换失败不会导致编译错误,只是从可能的重载列表中删除原型.
我不明白:为什么这个SFINAE:
template <bool C, typename T = void> struct enable_if{};
template <typename T> struct enable_if<true, T> { typedef T type; };
Run Code Online (Sandbox Code Playgroud)
但这不是吗?
template <bool C> struct assert;
template <> struct assert<true>{};
Run Code Online (Sandbox Code Playgroud)
根据我的理解,这里的基本逻辑是相同的.这个问题来自对这个答案的评论.