Skip to content

Commit 9b2ee4c

Browse files
committed
Use _t and _v traits instead of ::type and ::value
1 parent 959eb59 commit 9b2ee4c

24 files changed

+93
-108
lines changed

src/sst/core/baseComponent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ class SerializeBaseComponentHelper
11381138

11391139

11401140
template <class T>
1141-
class serialize_impl<T*, typename std::enable_if<std::is_base_of<SST::BaseComponent, T>::value>::type>
1141+
class serialize_impl<T*, std::enable_if_t<std::is_base_of_v<SST::BaseComponent, T>>>
11421142
{
11431143
template <class A>
11441144
friend class serialize;

src/sst/core/decimal_fixedpoint.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class decimal_fixedpoint
217217
@param init Initialization value.
218218
*/
219219
template <class T>
220-
decimal_fixedpoint(T init, typename std::enable_if<std::is_unsigned<T>::value>::type* = nullptr)
220+
decimal_fixedpoint(T init, std::enable_if_t<std::is_unsigned_v<T>>* = nullptr)
221221
{
222222
from_uint64(init);
223223
}
@@ -228,8 +228,7 @@ class decimal_fixedpoint
228228
@param init Initialization value.
229229
*/
230230
template <class T>
231-
decimal_fixedpoint(
232-
T init, typename std::enable_if<std::is_signed<T>::value && std::is_integral<T>::value>::type* = nullptr)
231+
decimal_fixedpoint(T init, std::enable_if_t<std::is_signed_v<T> && std::is_integral_v<T>>* = nullptr)
233232
{
234233
if ( init < 0 ) {
235234
from_uint64(-init);
@@ -246,7 +245,7 @@ class decimal_fixedpoint
246245
@param init Initialization value.
247246
*/
248247
template <class T>
249-
decimal_fixedpoint(const T init, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr)
248+
decimal_fixedpoint(const T init, std::enable_if_t<std::is_floating_point_v<T>>* = nullptr)
250249
{
251250
from_double(init);
252251
}
@@ -408,7 +407,7 @@ class decimal_fixedpoint
408407
Templated conversion function for unsigned types.
409408
*/
410409
template <typename T>
411-
T convert_to(typename std::enable_if<std::is_unsigned<T>::value>::type* = 0) const
410+
T convert_to(std::enable_if_t<std::is_unsigned_v<T>>* = nullptr) const
412411
{
413412
return static_cast<T>(toUnsignedLong());
414413
}
@@ -417,7 +416,7 @@ class decimal_fixedpoint
417416
Templated conversion function for signed integral types.
418417
*/
419418
template <typename T>
420-
T convert_to(typename std::enable_if<std::is_signed<T>::value && std::is_integral<T>::value>::type* = 0) const
419+
T convert_to(std::enable_if_t<std::is_signed_v<T> && std::is_integral_v<T>>* = nullptr) const
421420
{
422421
return static_cast<T>(toLong());
423422
}
@@ -426,7 +425,7 @@ class decimal_fixedpoint
426425
Templated conversion function for floating point types.
427426
*/
428427
template <typename T>
429-
T convert_to(typename std::enable_if<std::is_floating_point<T>::value>::type* = 0) const
428+
T convert_to(std::enable_if_t<std::is_floating_point_v<T>>* = nullptr) const
430429
{
431430
return static_cast<T>(toDouble());
432431
}

src/sst/core/eli/attributeInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ProvidesAttributes
7979
{ \
8080
static std::vector<SST::ElementInfoAttribute> var = { __VA_ARGS__ }; \
8181
auto parent = SST::ELI::GetAttributes< \
82-
typename std::conditional<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>::type>::get(); \
82+
std::conditional_t<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>>::get(); \
8383
SST::ELI::combineEliInfo(var, parent); \
8484
return var; \
8585
}

src/sst/core/eli/elementbuilder.h

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,11 @@ struct DerivedBuilder : public Builder<Base, Args...>
184184
Base* create(Args... ctorArgs) override { return Allocator<Base, T>()(std::forward<Args>(ctorArgs)...); }
185185
};
186186

187-
template <class T, class U>
188-
struct is_tuple_constructible : public std::false_type
189-
{};
187+
template <class, class>
188+
inline constexpr bool is_tuple_constructible_v = false;
190189

191190
template <class T, class... Args>
192-
struct is_tuple_constructible<T, std::tuple<Args...>> : public std::is_constructible<T, Args...>
193-
{};
191+
inline constexpr bool is_tuple_constructible_v<T, std::tuple<Args...>> = std::is_constructible_v<T, Args...>;
194192

195193
struct BuilderDatabase
196194
{
@@ -230,22 +228,22 @@ template <class NewCtor, class OldCtor>
230228
struct ExtendedCtor
231229
{
232230
template <class T>
233-
using is_constructible = typename NewCtor::template is_constructible<T>;
231+
static constexpr bool is_constructible_v = NewCtor::template is_constructible_v<T>;
234232

235233
/**
236234
The derived Ctor can "block" the more abstract Ctor, meaning an object
237235
should only be instantiated as the most derived type. enable_if here
238236
checks if both the derived API and the parent API are still valid
239237
*/
240238
template <class T>
241-
static typename std::enable_if<OldCtor::template is_constructible<T>::value, bool>::type add()
239+
static std::enable_if_t<OldCtor::template is_constructible_v<T>, bool> add()
242240
{
243241
// if abstract, force an allocation to generate meaningful errors
244242
return NewCtor::template add<T>() && OldCtor::template add<T>();
245243
}
246244

247245
template <class T>
248-
static typename std::enable_if<!OldCtor::template is_constructible<T>::value, bool>::type add()
246+
static std::enable_if_t<!OldCtor::template is_constructible_v<T>, bool> add()
249247
{
250248
// if abstract, force an allocation to generate meaningful errors
251249
return NewCtor::template add<T>();
@@ -262,7 +260,7 @@ template <class Base, class... Args>
262260
struct SingleCtor
263261
{
264262
template <class T>
265-
using is_constructible = std::is_constructible<T, Args...>;
263+
static constexpr bool is_constructible_v = std::is_constructible_v<T, Args...>;
266264

267265
template <class T>
268266
static bool add()
@@ -283,15 +281,12 @@ template <class Base, class Ctor, class... Ctors>
283281
struct CtorList : public CtorList<Base, Ctors...>
284282
{
285283
template <class T> // if T is constructible with Ctor arguments
286-
using is_constructible = typename std::conditional<
287-
is_tuple_constructible<T, Ctor>::value,
288-
std::true_type, // yes, constructible
289-
typename CtorList<Base, Ctors...>::template is_constructible<T> // not constructible here but maybe later
290-
>::type;
284+
static constexpr bool is_constructible_v =
285+
is_tuple_constructible_v<T, Ctor> // yes, constructible
286+
|| CtorList<Base, Ctors...>::template is_constructible_v<T>; // not constructible here but maybe later
291287

292288
template <class T, int NumValid = 0, class U = T>
293-
static typename std::enable_if<std::is_abstract<U>::value || is_tuple_constructible<U, Ctor>::value, bool>::type
294-
add()
289+
static std::enable_if_t<std::is_abstract_v<U> || is_tuple_constructible_v<U, Ctor>, bool> add()
295290
{
296291
// if abstract, force an allocation to generate meaningful errors
297292
auto* fact = ElementsBuilder<Base, Ctor>::template makeBuilder<U>();
@@ -300,8 +295,7 @@ struct CtorList : public CtorList<Base, Ctors...>
300295
}
301296

302297
template <class T, int NumValid = 0, class U = T>
303-
static typename std::enable_if<!std::is_abstract<U>::value && !is_tuple_constructible<U, Ctor>::value, bool>::type
304-
add()
298+
static std::enable_if_t<!std::is_abstract_v<U> && !is_tuple_constructible_v<U, Ctor>, bool> add()
305299
{
306300
return CtorList<Base, Ctors...>::template add<T, NumValid>();
307301
}
@@ -323,8 +317,8 @@ class NoValidConstructorsForDerivedType<0>
323317
template <class Base>
324318
struct CtorList<Base, void>
325319
{
326-
template <class T>
327-
using is_constructible = std::false_type;
320+
template <class>
321+
static constexpr bool is_constructible_v = false;
328322

329323
template <class T, int numValidCtors>
330324
static bool add()

src/sst/core/eli/elementinfo.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,15 @@ SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver)
420420
// this class. Sny local information will overwrite any inherited
421421
// information. See comment for SST_ELI_DECLARE_BASE in elibase.h for
422422
// info on how __EliDerivedLevel is used.
423-
#define SST_ELI_REGISTER_DERIVED(base, cls, lib, name, version, desc) \
424-
[[maybe_unused]] static constexpr int __EliDerivedLevel = \
425-
std::is_same<base, cls>::value ? __EliBaseLevel : __EliBaseLevel + 1; \
426-
static bool ELI_isLoaded() \
427-
{ \
428-
return SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \
429-
SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \
430-
} \
431-
SST_ELI_FORCE_INSTANTIATION(base, cls) \
423+
#define SST_ELI_REGISTER_DERIVED(base, cls, lib, name, version, desc) \
424+
[[maybe_unused]] static constexpr int __EliDerivedLevel = \
425+
std::is_same_v<base, cls> ? __EliBaseLevel : __EliBaseLevel + 1; \
426+
static bool ELI_isLoaded() \
427+
{ \
428+
return SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \
429+
SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \
430+
} \
431+
SST_ELI_FORCE_INSTANTIATION(base, cls) \
432432
SST_ELI_DEFAULT_INFO(lib, name, ELI_FORWARD_AS_ONE(version), desc)
433433

434434
#define SST_ELI_REGISTER_EXTERN(base, cls) \

src/sst/core/eli/paramsInfo.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ class ProvidesParams
8181
} // namespace SST
8282

8383
// clang-format off
84-
#define SST_ELI_DOCUMENT_PARAMS(...) \
85-
static const std::vector<SST::ElementInfoParam>& ELI_getParams() \
86-
{ \
87-
static std::vector<SST::ElementInfoParam> var = { __VA_ARGS__ }; \
88-
auto parent = SST::ELI::GetParams< \
89-
typename std::conditional<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>::type>::get(); \
90-
SST::ELI::combineEliInfo(var, parent); \
91-
return var; \
84+
#define SST_ELI_DOCUMENT_PARAMS(...) \
85+
static const std::vector<SST::ElementInfoParam>& ELI_getParams() \
86+
{ \
87+
static std::vector<SST::ElementInfoParam> var = { __VA_ARGS__ }; \
88+
auto parent = SST::ELI::GetParams< \
89+
std::conditional_t<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>>::get(); \
90+
SST::ELI::combineEliInfo(var, parent); \
91+
return var; \
9292
}
9393
// clang-format on
9494

src/sst/core/eli/portsInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ProvidesPorts
8282
{ \
8383
static std::vector<SST::ElementInfoPort> var = { __VA_ARGS__ }; \
8484
auto parent = SST::ELI::InfoPorts< \
85-
typename std::conditional<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>::type>::get(); \
85+
std::conditional_t<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>>::get(); \
8686
SST::ELI::combineEliInfo(var, parent); \
8787
return var; \
8888
}

src/sst/core/eli/profilePointInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ProvidesProfilePoints
7676
{ \
7777
static std::vector<SST::ElementInfoProfilePoint> var = { __VA_ARGS__ }; \
7878
auto parent = SST::ELI::InfoProfilePoints< \
79-
typename std::conditional<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>::type>::get(); \
79+
std::conditional_t<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>>::get(); \
8080
SST::ELI::combineEliInfo(var, parent); \
8181
return var; \
8282
}

src/sst/core/eli/simpleInfo.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,21 @@ class checkForELI_getSimpleInfoFunction
5454
static bool const value = (sizeof(HasFunction<T>(0)) == sizeof(Match));
5555
};
5656

57+
template <class T, int index, class InfoType>
58+
inline constexpr bool checkForELI_getSimpleInfoFunction_v =
59+
checkForELI_getSimpleInfoFunction<T, index, InfoType>::value;
60+
5761
// Actual functions that use checkForELI_getSimpleInfoFunction class
5862
// to create functions to get the information from the class
5963
template <class T, int index, class InfoType>
60-
typename std::enable_if<checkForELI_getSimpleInfoFunction<T, index, InfoType>::value, const InfoType&>::type
64+
std::enable_if_t<checkForELI_getSimpleInfoFunction_v<T, index, InfoType>, const InfoType&>
6165
ELI_templatedGetSimpleInfo()
6266
{
6367
return T::ELI_getSimpleInfo(SimpleInfoPlaceHolder<index, InfoType>());
6468
}
6569

6670
template <class T, int index, class InfoType>
67-
typename std::enable_if<not checkForELI_getSimpleInfoFunction<T, index, InfoType>::value, const InfoType&>::type
71+
std::enable_if_t<!checkForELI_getSimpleInfoFunction_v<T, index, InfoType>, const InfoType&>
6872
ELI_templatedGetSimpleInfo()
6973
{
7074
static InfoType var;

src/sst/core/eli/statsInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ProvidesStats
9090
{ \
9191
static std::vector<SST::ElementInfoStatistic> var = { __VA_ARGS__ }; \
9292
auto parent = SST::ELI::InfoStats< \
93-
typename std::conditional<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>::type>::get(); \
93+
std::conditional_t<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>>::get(); \
9494
SST::ELI::combineEliInfo(var, parent); \
9595
return var; \
9696
}

0 commit comments

Comments
 (0)