Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2005-02-15 16:13:35

On Tue, 15 Feb 2005 13:15:51 -0500, christopher diggins wrote:
> What do you think of the idea of passing of pointers to profile_manager
> variables to the profilers?

I personally like this idea.

As an added bonus, it will reduce compilation time dramatically, since the
Profile class itself does not need to be templated, and the
profile_manager class can then become a pure virtual class that must be
derived by a real class.

So your class to output to an ostream on generate_report might be:

class ostream_profile_manager : public profile_manager
    std::ostream os_;
    ostream_profile_manager(std::ostream &os) : os_(os) {}
    virtual ~ostream_profile_manager() {}

    // override pure virtual function in profile_manager
    void generate_report();

The Profile classes then just get a profile_manager class (it can still be
by reference, if its virtual, it will be taken care of), and thus the
Profile class does not need to be templated anymore, and you use
inheritance instead to handle what you used policies before to handle.

Of course, you could make profile_manager a policy based class, but then
that bumps up the compile time of the code again, since Profile also has
to be templated to handle varying types of templated profile_managers.

Either way, I approve of the manager being passed to the profile class, so
that multiple profile 'groups' can be used at once :)

PreZ :)
Founder. The Neuromancy Society (

Boost list run by bdawes at, gregod at, cpdaniel at, john at