aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lockfile.json4
-rw-r--r--queries/cpp/highlights.scm4
-rw-r--r--tests/query/highlights/cpp/concepts.cpp22
3 files changed, 28 insertions, 2 deletions
diff --git a/lockfile.json b/lockfile.json
index d75e52cf3..130aa972e 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -27,13 +27,13 @@
"revision": "4fd115d3bb7046cd094f21bfe5766c302dbf64cd"
},
"cpp": {
- "revision": "e8dcc9d2b404c542fd236ea5f7208f90be8a6e89"
+ "revision": "049c2a4edeb6c19bacefb4d40aa03c6fdc175575"
},
"css": {
"revision": "a03f1d2d1dfbf6f8e0fdca5f9ff030228241eb57"
},
"cuda": {
- "revision": "bc20ed7a36031437a69a88ef368af4b9f1ecec70"
+ "revision": "61de33bc41231a2e7c1970542c505a42d62c98eb"
},
"d": {
"revision": "c2fbf21bd3aa45495fe13247e040ad5815250032"
diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm
index c860b632a..cb5a98f85 100644
--- a/queries/cpp/highlights.scm
+++ b/queries/cpp/highlights.scm
@@ -30,6 +30,8 @@
(function_declarator
declarator: (field_identifier) @method)
+(concept_definition
+ name: (identifier) @type)
(namespace_identifier) @namespace
((namespace_identifier) @type
@@ -123,6 +125,8 @@
"using"
"virtual"
"co_await"
+ "concept"
+ "requires"
(auto)
] @keyword
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; }