diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/query/highlights/cpp/concepts.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/query/highlights/cpp/concepts.cpp b/tests/query/highlights/cpp/concepts.cpp new file mode 100644 index 000000000..07e2313ea --- /dev/null +++ b/tests/query/highlights/cpp/concepts.cpp @@ -0,0 +1,22 @@ + +template <class T, class U> +concept Derived = std::is_base_of<U, T>::value; +// ^ keyword +// ^ type + +template<typename T> +concept Hashable = requires(T a) { +// ^ keyword +// ^ parameter +// ^ type + { std::hash<T>{}(a) } -> std::convertible_to<std::size_t>; + typename CommonType<T, U>; // CommonType<T, U> is valid and names a type + { CommonType<T, U>{std::forward<T>(t)} }; + { CommonType<T, U>{std::forward<U>(u)} }; +}; + + +template<typename T> + requires requires (T x) { x + x; } // ad-hoc constraint, note keyword used twice +// ^ keyword +T add(T a, T b) { return a + b; } |
