Boost logo

Boost :

Subject: Re: [boost] [contract] SFINAE question for concepts
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2012-10-03 19:51:19


On Wed, Oct 3, 2012 at 7:41 PM, Matt Calabrese <rivorus_at_[hidden]> wrote:

> Also, I'm going to warn you now because I went down this same exact path
> with Generic -- you're going to have to change your approach for
> representing givens -- datamembers and even function parameters will not
> work. The problem is, you need to account for checking of "void", but with
> this implementation, you'll get a hard error instead of a compile-time bool
> value. You need to get everything into a context where SFINAE can take
> place. My approach with the old-style generic was to do all of the checking
> in a template specialization pattern list (as opposed to in a function
> template definition), and I used template reference parameters for the
> givens.
>

I'm not sure how much help it'll be, but you can look at the .hei files in
Boost.Generic's std_concept headers to see how I do the checks exactly. All
the tests for all of my concepts explicitly check results when using void
for each of the concept arguments, along with other "problem" types (such
as function types, since a function type that appears in a function
parameter list is treated as a function pointer type). The approach I use
should work for your N3351 concepts implementation as well, but it might
not be worth trying to figure out the preprocessor output. Anyway, my
recommendation is just make all of your givens template arguments (not
function arguments) and do all of your SFINAE stuff as a part of a
specialization of that template.

-- 
-Matt Calabrese

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