У меня есть следующий маленький код:
template <typename T>
class V
{
public:
T x;
explicit V(T & _x)
:x(_x){}
};
int main()
{
V<float> b(1.0f); // fails
return 0;
}
И это происходит неудачно. Сообщение, возвращаемое g ++ 4.4.5:
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
../main.cpp: In function ‘int main()’:
../main.cpp:19: error: no matching function for call to ‘V<float>::V(float)’
../main.cpp:10: note: candidates are: V<T>::V(T&) [with T = float]
../main.cpp:6: note: V<float>::V(const V<float>&)
Дело в том ... откуда появился второй конструктор? Я действительно понятия не имею ...