Boost logo

Boost :

Subject: Re: [boost] is_range metafunction
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2008-10-07 14:47:07


On Tue, Oct 7, 2008 at 2:52 AM, Joel Falcou <joel.falcou_at_[hidden]> wrote:
> Daniel Walker a écrit :
>>
>> Yeah, that's kind of what I was getting at by a compile time eval or
>> is_compilable. But those are misnomers. You're not checking validity
>> for whole blocks or statements, just single expressions with a given
>> type. But yeah, you could wrap the general boilerplate in a
>> preprocessor metafunction and maybe call it something like
>> BOOST_HAS_EXPRESSION.
>
> <snip>
>>
>> For platforms with concept language support, you would use CRFINAE
>> instead of expression SFINAE on the two test() functions. At least,
>> this is the general idea. I assume something like this would work...
>>
>
> I use this kind of code in a large number of code of my own and already have
> some proper macro. Mayeb i can upload my files somewhere so we can check ?

I don't think we exactly understand each other here. Mathias' examples
and mine both use C++0x features that, to my knowledge, are not
available on any released compiler (gcc 4.4 is in beta). The point in
question is the use of C++0x expression SFINAE and CRFINAE to
implement concept checking as a boolean metafunction. By
BOOST_HAS_EXPRESSION, I mean a general preprocessor boilerplate macro
that would generate metafunctions to detect the validity of ANY
expression as evaluated in the context of decltype or sizeof, i.e. not
just membership access but virtually any non-void expression. I don't
believe that's possible on C++03.

Of course, I think there is a need to package SFINAE techniques as a
nice library for compile-time class-based type introspection -
something beyond MPL's HAS_XXX. I've done some work on this myself,
actually, and I once submitted a patch implementing HAS_XXX for member
templates, but I believe it got lost in the SVN migration. This is
another topic that doesn't relate to is_range, but yeah, sure, if you
have something along these lines, by all means, share it! ;-)

Daniel Walker


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