forked from alandefreitas/matplotplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconcepts.h
More file actions
134 lines (104 loc) 路 4.98 KB
/
Copy pathconcepts.h
File metadata and controls
134 lines (104 loc) 路 4.98 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
// Created by Alan Freitas on 2020-07-03.
//
#ifndef MATPLOTPLUSPLUS_CONCEPTS_H
#define MATPLOTPLUSPLUS_CONCEPTS_H
#include <matplot/util/handle_types.h>
#include <matplot/util/type_traits.h>
#include <string>
namespace matplot {
// https://github.com/Neargye/yacppl/blob/master/include/concepts.hpp
// Fallback to type T if Enable is not void
template <typename T, typename Enable = void> using type_concept = T;
// type_concept where Enable is void if C is false
template <typename T, bool C>
using TypeConcept = type_concept<T, typename std::enable_if_t<C>>;
// TypeConcept where C is true only if T is RValue
template <typename T>
using RValue = TypeConcept<
T, std::is_rvalue_reference<T>::value &&
!std::is_const<typename std::remove_reference<T>::type>::value>
&&;
// TypeConcept where C is true only if T is Const
template <typename T>
using Const = TypeConcept<
T, std::is_const<typename std::remove_reference<T>::type>::value>;
// TypeConcept where C is true only if T is NotConst
template <typename T>
using NotConst = TypeConcept<
T, !std::is_const<typename std::remove_reference<T>::type>::value>;
// TypeConcept where C is true only if T is Arithmetic
template <typename T>
using Arithmetic = TypeConcept<
T, std::is_arithmetic<typename std::remove_reference<T>::type>::value>;
// TypeConcept where C is true only if T is Integral
template <typename T>
using Integral = TypeConcept<
T, std::is_integral<typename std::remove_reference<T>::type>::value>;
// TypeConcept where C is true only if T is Pointer
template <typename T>
using Pointer = TypeConcept<
T, std::is_pointer<typename std::remove_reference<T>::type>::value>;
// TypeConcept where C is true only if T is Trivial
template <typename T>
using Trivial = TypeConcept<
T, std::is_trivial<typename std::remove_reference<T>::type>::value>;
// TypeConcept where C is true only if T is TriviallyCopyable
template <typename T>
using TriviallyCopyable =
TypeConcept<T, std::is_trivially_copyable<
typename std::remove_reference<T>::type>::value>;
// TypeConcept where C is true only if T is String
template <typename T>
using String = TypeConcept<T, std::is_same_v<std::decay_t<T>, std::string>>;
// TypeConcept where C is true only if T is NotString
template <typename T>
using NotString =
TypeConcept<T, !std::is_same_v<std::decay_t<T>, std::string>>;
// TypeConcept where C is true only if T is NotString
template <typename T>
using NotStringConvertible =
TypeConcept<T, !std::is_convertible_v<std::decay_t<T>, std::string>>;
class figure_type;
// TypeConcept where C is true only if T is FigureHandle
template <typename T>
using FigureHandle = TypeConcept<
T, std::is_same_v<std::decay_t<T>, std::shared_ptr<class figure_type>>>;
// TypeConcept where C is true only if T is NotFigureHandle
template <typename T>
using NotFigureHandle =
TypeConcept<T, !std::is_same_v<std::decay_t<T>,
std::shared_ptr<class figure_type>>>;
// TypeConcept where C is true only if T is Iterable
template <typename T>
using Iterable = TypeConcept<T, is_iterable_v<std::decay_t<T>>>;
// TypeConcept where C is true only if T is IterableValues
template <typename T>
using IterableValues = TypeConcept<T, is_iterable_value_v<std::decay_t<T>>>;
// TypeConcept where C is true only if T is IterablePair
template <typename T>
using IterablePairs = TypeConcept<T, is_iterable_pair_v<std::decay_t<T>>>;
// TypeConcept where C is true only if T is IterableIterables
template <typename T>
using IterableIterables =
TypeConcept<T, is_iterable_iterable_v<std::decay_t<T>>>;
// TypeConcept where C is true only if T is IterableValues
template <typename T>
using NotAxesHandle =
TypeConcept<T, !std::is_same_v<std::decay_t<T>, axes_handle>>;
// TypeConcept where C is true only if T is an initializer list
template <typename T>
using InitializerList = TypeConcept<T, is_initializer_list<T>::value>;
// TypeConcept where C is true only if T is not an initializer list
template <typename T>
using NotInitializerList = TypeConcept<T, !is_initializer_list<T>::value>;
// TypeConcept where C is true only if T is a vector
template <typename T> using Vector = TypeConcept<T, is_vector<T>::value>;
// TypeConcept where C is true only if T is not a vector
template <typename T> using NotVector = TypeConcept<T, is_vector<T>::value>;
// TypeConcept where C is true only if T is a pair
template <typename T> using Pair = TypeConcept<T, is_pair<T>::value>;
// TypeConcept where C is true only if T is not a pair
template <typename T> using NotPair = TypeConcept<T, is_pair<T>::value>;
} // namespace matplot
#endif // MATPLOTPLUSPLUS_CONCEPTS_H