NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
concepts.hpp
浏览该文件的文档.
1#ifndef NEFORCE_CORE_TYPEINFO_CONCEPTS_HPP__
2#define NEFORCE_CORE_TYPEINFO_CONCEPTS_HPP__
3
10
12NEFORCE_BEGIN_NAMESPACE__
13
14#ifdef NEFORCE_STANDARD_20
15
21
30template <typename T1, typename T2>
32
44template <typename T1, typename T2>
51
64template <typename T1, typename T2>
76
85template <typename Derived, typename Base>
87
88
95template <typename T, typename... Args>
97
103template <typename T>
105
115template <typename T>
119
127template <typename T>
129 T{};
130 ::new (static_cast<void*>(nullptr)) T;
131};
132
141template <typename To, typename From>
144 requires(To x, From&& y) {
145 { x = static_cast<From&&>(y) } -> same_as<To>;
146 };
147
148
160template <typename T>
162
170template <typename T>
173
174
183template <typename T1, typename T2>
185 { x == y } -> convertible_to<bool>;
186 { x != y } -> convertible_to<bool>;
187};
188
195template <typename T1, typename T2>
197
203template <typename T>
205
212template <typename T1, typename T2>
218
219
226template <typename T1, typename T2>
227concept one_way_ordered = requires(const remove_reference_t<T1>& x, const remove_reference_t<T2>& y) {
228 { x < y } -> convertible_to<bool>;
229 { x > y } -> convertible_to<bool>;
230 { x <= y } -> convertible_to<bool>;
231 { x >= y } -> convertible_to<bool>;
232};
233
240template <typename T1, typename T2>
242
250template <typename T>
252
259template <typename T1, typename T2>
264
265
273template <typename T>
275
283template <typename T>
285
286
292template <typename T>
300
311template <typename Iterator>
318
329template <typename Iterator>
334
342template <typename Iterator>
343concept bidirectional_iterator = forward_iterator<Iterator> && requires(Iterator it) {
344 { --it } -> same_as<Iterator&>;
345 { it-- } -> same_as<Iterator>;
346};
347
355template <typename Iterator>
358 requires(Iterator it1, Iterator it2, typename iterator_traits<Iterator>::difference_type n) {
359 { it1 + n } -> convertible_to<Iterator>;
360 { n + it1 } -> convertible_to<Iterator>;
361 { it1 - n } -> convertible_to<Iterator>;
362 { it1 += n } -> convertible_to<Iterator>;
363 { it1 -= n } -> convertible_to<Iterator>;
366 };
367
375template <typename Iterator>
381
382
391template <typename Sentinel, typename Iterator>
393 input_iterator<Iterator> && semiregular<Sentinel> && requires(const Iterator& i, const Sentinel& s) {
394 { i == s } -> convertible_to<bool>;
395 { i != s } -> convertible_to<bool>;
396 };
397
406template <typename Sentinel, typename Iterator>
408 input_iterator<Iterator> && sentinel_for<Sentinel, Iterator> && requires(const Iterator& i, const Sentinel& s) {
410 } && requires(const Iterator& i, const Sentinel& s) {
411 { i + (s - i) } -> same_as<Iterator>;
412 };
413 // Concepts
415
421
426NEFORCE_BEGIN_RANGES__
427
436template <typename Derived>
437struct view_base {
438private:
439 constexpr const Derived& derived() const noexcept { return static_cast<const Derived&>(*this); }
440
441 constexpr Derived& derived() noexcept { return static_cast<Derived&>(*this); }
442
443public:
448 constexpr decltype(auto) begin() const { return derived().begin(); }
453 constexpr decltype(auto) end() const { return derived().end(); }
458 constexpr decltype(auto) begin() { return derived().begin(); }
463 constexpr decltype(auto) end() { return derived().end(); }
464};
465
466NEFORCE_END_RANGES__
467
473template <typename T>
474struct is_view : false_type {};
475
480template <typename D>
482
487template <typename T>
488NEFORCE_INLINE17 constexpr bool is_view_v = is_base_of_v<ranges::view_base<T>, T>;
489 // View
491
492#endif // NEFORCE_STANDARD_20
493
499
501NEFORCE_BEGIN_INNER__
502template <typename, typename = void>
503NEFORCE_INLINE17 constexpr bool __is_iterator_with_cate_v = false;
504template <typename Iterator>
505NEFORCE_INLINE17 constexpr bool __is_iterator_with_cate_v<Iterator, void_t<iter_category_t<Iterator>>> = true;
506NEFORCE_END_INNER__
508
516template <typename Iterator>
517NEFORCE_INLINE17 constexpr bool is_ranges_iter_v = inner::__is_iterator_with_cate_v<Iterator>;
518
524template <typename Iterator>
525NEFORCE_INLINE17 constexpr bool is_iter_v =
526#ifdef NEFORCE_STANDARD_20
528#endif
530
531
539template <typename Iterator>
540NEFORCE_INLINE17 constexpr bool is_ranges_input_iter_v =
542
548template <typename Iterator>
549NEFORCE_INLINE17 constexpr bool is_input_iter_v =
550#ifdef NEFORCE_STANDARD_20
552#endif
554
555
560template <typename Iterator>
561NEFORCE_INLINE17 constexpr bool is_ranges_fwd_iter_v =
563
568template <typename Iterator>
569NEFORCE_INLINE17 constexpr bool is_fwd_iter_v =
570#ifdef NEFORCE_STANDARD_20
572#endif
574
575
580template <typename Iterator>
581NEFORCE_INLINE17 constexpr bool is_ranges_bid_iter_v =
583
588template <typename Iterator>
589NEFORCE_INLINE17 constexpr bool is_bid_iter_v =
590#ifdef NEFORCE_STANDARD_20
592#endif
594
595
600template <typename Iterator>
601NEFORCE_INLINE17 constexpr bool is_ranges_rnd_iter_v =
603
608template <typename Iterator>
609NEFORCE_INLINE17 constexpr bool is_rnd_iter_v =
610#ifdef NEFORCE_STANDARD_20
612#endif
614
615
620template <typename Iterator>
621NEFORCE_INLINE17 constexpr bool is_ranges_cot_iter_v =
623
628template <typename Iterator>
629NEFORCE_INLINE17 constexpr bool is_cot_iter_v =
630#ifdef NEFORCE_STANDARD_20
632#endif // NEFORCE_STANDARD_20
635 // IteratorChecks
637
638NEFORCE_END_NAMESPACE__
639#endif // NEFORCE_CORE_TYPEINFO_CONCEPTS_HPP__
检查类型是否可以从另一个类型赋值
检查类型是否为双向迭代器
检查两个类型是否可以双向相等比较
检查两个类型是否可以双向顺序比较
检查两个类型是否有公共引用类型
检查两个类型是否有公共类型
检查类型是否可以使用指定参数构造
检查类型是否为连续迭代器
检查类型From是否可以转换为类型To
检查类型是否可复制构造
检查类型是否可复制
检查类型是否可默认初始化
检查类型是否派生自另一个类型
检查两个类型是否可以互相进行相等比较
检查类型是否可与自身进行相等比较
检查类型是否为前向迭代器
检查类型是否为输入迭代器
检查类型是否具有迭代器所需的所有类型定义
检查类型是否可移动
检查类型是否可移动构造
检查两个类型是否可以单向相等比较
检查两个类型是否可以单向顺序比较
检查类型是否为随机访问迭代器
检查类型是否为常规类型
检查两个类型是否完全相同
检查类型是否为半常规类型
检查类型是否为迭代器的哨兵
检查哨兵是否支持大小计算
检查两个类型是否可以互相完全有序比较
检查类型是否完全有序
typename add_reference< T >::lvalue add_lvalue_reference_t
add_lvalue_reference的便捷别名
NEFORCE_INLINE17 constexpr bool is_base_of_v
is_base_of的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_lvalue_reference_v
is_lvalue_reference的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_pod_v
is_pod的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_object_v
is_object的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_convertible_v
is_convertible的便捷变量模板
add_rvalue_reference_t< T > declval() noexcept
获取类型的右值引用,仅用于非求值上下文
NEFORCE_INLINE17 constexpr bool is_ranges_input_iter_v
检查是否为范围输入迭代器
NEFORCE_INLINE17 constexpr bool is_ranges_iter_v
检查类型是否为范围迭代器
NEFORCE_INLINE17 constexpr bool is_bid_iter_v
检查是否为双向迭代器
NEFORCE_INLINE17 constexpr bool is_ranges_fwd_iter_v
检查是否为范围前向迭代器
NEFORCE_INLINE17 constexpr bool is_ranges_bid_iter_v
检查是否为范围双向迭代器
NEFORCE_INLINE17 constexpr bool is_rnd_iter_v
检查是否为随机访问迭代器
NEFORCE_INLINE17 constexpr bool is_iter_v
检查类型是否为迭代器
NEFORCE_INLINE17 constexpr bool is_cot_iter_v
检查是否为连续迭代器
NEFORCE_INLINE17 constexpr bool is_input_iter_v
检查是否为输入迭代器
NEFORCE_INLINE17 constexpr bool is_fwd_iter_v
检查是否为前向迭代器
NEFORCE_INLINE17 constexpr bool is_ranges_cot_iter_v
检查是否为范围连续迭代器
NEFORCE_INLINE17 constexpr bool is_ranges_rnd_iter_v
检查是否为范围随机访问迭代器
typename iterator_traits< Iterator >::value_type iter_value_t
获取迭代器的值类型
constexpr decltype(auto) to_address(const Ptr &ptr) noexcept
安全地获取任意指针类型指向的地址
typename remove_cvref< T >::type remove_cvref_t
remove_cvref的便捷别名
typename remove_reference< T >::type remove_reference_t
remove_reference的便捷别名
typename remove_cv< T >::type remove_cv_t
remove_cv的便捷别名
NEFORCE_INLINE17 constexpr bool is_swappable_v
is_swappable的便捷变量模板
typename common_type< Types... >::type common_type_t
common_type的便捷别名
typename common_reference< Types... >::type common_reference_t
common_reference的便捷别名
NEFORCE_INLINE17 constexpr bool is_constructible_v
is_constructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_move_constructible_v
is_move_constructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_same_v
is_same的便捷变量模板
bool_constant< true > true_type
表示true的类型
bool_constant< false > false_type
表示false的类型
NEFORCE_INLINE17 constexpr bool is_view_v
is_view的便捷变量模板
迭代器萃取和指针萃取
范围操作命名空间
双向迭代器标签
连续迭代器标签
前向迭代器标签
输入迭代器标签
检查类型是否为视图
迭代器特性主模板
随机访问迭代器标签
范围视图的基类模板
constexpr decltype(auto) begin()
获取范围的起始迭代器
constexpr decltype(auto) end() const
获取范围的结束const迭代器
constexpr decltype(auto) begin() const
获取范围的起始const迭代器
constexpr decltype(auto) end()
获取范围的结束迭代器