mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 03:26:52 -04:00
highlights(cpp): add support for concepts
Requires https://github.com/tree-sitter/tree-sitter-cpp/pull/138
This commit is contained in:
parent
4cf688ee68
commit
db01c82b08
3 changed files with 28 additions and 2 deletions
22
tests/query/highlights/cpp/concepts.cpp
Normal file
22
tests/query/highlights/cpp/concepts.cpp
Normal file
|
|
@ -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; }
|
||||
Loading…
Add table
Add a link
Reference in a new issue