Explicit specialization of function templates causes linker error

后端 未结 2 830
滥情空心
滥情空心 2020-12-09 19:35

Functions.h:

#pragma once
#include 

template void TemplatedFunction(T* p) {}

template<> void TemplatedFunction

        
2条回答
  •  悲&欢浪女
    2020-12-09 19:54

    Such explicit specialisations should be moved to a .cpp file or made inline. The linker will find them there. If you define them in the header you will be getting "already defined" error messages just like you would get them for ordinary non-inline and non-static functions defined in a header included by multiple compilation units.

提交回复
热议问题