YSTest: type_traits.hpp 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

type_traits.hpp
浏览该文件的文档.
1 /*
2 © 2011-2019 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YB_INC_ystdex_type_traits_hpp_
29 #define YB_INC_ystdex_type_traits_hpp_ 1
30
31 #include "invoke.hpp" // for "type_inspection.hpp", "integral_constant.hpp",
32 // "invoke.hpp", <type_traits>, nonesuch, any_constructible, std::declval,
33 // and_;
34 #include "swap.hpp" // for "swap.hpp";
35
36 namespace ystdex
37 {
38
40
41
49 template<typename _type>
50 using id_t = _type;
51
52 template<typename _type>
53 using add_ptr_t = _type*;
54
55 template<typename _type>
56 using add_ref_t = _type&;
57
58 template<typename _type>
59 using add_rref_t = _type&&;
61
62
64
65 template<typename _type>
66 using addrof_t = decltype(&std::declval<_type>());
67
68 template<typename _type>
69 using indirect_t = decltype(*std::declval<_type>());
71
73 template<typename _type>
74 using indirect_element_t = remove_reference_t<indirect_t<_type>>;
75
77 template<typename _type>
78 using increment_t = decltype(++std::declval<_type>());
79
81
82 template<typename _type>
83 using increment_post_t = decltype(std::declval<_type>()--);
84
85 template<typename _type>
86 using decrement_t = decltype(++std::declval<_type>());
87
88 template<typename _type>
89 using decrement_post_t = decltype(std::declval<_type>()--);
90
91 template<typename _type, typename _type2>
92 using subscript_t = decltype(std::declval<_type>()[std::declval<_type2>()]);
93
94 template<typename _type, typename _type2 = _type>
95 using equal_t = decltype(std::declval<_type>() == std::declval<_type2>());
96
97 template<typename _type, typename _type2 = _type>
98 using not_equal_t = decltype(std::declval<_type>() != std::declval<_type2>());
100
101
103
104 template<typename _type>
105 using first_t = decltype(std::declval<_type>().first);
106
107 template<typename _type>
108 using second_t = decltype(std::declval<_type>().second);
110
111
112
113
115
116
120 template<typename _type1, typename _type2>
121 struct has_subscription
122 : bool_<is_detected<subscript_t, _type1, _type2>::value
123 && !is_void<detected_t<subscript_t, _type1, _type2>>::value>
124 {};
125
126
131 template<typename _type, typename _type2 = _type>
132 struct has_equality_operator
133 : is_detected_convertible<bool, equal_t, _type, _type2>
134 {};
136
137 } // namespace ystdex;
138
139 #endif
140
invoke.hpp
可调用对象和调用包装接口。
ystdex::equal_t
decltype(std::declval< _type >()==std::declval< _type2 >()) equal_t
Definition: type_traits.hpp:95
ystdex::increment_post_t
decltype(std::declval< _type >() --) increment_post_t
Definition: type_traits.hpp:83
ystdex::addrof_t
decltype(&std::declval< _type >()) addrof_t
Definition: type_traits.hpp:66
ystdex::add_rref_t
_type && add_rref_t
Definition: type_traits.hpp:59
ystdex::decrement_post_t
decltype(std::declval< _type >() --) decrement_post_t
Definition: type_traits.hpp:89
ystdex::subscript_t
decltype(std::declval< _type >()[std::declval< _type2 >()]) subscript_t
Definition: type_traits.hpp:92
swap.hpp
交换操作。
ystdex::first_t
decltype(std::declval< _type >().first) first_t
Definition: type_traits.hpp:105
ystdex::indirect_t
decltype(*std::declval< _type >()) indirect_t
Definition: type_traits.hpp:69
ystdex::bool_
integral_constant< bool, _vInt > bool_
Definition: integral_constant.hpp:93
ystdex::has_equality_operator
判断是否存在合式的结果可转换为 bool 类型的 == 操作符接受指定类型的表达式。
Definition: type_traits.hpp:134
ystdex::increment_t
decltype(++std::declval< _type >()) increment_t
Definition: type_traits.hpp:78
ystdex::indirect_element_t
remove_reference_t< indirect_t< _type > > indirect_element_t
Definition: type_traits.hpp:74
ystdex::is_detected_convertible
is_convertible< detected_t< _gOp, _tParams... >, _tTo > is_detected_convertible
Definition: meta.hpp:415
ystdex::id_t
_type id_t
Definition: type_traits.hpp:50
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
ystdex::not_equal_t
decltype(std::declval< _type >() !=std::declval< _type2 >()) not_equal_t
Definition: type_traits.hpp:98
ystdex::cpp2014::remove_reference_t
typename remove_reference< _type >::type remove_reference_t
Definition: meta.hpp:155
ystdex::second_t
decltype(std::declval< _type >().second) second_t
Definition: type_traits.hpp:108
ystdex::add_ref_t
_type & add_ref_t
Definition: type_traits.hpp:56
ystdex::add_ptr_t
_type * add_ptr_t
Definition: type_traits.hpp:53
ystdex::has_subscription
判断是否存在合式的结果为非 void 类型的 [] 操作符接受指定类型的表达式。
Definition: type_traits.hpp:124
ystdex::decrement_t
decltype(++std::declval< _type >()) decrement_t
Definition: type_traits.hpp:86