|
Boost-Build : |
From: Patrick Frants (gclbb-jamboost_at_[hidden])
Date: 2002-10-24 04:07:42
David Abrahams <dave_at_[hidden]> wrote in
news:uk7k8ap4b.fsf_at_[hidden]:
> Alisdair Meredith <gclbb-jamboost_at_[hidden]> writes:
> One way to avoid some of the maintenance overhead of this approach is
> to use explicit specializations of a function template:
>
> template <int n> register_initializer() {}
>
> template <int num_registrations>
> void register_all_initializers()
> {
> register_initializer<num_registrations - 1>();
> register_all_initializers<num_registrations - 1>();
> }
>
>
> template <> void register_all_initializers<0>() {}
>
>
> Now you can explicitly instantiate specializations of
> register_initializer in the translation units that need to have
> initializers run.
So I have register_initializer instantiations from 0 to n in all cpp files.
And the register_all_initializers template will recursively call these
function from n down to 0. I see it is easy to extend this with an extra
template parameter for the library and the initializers within a library
count from 0 to n. Is there a chance that you would hit an artificial limit
in the template expansion code of the compiler if n is large (> 1500)?
Patrick
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk