1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 17:50:05 +08:00
SpaceVim/bundle/nvim-treesitter/tests/query/highlights/cpp/concepts.cpp

23 lines
688 B
C++
Raw Normal View History

template <class T, class U>
concept Derived = std::is_base_of<U, T>::value;
// ^ keyword
// ^ type.definition
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; }