Boost logo

Boost :

Subject: Re: [boost] [offtopic] C++11 useful trick
From: Eric Niebler (eric_at_[hidden])
Date: 2012-07-29 02:55:49

On 7/28/2012 7:10 PM, Dave Abrahams wrote:
> on Wed Jul 04 2012, Eric Niebler <> wrote:
>> 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.
> That explanation doesn't match what I'm seeing in his latest attachment

Right, I was commenting on this:

> (, which doesn't
> require storing anything. Which is pretty cool!

His latest implementation is very, very cool and I've already found
another use for his technique.

I'm slightly dismayed that we need to be so very clever to use variadic
templates efficiently. This stuff is not obvious AT ALL.

Eric Niebler
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at