I think i found a bug in MSVC, but i wanted to confirm. I have the following simple reproducer:
template <typename T, typename R>
concept convertible_range =
std::ranges::sized_range<R> && std::convertible_to<std::ranges::range_value_t<R>, T>;
template <typename T>
struct S {
using value_type = T;
template <convertible_range<value_type> R>
void foo(R&&);
};
template <typename T>
template <convertible_range<T> R>
void S<T>::foo(R&&) {}
This compiles with gcc-14.1 but fails in all versions of MSVC++ with:
error C2244: ‘S::foo’: unable to match function definition to an existing declaration
The issue appears to be a combination of defining foo
outside the class using the type alias in the declaration of foo
in S
. If i either:
- define the function in place:
struct S {
using value_type = T;
template <convertible_range<value_type> R>
void foo(R&&) {}
};
- Change the declaration to use
T
directly:
template <typename T>
struct S {
template <convertible_range<T> R> // Difference is here!
void foo(R&&);
};
template <typename T>
template <convertible_range<T> R>
void S<T>::foo(R&&) {}
Then this compiles.
Is this an MSVC bug?
You need to sign in to view this answers
Leave feedback about this