
I have a variety of user defined function objects that I will need to call. Take the following examples:template<int N1, int N2 = 0> struct Func1{ double operator()(boost::array<double, N1>& x1, boost::array<double, N2>& x2){...}}; template<int N1> struct Func2{ double operator()(boost::array<double, N1>& x){...}}; With a function such as template<int N1, int N2 = 0, class F = boost::function<double (boost::array<double, N1>& x1, boost::array<double, N2>& x2)> class DPP{ void solve(){...... uses F...to be discussed} }; I have a few questions: 1) Is there a relatively easy way to use boost concept check to verify that F follows the first function signature so that I can detect compile time the problem? I can't figure out how to do it from the concept check docs, and they say they are out of date. Usage I want to check in the instantiation of DPP: F f; f(boost::array<double, N1>& x1, boost::array<double, N2>& x2) 2) I want the user to be able to pass in a simplified function type if N2 = 0 I assume that to call the actual function I would have some kind of impl function with partial specialization such as: template<bool use_simplified, int N1, int N2> struct use_f_impl(); template<int N1, int N2> struct use_f_impl<true, N1, N2>{ static double use_f() { STATIC_ASSERT(N2 == 0); F f; boost::array<double, N1> x; return f(x); } }; template<int N1, int N2> struct use_f_impl<false, N1, N2>{ static double use_f() { F f; boost::array<double, N1> x1; boost::array<double, N2> x2; return f(x1, x2); } }; And then in my solve() function I go: double val = use_f<(N2 == 0, N1, N2)>::use_f(); Is this the right idiom, pattern, etc? Do I need to use the struct with a static function since function templates don't have partial specialization? 3) Now what if I want to do a concept check on the F passed into DPP? It has to be conditional on the N2 value now. How would I do this? 4) Lets say that I don't want to force them to use the simplified version of the function signature if they don't want to. Can I automatically detect the signature and put it into a flag integer in the class? i.e. inside of the DPP class: static bool use_simple = IsSimple<F>::value; Then pass in the use_simple value when calling use_f_impl. If so, what would the IsSimple metafunction look like and can concept check help? Thanks, Jesse