partial-ordering

Template partial ordering - why does partial deduction succeed here

最后都变了- 提交于 2019-11-26 08:23:28
问题 Consider the following simple (to the extent that template questions ever are) example: #include <iostream> template <typename T> struct identity; template <> struct identity<int> { using type = int; }; template<typename T> void bar(T, T ) { std::cout << \"a\\n\"; } template<typename T> void bar(T, typename identity<T>::type) { std::cout << \"b\\n\"; } int main () { bar(0, 0); } Both clang and gcc print \"a\" there. According to the rules in [temp.deduct.partial] and [temp.func.order], to

What is the partial ordering procedure in template deduction

寵の児 提交于 2019-11-26 05:26:34
问题 Reading the C++11 standard I can\'t fully understand the meaning of the following statement. Example are very welcome. Two sets of types are used to determine the partial ordering. For each of the templates involved there is the original function type and the transformed function type. [Note: The creation of the transformed type is described in 14.5.6.2. — end note ] The deduction process uses the transformed type as the argument template and the original type of the other template as the