Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug?

5 views
Skip to first unread message

Paul Mensonides

unread,
Oct 8, 2012, 12:17:11 PM10/8/12
to help-gp...@gnu.org
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


0 new messages