I am now writing a project about some sort algorithm and having some trouble with it. Here is my project structure. I make it simple that might save your time
//-------Sort.h------
#ifndef....
class Sort{
public:
template <typename T>
static bool foo(T* t_, ...); //maybe more parameters
... //and maybe more functions
}
#endif
//--------foo.cpp-----
#include "Sort.h"
template<typename T>
bool Sort::foo(T* t_, ...){
... //function implementation
return true;
}
template bool Sort::foo<int>(int*, ...);
template bool Sort::foo<char>(int*, ...);
However, I found it not so good. I have to specific template function at the end of each .cpp files. What's more, I cannot use these functions with custom classes(because I didn't specific the function with this class).
But if I write everything in Sort.hpp files, I cannot compile .hpp file into .a or .lib. What can I do to compile my project into library files While reducing duplication of work?
highly appreciate your help.
thanks