using std::__enable_if template as constructor parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
http://www.seznam.cz

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux