I am trying to write a library where I have some template functions, some of which are helper functions, so I do not want my users to have access to them. Some basic code may be
//mylib.h namespace myfuncs { template<class T> void helper (T input, int extrainformation) { //do some usefull things } template<class T> void dostuff(T input) { int someinfo=4; helper(input, someinfo); } }
Is it possible to somehow hide the helper function so that library users cannot call it directly? I thought an unnamed namespace could do the job, but since I use templates, I cannot separate the function declaration and body between the header and implementation file. Putting an unnamed namespace in the header file is useless and bad. The only thing I can do is create mylib class and encapsulate functions as private / public static functions.
Any better solutions would be greatly appreciated.
Phil
source share