Templates and header organization

A

ALiX

When not using any templates I use Stroustrup's convention for
oraganizing my headers. For example, if I am implementing a module
called mymodule, then I have the following header organization:

mymodule.hpp - contains declarations and inline functions needed by
users of my_module
mymodule-impl.hpp - contains all declarations needed by the module.
This file #includes mymodule.hpp for consistency checking.
mymodule.cpp - contains the definitions. #includes mymodule-impl.hpp

I'd like to know what conventions others use when a module contains
templated functions and/or classes. My own attempts at a general
convention has failed. For example I once tried:

mymodule.hpp - declarations and inline functions for users. Must
#include mymodule-templ.hpp.
mymodule-templ.hpp - definitions of templated functions/members
needed by users
mymodule-impl.hpp - contains all declarations. #includes
mymodule.hpp for consistency.
mymodule.cpp - contains all non-template definitions. #includes
mymodule-impl.hpp

The problem is that sometimes functions in mymodule-templ.hpp need to
use functions not intended for users. Thereofore, I end up #including
mymodule-impl.hpp within mymodule-templ.hpp anyway, and so making
every declaration visible to the users code.

Cheers,
/ALiX
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top