Boost logo

Boost Users :

Subject: Re: [Boost-users] [concept check][mpl] (Conditional) Concept checking for functions
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-03-30 22:41:50


Jesse Perla wrote:
> One rough idea I had was that since I will always have boost::function
> declarations as the default type, I could try to see if the type F is
> compatible with the boost::function type? Could this be done in a simple
> metafunction similar to the following:
> template<class BoostF, class F>
> struct CheckFunctionCompatible
> {
> static void Check()
> {
> F f;
> BoostF fboost = f; //If this fails, then I am basically failing
> }
> };
> But then if I instantiate, won't it also try to instantiate the constructor?

You could do it like this, but I doubt the error messages
from deep inside boost::function will be very helpful.

template<class BoostF, class F>
class CheckFunctionCompatible {
    BOOST_CONCEPT_USAGE(CheckFunctionCompatible) {
        BoostF test(f);
    F f;

In Christ,
Steven Watanabe

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at