argument-deduction

Understanding SFINAE

一曲冷凌霜 提交于 2019-11-27 14:06:49
问题 As far as I know, SFINAE means substitution failures do not result in compilation errors, but just remove the prototype from the list of possible overloads. What I do not understand: why is this SFINAE: template <bool C, typename T = void> struct enable_if{}; template <typename T> struct enable_if<true, T> { typedef T type; }; But this is not? template <bool C> struct assert; template <> struct assert<true>{}; From my understanding, the underlying logic is identical here. This question

What is a nondeduced context?

风格不统一 提交于 2019-11-25 22:27:14
问题 I\'ve stumbled over \" Why is the template argument deduction not working here? \" recently and the answers can be summed up to \"It\'s a nondeduced context\". Specifically, the first one says it\'s such a thing and then redirects to the standard for \"details\", while the second one quotes the standard, which is cryptic to say the least. Can someone please explain to mere mortals, like myself, what a nondeduced context is, when does it occur, and why does it occur? 回答1: Deduction refers to