using std::__enable_if template as constructor parameter

Michal Bukovský
Fri Jan 16 19:24:00 GMT 2009


     I try use std::__enable_if as class constructor but gcc don't see
     this constructor while I try use it. Then I write small bit of code,
     which I think, is same and gcc don't compile this too.

     template <typename>
     struct is_allowed {};

     template <>
     struct is_allowed<int> { typedef int type; };

     class SomeObject {
         template <typename Type>
         SomeObject(const typename is_allowed<Type>::type &) {}

     int main(int /*argc*/, char *[] /*argv*/) {
         SomeObject o(1);

     Gcc says: In function ‘int main(int, char**)’: error: no matching function for call to ‘SomeObject::SomeObject(int)’ note: candidates are: SomeObject::SomeObject(const SomeObject&)

     I can't understand why gcc don't instantiate constructor template

     Can anybody explain me this?


Michal Bukovský
Senior Programátor, a.s.
Radlická 608/2
150 00 Praha 5

tel.: +420 234 694 321
fax:  +420 234 694 115

More information about the Gcc-help mailing list