YSTest: node_base.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

node_base.h
浏览该文件的文档.
1 /*
2 © 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
32 #ifndef YB_INC_ystdex_node_base_h_
33 #define YB_INC_ystdex_node_base_h_ 1
34
35 #include "../ydef.h"
36
37 namespace ystdex
38 {
39
41 namespace details
42 {
43
45
46 struct YB_API list_node_base
47 {
48 using base_ptr = list_node_base*;
49 using const_base_ptr = const list_node_base*;
50
51 // XXX: Uninitialized.
52 base_ptr next;
53 base_ptr prev;
54
56
57 void
58 reset_links() ynothrow
59 {
60 next = prev = this;
61 }
62
63 static void
64 swap(list_node_base&, list_node_base&) ynothrow;
65
67 void
68 transfer(base_ptr, base_ptr) ynothrow;
69
70 void
71 reverse_nodes() ynothrow;
72
73 void
74 hook(base_ptr) ynothrow;
75
76 void
77 unhook() ynothrow;
79 };
80
81
83 struct YB_API list_header : list_node_base
84 {
86 size_t node_count;
87
88 list_header() ynothrow
89 : node_count(0)
90 {
91 reset_links();
92 }
93 list_header(list_header&&) ynothrow;
94
95 void
96 move_nodes(list_header&&);
97
99 void
100 reset() ynothrow
101 {
102 reset_links();
103 node_count = 0;
104 }
105
107 YB_ATTR_nodiscard YB_PURE list_node_base&
108 base()
109 {
110 return *this;
111 }
112 };
114
115 } // namespace details;
116
117 } // namespace ystdex;
118
119 #endif
120
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
ystdex::details::list_node_base::reset_links
void reset_links()
Definition: node_base.h:58
ystdex::cpp2017::swap
void swap(optional< _type > &x, optional< _type > &y)
Definition: optional.h:888
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
ystdex::details::list_node_base::prev
base_ptr prev
Definition: node_base.h:53
next
tidy_ptr< slink > next
Definition: memory_resource.cpp:223
ystdex::details::list_node_base::next
base_ptr next
Definition: node_base.h:52
ystdex::details::list_header
Definition: node_base.h:84
ystdex::reset
bool reset(std::unique_ptr< _type, _tDeleter > &p)
Definition: memory.hpp:613
ystdex::details::list_header::base
list_node_base & base()
Definition: node_base.h:108
YB_API
#define YB_API
YBase 应用程序编程接口：用于向库文件约定链接。
Definition: ydef.h:985
ystdex::details::list_header::node_count
size_t node_count
Definition: node_base.h:86
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
ystdex::details::list_node_base
Definition: node_base.h:47
ystdex::details::list_header::list_header
list_header()
Definition: node_base.h:88
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:1199