|
Boost : |
From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2005-01-28 05:14:21
"Oleg G. Abrosimov" ha escrito:
> JOAQUIN LOPEZ MU?Z wrote:
> > This is not strictly related to Boost, but its
> > motivation comes from an effort to reduce compilation
> > times for a Boost library, so I'll risk posting the
> > question.
> > Consider the following:
> >
> > // *************** some_class_template.hpp ***************
> >
> > #ifdef INCLUDE_DEFINITION
> > # define BODY_INCLUDED 1
> > #else
> > # define BODY_INCLUDED 0
> > #endif
> >
> > #define BODY_DEFINITION(body) BOOST_PP_IF(BODY_INCLUDED,body,;)
> >
> > template<typename ...>
> > class some_template_class
> > {
> > ...
> > void f(...)
> > BODY_DEFINITION((
> > {
> > // implementation of f goes here
> > }
> > ))
> > ...
> > };
> >
> > // *************** foo.hpp ***************
> >
> > #include "some_class_template.hpp"
> >
> > class foo
> > {
> > void bar();
> >
> > private:
> > some_class_template<...> m;
> > };
> >
> > // *************** foo.cpp ***************
> >
> > #define INCLUDE_DEFINITION
> > #include "user.hpp"
> >
> > void foo::bar()
> > {
> > m.f(); // f is defined, OK to use it.
> > }
> >
> > Well, the idea is to generate in a simple way a
> > declaration only header of a template class from the full
> > definition, for those situations when the definitions are
> > not needed. The purpose is to reduce compilation times in
> > those translations units including foo.hpp, as they
>
> foo.hpp is not a translation unit, as I understand it...
> could you please explane were is a place for reduce of a compile time in
> your approach?
>
The reduction would take effect in any translation unit including foo.hp:
//**************** bar.cpp **********
#include<foo.pp>
// use foo
//**********************
(on a side note, Jonathan pointed out that the macro mechanism dows
not work, but my question holds regardless of the particular implementation
technique.)
Joaquín M López Muñoz
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk