Boost logo

Boost :

Subject: Re: [boost] C++11 Metaprogramming
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2012-04-04 11:49:44


On 03.04.2012, at 19:20, Dave Abrahams wrote:

>
> on Sun Apr 01 2012, Olivier Grant <olivier.grant-AT-gmail.com> wrote:
>
>> Hi Dave,
>>
>> That's going to be an interesting presentation. Here is a small piece of
>> code that allows to generate a traits structure that determines if a call
>> can be made on an object with a specific function name and specific
>> arguments and return value :
>>
>> https://gist.github.com/2276393
>> (compile with : g++ -std=c++0x -Wall -o has_callable has_callable.cpp)
>>
>> This was not possible in C++03, or at least not completely possible, and
>> the code is much simpler with C++11 for the cases where it was possible as
>> well.
>
> Yep, I see. However, I also have some questions about the utility of
> such traits. As I mentioned to Mathias, structural matching is always
> susceptible to false positives. What do you use this for?

I have used something like this to define a generic Set concept (bool contains(const Set& set, const Value& value)). Since in this concept, every normal value represents its own singleton set, I have used is_callable to separate out functions and function-like objects that return bool.

Sebastian


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