While searching for an answer to another question I developed a a helper class that would work with any kind of container of integers. Specifically, my class would lookup container values based on some criteria. In order to work with different types of containers, my class obviously needs to operate not on containers themselves but on their iterators. I don't need to reference containers anywhere in my class, I use only iterators and only in class constructor.
// Header file.
class MyLookup {
public:
template<typename ForwardIt> // Forward iterator though sequence of integers
MyLookup(ForwardIt begin, ForwardIt end)
...
}
// Implementation file
template<typename ForwardIt>
MyLookup::MyLookup(ForwardIt begin, ForwardIt end) {
...
}
// Use file
std::vector<int> foo;
...
MyLookup lookup(foo.begin(), foo.end());
While using CLang the initial compiler pass succeeds but then I get linker errors:
Undefined symbols for architecture x86_64: "MyLookup::MyLookup >(std::__1::__wrap_iter, std::__1::__wrap_iter)", referenced from: ...
Any idea what am I doing wrong?