concepts_test_code.cpp 406 B

1234567891011121314151617181920212223242526272829
  1. #if !defined(__cpp_concepts) || __cpp_concepts == 0
  2. #error "Sorry, Charlie. No concepts"
  3. #else
  4. #if __cpp_concepts <= 201507L
  5. #define concept concept bool
  6. #endif
  7. template<class>
  8. concept True = true;
  9. template<class T>
  10. constexpr bool test(T)
  11. {
  12. return false;
  13. }
  14. template<class T>
  15. requires True<T>
  16. constexpr bool test(T)
  17. {
  18. return true;
  19. }
  20. int main()
  21. {
  22. static_assert(::test(42), "");
  23. }
  24. #endif