Talk:cpp/keyword/requires
From cppreference.com
There's no mention of non-template scenarios. I don't feel qualified to try and describe that, but the following also works
template<typename T>
struct Foo {
T m() requires (!is_void_v<T>{}) { ... }
void m() requires (is_void_v<T>{}) { ... }
};
This also works.. it's in a template class, but the method, m, itself is not considered a template, is it?
- on this page, this case falls under "in a template declaration" (it's not done until the last };. On the page that line links to, cpp/language/constraints. the first sentence mentions this case "and non-template functions (typically members of class templates)" --Cubbi (talk) 06:50, 5 January 2022 (PST)