Playing around, I noticed that the following code compiles on MSVC 19.27
template <typename T>
concept defined = true;
template <!defined T> // <=== !!!!!!!!
inline auto constexpr Get()
{
return 5;
}
What's going on? Is it such a bad idea to allow this syntax?
You're right; MSVC 19.27 and 19.28 (before VS16.9) support syntax with ! for negation of concept (cf in compiler explorer).
Even if this syntax is not allowed in C++20, you can do something very close
template<typename T>
concept defined = your_rule_on<T>;
template <typename T>
requires defined<T>
inline auto constexpr Get() { /* ... */ }
template <typename T>
requires(!defined<T>) // <=== !
inline auto constexpr Get() { /* ... */ }
demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With