$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Oleg G. Abrosimov (beholder_at_[hidden])
Date: 2005-01-28 03:06:09
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?
> won't be using the class template directly.
> Other, more conventional approaches, like having the
> definitions of the class template out of line in a
> separate file, are harder to maintain and proved to
> be problematic with buggy compilers (MSVC++ 6.5.)
> Yet another alternative is to use the pimpl idiom, but
> this has a runtime penalty.
> 
> My question is: is this ODR compliant? Anyone sees a
> problem with this approach? Thank you,
> 
> Joaquín M López Muñoz
> Telefónica, Investigación y Desarrollo
> 
> _______________________________________________
> Unsubscribe & other changes: http://listarchives.boost.org/mailman/listinfo.cgi/boost
>