Boost logo

Boost :

Subject: Re: [boost] [offtopic] C++11 useful trick
From: Roland Bock (rbock_at_[hidden])
Date: 2012-07-04 05:07:21


On 2012-07-04 09:50, Eric Niebler wrote:
>> - original code: Eric's version
>> - second attachment: my "boring" version
>> Richard also offers an alternative (see ticket link above) which he
>> claims to be much more effective, but I haven't comprehended it yet...
> Yes, I get it. He's using a variant of the variadic tuple trick. He
> wants to find the Nth element in a parameter pack. So he puts all the
> elements in a tuple-like thingy (select_impl) which holds individual
> elements, each in its own base class (select_base). But only the Nth
> base actually holds onto its argument. (See the partial specialization
> of select_base.) His solution instantiates O(N) instances of
> select_base, but gets you the Nth element in O(1). Fiendishly clever.
>

Huh! Thanks for the explanation!

Really awesome! :-)


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