Boost logo

Boost :

Subject: Re: [boost] [offtopic] C++11 useful trick
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-07-02 14:18:18


On 02/07/2012 19:29, Eric Niebler wrote:

> Yeah, it's booo-ring. ;-) Also, it needlessly instantiates O(N)
> templates. And why write both a function template *and* a class template
> when the function template alone will do? Now you have to maintain two
> computations in parallel. I hate writing metafunctions to compute things
> the compiler already knows. And in less trivial examples, the
> metafunction wouldn't be so easy to write. BTW, only the implementation
> of back needs to go in a struct. The user-visible function could fwd to it.

Have you done benchmarks that shows your approach is significantly faster?

Use of a C++11 feature just for the sake of it doesn't seem like such a
good idea to me. Especially since BOOST_TYPEOF in the return type tends
to be quite fragile, so it cannot really be emulated.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk