diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2021-11-28 18:05:18 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2022-01-16 22:19:34 +0100 |
| commit | db01c82b08bf20e5260810dccdec7ff4936934eb (patch) | |
| tree | d0011d4c9fb4c380898cb7f2d28dc66068c1e043 /tests/query/highlights | |
| parent | 4cf688ee681bbe9a35651732b2d2281a01c40066 (diff) | |
highlights(cpp): add support for concepts
Requires https://github.com/tree-sitter/tree-sitter-cpp/pull/138
Diffstat (limited to 'tests/query/highlights')
| -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 00000000..07e2313e --- /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; } |
