help-gplusplus
[Top][All Lists]
Advanced

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

Bug?


From: Paul Mensonides
Subject: Bug?
Date: Mon, 8 Oct 2012 16:17:11 +0000 (UTC)
User-agent: Pan/0.133 (House of Butterflies)

Is the following a known bug or possibly not a bug in some weird way?

struct outer {
    template<class T> struct inner { };
};

template<class T, class... U>
void f(typename T::template inner<U...>*) { }

int main() {
    f<outer, int>(nullptr);
    return 0;
}

The compiler yields:

error: no matching function for call to 'f(std::nullptr_t)'
note: candidate is:
note: template<class T, class ... U> void f(typename T::inner<U ...>*)
note:   template argument deduction/substitution failed:
note:   mismatched types 'outer::inner<U ...>*' and 'std::nullptr_t'

Given the explicit arguments, deduction should not be occurring and 
substitution should be successful.

--

What I'm actually trying to do is determine whether a metafunction class 
can be applied with a particular arity.  E.g.

template<class T, class... U> class is_callable {
    private:
        template<class V, class... W>
        static char check(typename V::template apply<W...>*);
        template<class...>
        static char (& check(...))[2];
    public:
        static constexpr bool value = sizeof(check<T, U...>(0)) == 1;
};

Then, given some type:

struct f {
    template<class T, class U> struct apply {
        // ...
    };
};

int main() {
    std::cout << is_callable<f, int, int>::value << '\n';
}

However, this outputs 0 because of the above bug.

Regards,
Paul Mensonides




reply via email to

[Prev in Thread] Current Thread [Next in Thread]