I've got an .h
file containing 2 different functions declaration:
#ifdef MY_HEADER
#define MY_HEADER
void a();
void b();
#endif
Now into .cpp
file I want to implement those functions as different instances of another templated function:
#include "my_header.h"
namespace {
template<size_t N>
void c()
{
...
}
}
void (*a)() = c<42>;
void (*b)() = c<265>;
I'm getting an error message error: 'void (* a)()' redeclared as different kind of symbol
. I've also tried a = c<42>
and auto a = c<42>
with no luck.
I know I can do it like this:
void a() {c<42>();}
void b() {c<265>();}
and I'm almost sure compiler will optimize this extra function call for me, but I'm wondering if there's a better way to declare this. I don't want to put c
function itself into .h
file either because this function is quite heavy and I don't want to have it recompiled in every source file using my header.
Aucun commentaire:
Enregistrer un commentaire