using std::__enable_if template as constructor parameter

Michal Bukovský michal.bukovsky@firma.seznam.cz
Fri Jan 16 19:24:00 GMT 2009


Hello,

     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 {
     public:
         template <typename Type>
         SomeObject(const typename is_allowed<Type>::type &) {}
     };

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

     Gcc says:

     a.cc: In function ‘int main(int, char**)’:
     a.cc:112: error: no matching function for call to ‘SomeObject::SomeObject(int)’
     a.cc:105: note: candidates are: SomeObject::SomeObject(const SomeObject&)

     I can't understand why gcc don't instantiate constructor template
     SomeObject::SomeObject<>?

     Can anybody explain me this?

--
______________________________________________________________

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

tel.: +420 234 694 321
fax:  +420 234 694 115
michal.bukovsky@firma.seznam.cz
http://www.seznam.cz


More information about the Gcc-help mailing list