Skip to content

Commit 972a358

Browse files
Opt, Optional添加SAL标签
1 parent f8c2cdb commit 972a358

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

include/YY/Base/Containers/Optional.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,41 +63,41 @@ namespace YY
6363
Reset();
6464
}
6565

66-
inline bool HasValue() const
66+
inline bool __YYAPI HasValue() const noexcept
6767
{
6868
return bHasValue;
6969
}
7070

71-
_Type* GetValuePtr()
71+
_Ret_maybenull_ _Type* __YYAPI GetValuePtr() noexcept
7272
{
7373
return bHasValue ? &oValue : nullptr;
7474
}
7575

76-
inline const _Type* GetValuePtr() const
76+
_Ret_maybenull_ inline const _Type* __YYAPI GetValuePtr() const noexcept
7777
{
7878
return const_cast<Optional*>(this)->GetValuePtr();
7979
}
8080

81-
inline _Type& GetValue()
81+
inline _Type& __YYAPI GetValue()
8282
{
8383
return *GetValuePtr();
8484
}
8585

86-
inline const _Type& GetValue() const
86+
inline const _Type& __YYAPI GetValue() const
8787
{
8888
return *GetValuePtr();
8989
}
9090

9191
template<typename... Args>
92-
_Type& Emplace(Args&&... oArgs)
92+
_Type& __YYAPI Emplace(Args&&... oArgs)
9393
{
9494
Reset();
9595
new (&oValue) _Type(std::forward<Args>(oArgs)...);
9696
bHasValue = true;
9797
return oValue;
9898
}
9999

100-
void Reset()
100+
void __YYAPI Reset()
101101
{
102102
if (bHasValue)
103103
{
@@ -106,7 +106,7 @@ namespace YY
106106
}
107107
}
108108

109-
Optional& operator=(const _Type& _oValue)
109+
Optional& __YYAPI operator=(const _Type& _oValue)
110110
{
111111
if (bHasValue)
112112
{
@@ -124,7 +124,7 @@ namespace YY
124124
return *this;
125125
}
126126

127-
Optional& operator=(_Type&& _oValue)
127+
Optional& __YYAPI operator=(_Type&& _oValue)
128128
{
129129
if (bHasValue)
130130
{
@@ -142,7 +142,7 @@ namespace YY
142142
return *this;
143143
}
144144

145-
Optional& operator=(const Optional& _oOther)
145+
Optional& __YYAPI operator=(const Optional& _oOther)
146146
{
147147
if (_oOther.HasValue())
148148
{
@@ -156,7 +156,7 @@ namespace YY
156156
return *this;
157157
}
158158

159-
Optional& operator=(Optional&& _oOther)
159+
Optional& __YYAPI operator=(Optional&& _oOther)
160160
{
161161
if(this == &_oOther)
162162
return *this;
@@ -174,7 +174,7 @@ namespace YY
174174
return *this;
175175
}
176176

177-
bool operator==(const Optional& _oOther) const
177+
bool __YYAPI operator==(const Optional& _oOther) const noexcept
178178
{
179179
if (HasValue() != _oOther.HasValue())
180180
return false;
@@ -188,7 +188,7 @@ namespace YY
188188
}
189189

190190
#if !defined(_HAS_CXX20) || _HAS_CXX20 == 0
191-
bool operator!=(const Optional& _oOther) const
191+
bool __YYAPI operator!=(const Optional& _oOther) const noexcept
192192
{
193193
if (HasValue() != _oOther.HasValue())
194194
return true;

0 commit comments

Comments
 (0)