Consider the following snippet
#include <type_traits>
template <typename T>
concept unsigned_integral = std::is_integral_v<T> &&std::is_unsigned_v<T>;
template <unsigned_integral T>
auto test(T) -> std::make_signed_t<T>; //(1)
template <typename T>
auto test(T) -> int; //(2)
int sandbox() {
test(1u); // Call to (1) as expected
test(1.0); // Expected to call (2), compilers choose (1) and fail to compile
}
MSVC 14.26, GCC-10, and Clang-10 all failed to compile this, so I suppose the standard makes this an invalid code, so should this be considered an oversight from the standard? because using SFINAE, the code is compiled as expected.
SFINAE version (this only works with the double case, because there will be ambiguity for the unsigned int case, but that doesn't affect the question I'm asking)
template <typename T, typename = std::enable_if_t<unsigned_integral<T>>>
auto test(T) -> std::make_signed_t<T>;
edit: apparently, this does not relate to trailing return types, so I have changed the title to the appropriate one.