Boost logo

Boost :

Subject: Re: [boost] [offtopic] C++11 useful trick
From: Kim Barrett (kab.conundrums_at_[hidden])
Date: 2012-07-03 11:00:16


On Jul 3, 2012, at 3:13 AM, Eric Niebler wrote:
> On 7/2/2012 7:26 PM, Ravi wrote:
>> On Monday, July 02, 2012 12:41:22 PM Eric Niebler wrote:
>>>> Use of a C++11 feature just for the sake of it doesn't seem like such a
>>>> good idea to me.
>>>
>>> <baffle> Have I not given enough good reasons above? Maybe I'll just
>>> keep my good ideas to myself next time. :-/
>>
>> Please don't. This one is actually pretty widely applicable if you are doing
>> type deduction in C++11; it took me quite a while to figure this one out when
>> I ran into it. I, too, fail to see how the reasons you gave were not perfectly
>> clear.
>
> Thanks Ravi. For the record, this trick is also useful for CRTP bases
> when you need to static_cast this from base to derived in a return type:

Something like this also showed up in Matt Calabrese's suggested BOOST_ENABLE_IF() macro that appeared in this thread:

    http://lists.boost.org/Archives/boost/2011/08/184465.php

I didn't really understand the introduction of the dummy template parameter at the time, and the explanation Matt gave was (rough paraphrase, I can't find the exact quote)

    The BoostDetailEnableIfDependentType template parameter exists in order to ensure that the later condition is dependent on a template argument.

which was pretty opaque to me at the time, but with Eric's explanation I think maybe I now understand.


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