Код: Выделить всё
#include
#include
template
constexpr unsigned int
foo(T x)
{
return x;
}
template requires (sizeof(T) == 1)
constexpr unsigned int
foo(T x)
{
return x + 1;
}
int
main()
{
assert(foo(static_cast(0)) == 1);
unsigned int (*function)(unsigned char x) = foo;
assert(function(0) == 1);
}
Код: Выделить всё
clang -v
Код: Выделить всё
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: arm64-apple-darwin24.2.0
Код: Выделить всё
Assertion failed: (function(0) == 1), function main, file file.cc, line 24.
Abort trap: 6
Подробнее здесь: https://stackoverflow.com/questions/793 ... -is-chosen