Due to templates being templates, they need to be defined in a header file (making explicit instantiations is not an option). I have an extern function which takes an expanded template parameter pack:
#pragma once
extern "C" int bar(...);
class Foo {
template <typename ...Args>
int foo(Args&&... args) {
return bar(args...);
}
};
I thought about it for quite a while, and I can't figure out how to decouple this. I don't want bar to be in the header and the consumers of said header to have access to it, but because templates must be in a header file, I can't make a wrapper function that would contain the extern. The extern function cannot take va_list.
Is this even possible to do in a portable (compiler agnostic) way?
PS: the extern could be really anywhere, as long as it would somehow bypass templates requirement to be withing the header, and not be accessible to consumers of the header.
extern "C"? if not then you can declare it insidefoo