I'm in a process of implementing loadAsset
method in my asset manager implementation. I've tried using variadic arguments template method with following signature:
class AssetManager {
public:
template <typename AssetType, typename... Args>
void loadAsset(std::string_view name, const Args &...args);
...
};
And following specialization in .cpp
file:
template <>
void AssetManager::loadAsset<Texture, std::string>(std::string_view name, const std::string &path) {...}
template void AssetManager::loadAsset<Texture, std::string>(std::string_view, const std::string &path); //explicit instantiation
However when trying to invoke loadAsset
method like so:
m_assetManager->loadAsset<NOX::Texture>("texture", "assets/textures/texture.jpg");
I get the following error:
error LNK2019: unresolved external symbol "public: void __cdecl NOX::AssetManager::loadAsset<class NOX::Texture,char [28]>(class std::basic_string_view<char,struct std::char_traits<char> >,char const (&)[28])" (??$loadAsset@VTexture@NOX@@$$BY0BM@D@AssetManager@NOX@@QEAAXV?$basic_string_view@DU?$char_traits@D@std@@@std@@AEAY0BM@$$CBD@Z) referenced in function "public: __cdecl ExampleApplication::ExampleApplication(struct NOX::ApplicationSpecification const &)" (??0ExampleApplication@@QEAA@AEBUApplicationSpecification@NOX@@@Z)
How can I prevent that from happening? I'm using C++17 and can't use C++20.