Boost logo

Boost :

Subject: Re: [boost] GSoC: Enforcing Code Feature Requirements
From: Vicente Botet Escriba (vicente.botet_at_[hidden])
Date: 2010-03-31 09:21:22

joel falcou-3 wrote:
>> Joel, maybe you can elaborate how the Concept/SFINAE approach manages
>> with this problem.
> Sure,
> in my head, we can define Concepts callee ThreadSafe, ExceptionSafe etc
> and just use BOOST_CONCEPT_REQUIRE on those (or the real C++0x concept
> maps) and have Concept Violation error when you try to call one function
> with improper settings. Then, IIRC there was planned to have SFINAE
> based on concept so we cna alos have function prunning (ie nice 'no such
> function f() defined' inthose case.
> Using BOOST.CC, I already do that for parallel computing enforcement: i
> have a type traits that I can specialize per obejct or function type
> basis and the concept class just check for this concept then I write:
> template<class F,class A>
> BOOST_CONCEPT_REQUIRE( (CalalbleObject<F>)(DataParallel<F>)
> , std::vector<boost::result_of<F(A)>::type>
> )
> map( F f, std::vector );
> if f is not a CallableObjec supporting data-parallelism (here I just
> check that is_dataparallel<F>::value is true) then the function is not
> permitted.
> Such a mechanism can be applied to what's describe in the article, or am
> I mistaken ?

Well, the problem is that the constraints on features must be checked on the
caller function. So you will need to add a parameter or a template parameter
for the caller function. This is what I try to avoid.

In your case we will need to have

template<class F,class A, typename CALLER>
                      , std::vector<boost::result_of<F(A)>::type>
map( F f, std::vector );

and the user will need to call the function map as follows

void g() {
  map<void g()>(foo, v);

On the other side this can not be applied to 3pp function which don't have
specified the constraint using SFINAE.

Hoping my concern will be clear now.

View this message in context:
Sent from the Boost - Dev mailing list archive at

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