-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtemplateutils.h
More file actions
87 lines (69 loc) · 2.35 KB
/
Copy pathtemplateutils.h
File metadata and controls
87 lines (69 loc) · 2.35 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include <vector>
#if __cplusplus > 201703L
#include <span>
#endif
#include <string>
#include <string_view>
#include <array>
#define HAVE_db59c0d370a4d148_TEMPLATEUTILS
/** test if T is a container type */
template<typename T>
struct is_container : std::false_type {};
template<typename T>
struct is_container<std::vector<T> > : std::true_type {};
template<typename T>
struct is_container<const std::vector<T> > : std::true_type {};
#if __cplusplus > 201703L
template<typename T>
struct is_container<std::span<T> > : std::true_type {};
template<typename T>
struct is_container<const std::span<T> > : std::true_type {};
#endif
template<typename T>
struct is_container<std::basic_string<T> > : std::true_type {};
template<typename T>
struct is_container<const std::basic_string<T> > : std::true_type {};
template<typename T>
struct is_container<std::basic_string_view<T> > : std::true_type {};
template<typename T>
struct is_container<const std::basic_string_view<T> > : std::true_type {};
// note: gcc will not match this template when N is specified as 'int'
template<typename T, size_t N>
struct is_container<std::array<T,N> > : std::true_type {};
template<typename T, size_t N>
struct is_container<const std::array<T,N> > : std::true_type {};
template<typename T>
constexpr bool is_container_v = is_container<T>::value;
template<typename T>
struct is_callable_impl {
private:
typedef char(&yes)[1];
typedef char(&no)[2];
struct Fallback { void operator()(); };
struct Derived : T, Fallback { };
template<typename U, U> struct Check;
template<typename>
static yes test(...);
template<typename C>
static no test(Check<void (Fallback::*)(), &C::operator()>*);
public:
static const bool value = sizeof(test<Derived>(0)) == sizeof(yes);
};
template<typename T>
struct is_callable
: std::conditional<
std::is_class<T>::value,
is_callable_impl<T>,
std::false_type
>::type
{ };
template<typename T> constexpr bool is_callable_v = is_callable<T>::value;
template<class T, class R = void>
struct enable_if_type { typedef R type; };
template<class T, class Enable = void>
struct is_searchable : std::false_type {};
template<class T>
struct is_searchable<T, typename enable_if_type<typename T::key_type>::type> : std::true_type
{};
template<typename T> constexpr bool is_searchable_v = is_searchable<T>::value;