相关疑难解决方法(0)

了解SFINAE

据我所知,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)

根据我的理解,这里的基本逻辑是相同的.这个问题来自对这个答案的评论.

c++ templates sfinae c++11 argument-deduction

13
推荐指数
1
解决办法
2770
查看次数

标签 统计

argument-deduction ×1

c++ ×1

c++11 ×1

sfinae ×1

templates ×1