aboutsummaryrefslogtreecommitdiffstats
path: root/tests/query
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2021-11-28 18:05:18 +0100
committerStephan Seitz <stephan.seitz@fau.de>2022-01-16 22:19:34 +0100
commitdb01c82b08bf20e5260810dccdec7ff4936934eb (patch)
treed0011d4c9fb4c380898cb7f2d28dc66068c1e043 /tests/query
parentci: fix markdown tests (diff)
downloadnvim-treesitter-db01c82b08bf20e5260810dccdec7ff4936934eb.tar
nvim-treesitter-db01c82b08bf20e5260810dccdec7ff4936934eb.tar.gz
nvim-treesitter-db01c82b08bf20e5260810dccdec7ff4936934eb.tar.bz2
nvim-treesitter-db01c82b08bf20e5260810dccdec7ff4936934eb.tar.lz
nvim-treesitter-db01c82b08bf20e5260810dccdec7ff4936934eb.tar.xz
nvim-treesitter-db01c82b08bf20e5260810dccdec7ff4936934eb.tar.zst
nvim-treesitter-db01c82b08bf20e5260810dccdec7ff4936934eb.zip
highlights(cpp): add support for concepts
Requires https://github.com/tree-sitter/tree-sitter-cpp/pull/138
Diffstat (limited to 'tests/query')
-rw-r--r--tests/query/highlights/cpp/concepts.cpp22
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; }