@@ -55,22 +55,22 @@ class Valueable
5555 using value_type = T;
5656 using base_type = std::remove_pointer_t <T>;
5757
58- Valueable () = default ;
59- explicit Valueable (T value) noexcept (noexcept (T { std::move (value) })) : Value(std::move(value)) { }
60- Valueable (Valueable const & other) = default ;
61- Valueable (Valueable&& other) = default ;
58+ constexpr Valueable () = default;
59+ constexpr explicit Valueable (T value) noexcept (noexcept (T { std::move (value) })) : Value(std::move(value)) { }
60+ constexpr Valueable (Valueable const & other) = default;
61+ constexpr Valueable (Valueable&& other) = default;
6262
63- Valueable& operator = (Valueable const & value) = default ;
64- Valueable& operator = (Valueable&& value) = default ;
63+ constexpr Valueable& operator = (Valueable const & value) = default ;
64+ constexpr Valueable& operator = (Valueable&& value) = default ;
6565
6666 template <typename Val> requires std::assignable_from<T&, Val&&>
67- Valueable& operator = (Val value)
67+ constexpr Valueable& operator = (Val value)
6868 {
6969 this ->Value = std::move (value);
7070 return *this ;
7171 }
7272
73- operator const T& () const noexcept
73+ constexpr operator const T& () const noexcept
7474 {
7575 return this ->Get ();
7676 }
@@ -81,32 +81,32 @@ class Valueable
8181 // return this->GetEx();
8282 // }
8383
84- T operator -> () const
84+ constexpr T operator -> () const
8585 {
8686 return this ->Get ();
8787 }
8888
89- T* operator & () noexcept
89+ constexpr T* operator & () noexcept
9090 {
9191 return this ->GetEx ();
9292 }
9393
94- bool operator ! () const
94+ constexpr bool operator ! () const
9595 {
9696 return this ->Get () == 0 ;
9797 }
9898
99- const T& Get () const noexcept
99+ constexpr const T& Get () const noexcept
100100 {
101101 return this ->Value ;
102102 }
103103
104- T* GetEx () noexcept
104+ constexpr T* GetEx () noexcept
105105 {
106106 return &this ->Value ;
107107 }
108108
109- const T* GetEx () const noexcept
109+ constexpr const T* GetEx () const noexcept
110110 {
111111 return &this ->Value ;
112112 }
@@ -119,26 +119,26 @@ class Valueable
119119 inline bool Save (PhobosStreamWriter& Stm) const ;
120120};
121121
122- template <typename T, typename = std::enable_if_t <std::is_enum<T>::value> >
123- inline bool operator == (const Valueable<T>& val, const T& other)
122+ template <typename T> requires std::is_enum_v<T >
123+ constexpr bool operator == (const Valueable<T>& val, const T& other)
124124{
125125 return val.Get () == other;
126126}
127127
128- template <typename T, typename = std::enable_if_t <std::is_enum<T>::value> >
129- inline bool operator == (const T& other, const Valueable<T>& val)
128+ template <typename T> requires std::is_enum_v<T >
129+ constexpr bool operator == (const T& other, const Valueable<T>& val)
130130{
131131 return val.Get () == other;
132132}
133133
134- template <typename T, typename = std::enable_if_t <std::is_enum<T>::value> >
135- inline bool operator != (const Valueable<T>& val, const T& other)
134+ template <typename T> requires std::is_enum_v<T >
135+ constexpr bool operator != (const Valueable<T>& val, const T& other)
136136{
137137 return !(val == other);
138138}
139139
140- template <typename T, typename = std::enable_if_t <std::is_enum<T>::value> >
141- inline bool operator != (const T& other, const Valueable<T>& val)
140+ template <typename T> requires std::is_enum_v<T >
141+ constexpr bool operator != (const T& other, const Valueable<T>& val)
142142{
143143 return !(val == other);
144144}
@@ -148,16 +148,16 @@ template<typename Lookuper>
148148class ValueableIdx : public Valueable <int >
149149{
150150public:
151- ValueableIdx () noexcept : Valueable<int >(-1 ) { }
152- explicit ValueableIdx (int value) noexcept : Valueable<int>(value) { }
153- ValueableIdx (ValueableIdx const & other) = default ;
154- ValueableIdx (ValueableIdx&& other) = default ;
151+ constexpr ValueableIdx () noexcept : Valueable<int>(-1 ) { }
152+ constexpr explicit ValueableIdx (int value) noexcept : Valueable<int>(value) { }
153+ constexpr ValueableIdx (ValueableIdx const & other) = default;
154+ constexpr ValueableIdx (ValueableIdx&& other) = default;
155155
156- ValueableIdx& operator = (ValueableIdx const & value) = default ;
157- ValueableIdx& operator = (ValueableIdx&& value) = default ;
156+ constexpr ValueableIdx& operator = (ValueableIdx const & value) = default ;
157+ constexpr ValueableIdx& operator = (ValueableIdx&& value) = default ;
158158
159159 template <typename Val> requires std::assignable_from<int &, Val&&>
160- ValueableIdx& operator = (Val value)
160+ constexpr ValueableIdx& operator = (Val value)
161161 {
162162 this ->Value = std::move (value);
163163 return *this ;
@@ -172,47 +172,47 @@ class Nullable : public Valueable<T>
172172protected:
173173 bool HasValue { false };
174174public:
175- Nullable () = default ;
176- explicit Nullable (T value) noexcept (noexcept (Valueable<T>{std::move (value)})) : Valueable<T>(std::move(value)), HasValue(true ) { }
177- Nullable (Nullable const & other) = default ;
178- Nullable (Nullable&& other) = default ;
175+ constexpr Nullable () = default;
176+ constexpr explicit Nullable (T value) noexcept (noexcept (Valueable<T>{std::move (value)})) : Valueable<T>(std::move(value)), HasValue(true ) { }
177+ constexpr Nullable (Nullable const & other) = default;
178+ constexpr Nullable (Nullable&& other) = default;
179179
180- Nullable& operator = (Nullable const & value) = default ;
181- Nullable& operator = (Nullable&& value) = default ;
180+ constexpr Nullable& operator = (Nullable const & value) = default ;
181+ constexpr Nullable& operator = (Nullable&& value) = default ;
182182
183- template <typename Val, typename = std::enable_if_t <std::is_assignable< T&, Val&&>::value> >
184- Nullable& operator = (Val value)
183+ template <typename Val> requires std::assignable_from< T&, Val&&>
184+ constexpr Nullable& operator = (Val value)
185185 {
186186 this ->Value = std::move (value);
187187 this ->HasValue = true ;
188188 return *this ;
189189 }
190190
191- bool isset () const noexcept
191+ constexpr bool isset () const noexcept
192192 {
193193 return this ->HasValue ;
194194 }
195195
196196 using Valueable<T>::Get;
197197
198- T Get (const T& defaultValue) const
198+ constexpr T Get (const T& defaultValue) const
199199 {
200200 return this ->isset () ? this ->Get () : defaultValue;
201201 }
202202
203203 using Valueable<T>::GetEx;
204204
205- T* GetEx (T* defaultValue) & noexcept
205+ constexpr T* GetEx (T* defaultValue) & noexcept
206206 {
207207 return this ->isset () ? this ->GetEx () : defaultValue;
208208 }
209209
210- const T* GetEx (const T* defaultValue) const noexcept
210+ constexpr const T* GetEx (const T* defaultValue) const noexcept
211211 {
212212 return this ->isset () ? this ->GetEx () : defaultValue;
213213 }
214214
215- void Reset ()
215+ constexpr void Reset ()
216216 {
217217 this ->Value = T ();
218218 this ->HasValue = false ;
@@ -230,16 +230,16 @@ template<typename Lookuper>
230230class NullableIdx : public Nullable <int >
231231{
232232public:
233- NullableIdx () noexcept : Nullable<int >(-1 ) { this ->HasValue = false ; }
234- explicit NullableIdx (int value) noexcept : Nullable<int>(value) { }
235- NullableIdx (NullableIdx const & other) = default ;
236- NullableIdx (NullableIdx&& other) = default ;
233+ constexpr NullableIdx () noexcept : Nullable<int>(-1 ) { this ->HasValue = false ; }
234+ constexpr explicit NullableIdx (int value) noexcept : Nullable<int>(value) { }
235+ constexpr NullableIdx (NullableIdx const & other) = default;
236+ constexpr NullableIdx (NullableIdx&& other) = default;
237237
238- NullableIdx& operator = (NullableIdx const & value) = default ;
239- NullableIdx& operator = (NullableIdx&& value) = default ;
238+ constexpr NullableIdx& operator = (NullableIdx const & value) = default ;
239+ constexpr NullableIdx& operator = (NullableIdx&& value) = default ;
240240
241- template <typename Val, typename = std::enable_if_t <std::is_assignable< int &, Val&&>::value> >
242- NullableIdx& operator = (Val value)
241+ template <typename Val> requires std::assignable_from< int &, Val&&>
242+ constexpr NullableIdx& operator = (Val value)
243243 {
244244 this ->Value = std::move (value);
245245 this ->HasValue = true ;
0 commit comments