I've run into an issue trying to keep my implementation details out of reach of the user when writing templates because they reside in headers.
In a typical .cpp
file, implementation details can be completely hidden by using internal linkage through inline namespaces or the static
keyword. But, this doesn't do much in headers since they're not separate translation units.
What I've settled on is having an implementation namespace, and just assuming that the user won't be inclined to mess with it. But, I'd rather not give the user an option to see it at all. Is this possible?
What I currently do:
//template_stuff.hpp
namespace impl {
// stuff used in code below
}
namespace project {
// templates that use entities in ::impl
}
A question I have for the future is if modules will resolve this issue for me. I hope so, but I don't know enough details about the final design to conclude this.