concepts.cxx 378 B

123456789101112131415161718192021
  1. // Test for concepts support. Not just the language feature; also headers.
  2. #include <iostream>
  3. #include <ranges>
  4. #include <vector>
  5. template<typename T>
  6. concept Foo = std::ranges::input_range<T>;
  7. template<Foo F> auto foo(F const &r)
  8. {
  9. return std::distance(std::begin(r), std::end(r));
  10. }
  11. int main()
  12. {
  13. std::vector<int> const v{1, 2, 3};
  14. std::cout << foo(v) << '\n';
  15. }