Код: Выделить всё
template
struct X {
template
X(T t) {}
};
template
void f(X x, A a) {}
int main() {
f(0, 0);
}
Код: Выделить всё
test.cc:20:10: error: no matching function for call to ‘f(int, int)’
20 | f(0, 0);
| ~^~~~~~
test.cc:17:6: note: candidate: ‘template void f(X, A)’
17 | void f(X x, A a) {}
| ^
test.cc:17:6: note: template argument deduction/substitution failed:
test.cc:20:10: note: mismatched types ‘X’ and ‘int’
20 | f(0, 0);
| ~^~~~~~
Но вот что интересно заключается в том, что static_assert не вызывает ошибку времени компиляции:
Код: Выделить всё
static_assert(std::is_convertible_v); // no assertion failure
Подробнее здесь: https://stackoverflow.com/questions/787 ... -happening