blob: 1da56cefe50361ee7ef7fe542ec9f9b87d87fa86 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include <zenbase/zenbase.h>
#include <type_traits>
// At the time of writing only ver >= 13 of LLVM's libc++ has an implementation
// of std::integral. Some platforms like Ubuntu and Mac OS are still on 12.
#if defined(__cpp_lib_concepts)
# include <concepts>
template<class T>
concept Integral = std::integral<T>;
template<class T>
concept SignedIntegral = std::signed_integral<T>;
template<class T>
concept UnsignedIntegral = std::unsigned_integral<T>;
template<class F, class... A>
concept Invocable = std::invocable<F, A...>;
template<class D, class B>
concept DerivedFrom = std::derived_from<D, B>;
#else
# include <functional> // for std::invoke below
template<class T>
concept Integral = std::is_integral_v<T>;
template<class T>
concept SignedIntegral = Integral<T> && std::is_signed_v<T>;
template<class T>
concept UnsignedIntegral = Integral<T> && !std::is_signed_v<T>;
template<class F, class... A>
concept Invocable = requires(F&& f, A&&... a)
{
std::invoke(std::forward<F>(f), std::forward<A>(a)...);
};
template<class D, class B>
concept DerivedFrom = std::is_base_of_v<B, D> && std::is_convertible_v<const volatile D*, const volatile B*>;
#endif
#if defined(__cpp_lib_ranges)
# include <ranges>
template<typename T>
concept ContiguousRange = std::ranges::contiguous_range<T>;
#else
template<typename T>
concept ContiguousRange = true;
#endif
|