У меня ситуация как этотаргумент шаблона для функции в шаблон класса
template<class T> class Vector {
T *data;
uint _size, _counter;
public:
class Iterator;
template<template<class> class C> Vector(typename C<T>::Iterator it1,
typename C<T>::Iterator it2) {
data = NULL;
_size = _counter = 0;
for(typename C<T>::Iterator it = it1; it != it2 && it != end(); it++)
push(*it);
}
};
, что это мой собственный вектор класс и поведение конструктора подражает вектора (и можно построить его с диапазоном данных, предоставленных с использованием interators), но добавьте требование о том, чтобы контейнер был шаблоном того же типа, что и тот, который строится. Я получаю ошибку
5.cpp:16:36: error: no matching function for call to ‘Vector::Vector(Vector::Iterator, Vector::Iterator)’ 5.cpp:16:36: note: candidates are: In file included from 5.cpp:2:0:
5.hpp:17:37: note: template class typedef C C> Vector::Vector(typename C::Iterator, typename C::Iterator)
5.hpp:17:37: note: template argument deduction/substitution failed:
5.cpp:16:36: note: couldn't deduce template parameter ‘template class typedef C C’ In file included from 5.cpp:2:0:
5.hpp:11:3: note: Vector::Vector() [with T = int]
5.hpp:11:3: note: candidate expects 0 arguments, 2 provided
5.hpp:7:25: note: Vector::Vector(const Vector&)
5.hpp:7:25: note: candidate expects 1 argument, 2 provided
Нужна помощь здесь.
Что, что 'шаблон <шаблон класс C>'? –
конструктор - это шаблонный метод с параметром C, который сам по себе является шаблоном с одним именем параметра unvelant. –
'it! = End()'. Это не так. – jrok