Код: Выделить всё
#include
template class Any {
T value_;
public:
explicit Any(T value) : value_(value) {}
};
int main() { Any a = 1; }
Код: Выделить всё
other.cpp:10:18: error: no viable constructor or deduction guide for deduction of template arguments of 'Any'
int main() { Any a = 1; }
^
other.cpp:3:29: note: candidate template ignored: could not match 'Any' against 'int'
template class Any {
^
other.cpp:7:12: note: explicit constructor is not a candidate
explicit Any(T value) : value_(value) {}
^
1 error generated.
Код: Выделить всё
int main() { Any a(1); }
Подробнее здесь: https://stackoverflow.com/questions/790 ... ifferences