boost::enable_if class template method

Posted by aaa on Stack Overflow See other posts from Stack Overflow or by aaa
Published on 2010-05-30T03:34:50Z Indexed on 2010/05/30 3:42 UTC
Read the original article Hit count: 209

Filed under:
|
|
|

I got class with template methods that looks at this:

struct undefined {};

template<typename T> struct is_undefined : mpl::false_ {};

template<> struct is_undefined<undefined> : mpl::true_ {};

template<class C>
struct foo {
        template<class F, class V>
        typename boost::disable_if<is_undefined<C> >::type
            apply(const F &f, const V &variables) {
        }

        template<class F, class V>
        typename boost::enable_if<is_undefined<C> >::type
            apply(const F &f, const V &variables) {
        }
};

apparently, both templates are instantiated, resulting in compile time error. is instantiation of template methods different from instantiation of free functions? I have fixed this differently, but I would like to know what is up.

Thank you

© Stack Overflow or respective owner

Related posts about c++

Related posts about templates