I don't understand why it's not compiling correctly, the linker reports missing symbols:
Undefined symbols for architecture x86_64: "bool swinadventure::Utils::is_last<__gnu_cxx::__normal_iterator > >, std::vector > >(__gnu_cxx::__normal_iterator > >, std::vector > const&)", referenced from: swinadventure::Inventory::get_item_list(std::string, std::string) in Inventory.cpp.o
Because eariler in the process I also see this error: /usr/bin/ranlib: file: liblibswinadventure.a(Utils.cpp.o) has no symbols I assume that it's not compiling the utils file correctly for some reason.
For reference, I'm using CMake on a Mac OS X 10.7 system with most homebrew tools installed and linked.
Utils.h
#ifndef UTILS_H_ #define UTILS_H_ #include <vector> namespace swinadventure { /** * Static class for various utilities and helper functions */ class Utils { public: template <typename Iter> static Iter next_iterator(Iter iter); template <typename Iter, typename Cont> static bool is_last(Iter iter, const Cont& cont); }; } /* namespace swinadventure */ #endif /* UTILS_H_ */ Utils.cpp
#include "Utils.h" namespace swinadventure { /** * Returns the next iterator * http://stackoverflow.com/questions/3516196/testing-whether-an-iterator-points-to-the-last-item * @param iter * @return */ template <typename Iter> Iter Utils::next_iterator(Iter iter) { return ++iter; } /** * Checks if the iterator is the last of the vector array * http://stackoverflow.com/questions/3516196/testing-whether-an-iterator-points-to-the-last-item * @param iter iterator * @param cont vector array * @return */ template <typename Iter, typename Cont> bool Utils::is_last(Iter iter, const Cont& cont) { return (iter != cont.end()) && (next_iterator(iter) == cont.end()); } } /* namespace swinadventure */