Boost logo

Boost Users :

Subject: [Boost-users] [mpl] is_constructible_from
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-03-13 04:48:25


I need a metafunction that returns true iif a type has a constructor with 2
arguments of a given type. Does mpl have it? If not, is it possible to
implement?

template <class C, class T1, class T2>
struct is_constructible_from;

struct foo { foo(int, int); };
struct bar { bar(int*, int); };
struct baz {};

int main() {
  assert(is_constructible_from<foo, int, int>::value);
  assert(is_constructible_from<foo, int, double>::value);
  assert(!is_constructible_from<bar, int, int>::value);
  assert(!is_constructible_from<baz, int, int>::value);
};

Roman Perepelitsa.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net