|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2007-08-10 15:08:51
on Fri Aug 10 2007, Mathias Gaunard <mathias.gaunard-AT-etu.u-bordeaux1.fr> wrote:
> Ion Gaztañaga wrote:
>
>> I don't know much about Boost.Parameter but my goal is maintain
>> Boost.Intrusive independent of heavy template-metaprogramming machinery,
>> because the library is adequate for embedded systems and I wouldn't want
>> the executable to grow with type-info information/increased compilation
>> time created by meta-programming (I might absolutely wrong with this
>> sentence, so please feel free to correct).
>
> It's not the first time I've seen this, and I still do not understand
> what the belief of template meta-programming causing bloat is based on.
>
> It certainly increases compilation time, of course, since the point is
> to create a domain specific language for the problem domain -- using the
> type system -- and evaluate it at compile-time to generate the best
> targeted code, but it certainly doesn't make the executable needlessly
> grow at all.
> All information about types is lost once a program is compiled. (apart
> from debugging information, of course)
Imagine you have a function [template] f using named parameters. Then
f(n = 4, s = "hello");
and
f(s = "hello", n = 4);
instantiate different specializations of f at the top level even
though the two are functionally equivalent. Of course, everything in
f that generates substantial code can be in an implementation function
-- say, f_impl -- whose template parameters are identical for the two
invocations, so in the end I don't think there's much to worry
about. f simply gathers up and distributes references to its
arguments.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk