Skip to content

Commit 319c45c

Browse files
authored
Replace MethodDetect<...> with std::void_t<...> (#1211)
1 parent a23e030 commit 319c45c

File tree

8 files changed

+22
-27
lines changed

8 files changed

+22
-27
lines changed

src/sst/core/eli/attributeInfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace SST {
2222
namespace ELI {
2323

24-
template <class T, class Enable = void>
24+
template <typename, typename = void>
2525
struct GetAttributes
2626
{
2727
static const std::vector<SST::ElementInfoAttribute>& get()
@@ -31,8 +31,8 @@ struct GetAttributes
3131
}
3232
};
3333

34-
template <class T>
35-
struct GetAttributes<T, typename MethodDetect<decltype(T::ELI_getAttributes())>::type>
34+
template <typename T>
35+
struct GetAttributes<T, std::void_t<decltype(T::ELI_getAttributes())>>
3636
{
3737
static const std::vector<SST::ElementInfoAttribute>& get() { return T::ELI_getAttributes(); }
3838
};

src/sst/core/eli/elibase.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <memory>
2222
#include <set>
2323
#include <string>
24+
#include <type_traits>
2425
#include <vector>
2526

2627
// Component Category Definitions
@@ -125,12 +126,6 @@ combineEliInfo(std::vector<T>& base, std::vector<T>& add)
125126
// field
126127
void combineEliInfo(std::vector<ElementInfoAttribute>& base, std::vector<ElementInfoAttribute>& add);
127128

128-
template <class T>
129-
struct MethodDetect
130-
{
131-
using type = void;
132-
};
133-
134129
struct LibraryLoader
135130
{
136131
virtual void load() = 0;
@@ -159,14 +154,14 @@ class LoadedLibraries
159154

160155
// Template used to get aliases. Needed because the ELI_getAlias()
161156
// function may not exist.
162-
template <class T, class Enable = void>
157+
template <typename, typename = void>
163158
struct GetAlias
164159
{
165160
static std::string get() { return ""; }
166161
};
167162

168-
template <class T>
169-
struct GetAlias<T, typename MethodDetect<decltype(T::ELI_getAlias())>::type>
163+
template <typename T>
164+
struct GetAlias<T, std::void_t<decltype(T::ELI_getAlias())>>
170165
{
171166
static std::string get() { return T::ELI_getAlias(); }
172167
};

src/sst/core/eli/paramsInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace SST {
2121
namespace ELI {
2222

23-
template <class T, class Enable = void>
23+
template <typename, typename = void>
2424
struct GetParams
2525
{
2626
static const std::vector<SST::ElementInfoParam>& get()
@@ -31,7 +31,7 @@ struct GetParams
3131
};
3232

3333
template <class T>
34-
struct GetParams<T, typename MethodDetect<decltype(T::ELI_getParams())>::type>
34+
struct GetParams<T, std::void_t<decltype(T::ELI_getParams())>>
3535
{
3636
static const std::vector<SST::ElementInfoParam>& get() { return T::ELI_getParams(); }
3737
};

src/sst/core/eli/portsInfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace SST {
2121
namespace ELI {
2222

23-
template <class T, class Enable = void>
23+
template <typename, typename = void>
2424
struct InfoPorts
2525
{
2626
static const std::vector<SST::ElementInfoPort>& get()
@@ -30,8 +30,8 @@ struct InfoPorts
3030
}
3131
};
3232

33-
template <class T>
34-
struct InfoPorts<T, typename MethodDetect<decltype(T::ELI_getPorts())>::type>
33+
template <typename T>
34+
struct InfoPorts<T, std::void_t<decltype(T::ELI_getPorts())>>
3535
{
3636
static const std::vector<SST::ElementInfoPort>& get() { return T::ELI_getPorts(); }
3737
};

src/sst/core/eli/profilePointInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace SST {
2121
namespace ELI {
2222

23-
template <class T, class Enable = void>
23+
template <typename, typename = void>
2424
struct InfoProfilePoints
2525
{
2626
static const std::vector<SST::ElementInfoProfilePoint>& get()
@@ -31,7 +31,7 @@ struct InfoProfilePoints
3131
};
3232

3333
template <class T>
34-
struct InfoProfilePoints<T, typename MethodDetect<decltype(T::ELI_getProfilePoints())>::type>
34+
struct InfoProfilePoints<T, std::void_t<decltype(T::ELI_getProfilePoints())>>
3535
{
3636
static const std::vector<SST::ElementInfoProfilePoint>& get() { return T::ELI_getProfilePoints(); }
3737
};

src/sst/core/eli/simpleInfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ template <int num, typename InfoType>
2828
struct SimpleInfoPlaceHolder
2929
{};
3030

31-
// Class to check for an ELI_getSimpleInfo Function. The
32-
// MethodDetect way to detect a member function doesn't seem to work
33-
// for functions with specific type signatures and we need to
31+
// Class to check for an ELI_getSimpleInfo Function. The std::void_t<
32+
// decltype()> way to detect a member function's type doesn't seem to
33+
// work for functions with specific type signatures and we need to
3434
// differentiate between the various versions using the first
3535
// parameter to the function (index + type).
3636
template <class T, int index, class InfoType>

src/sst/core/eli/statsInfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace SST {
2121
namespace ELI {
2222

23-
template <class T, class Enable = void>
23+
template <typename, typename = void>
2424
struct InfoStats
2525
{
2626
static const std::vector<SST::ElementInfoStatistic>& get()
@@ -30,8 +30,8 @@ struct InfoStats
3030
}
3131
};
3232

33-
template <class T>
34-
struct InfoStats<T, typename MethodDetect<decltype(T::ELI_getStatistics())>::type>
33+
template <typename T>
34+
struct InfoStats<T, std::void_t<decltype(T::ELI_getStatistics())>>
3535
{
3636
static const std::vector<SST::ElementInfoStatistic>& get() { return T::ELI_getStatistics(); }
3737
};

src/sst/core/eli/subcompSlotInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace SST {
2121
namespace ELI {
2222

23-
template <class T, class Enable = void>
23+
template <typename, typename = void>
2424
struct InfoSubs
2525
{
2626
static const std::vector<SST::ElementInfoSubComponentSlot>& get()
@@ -31,7 +31,7 @@ struct InfoSubs
3131
};
3232

3333
template <class T>
34-
struct InfoSubs<T, typename MethodDetect<decltype(T::ELI_getSubComponentSlots())>::type>
34+
struct InfoSubs<T, std::void_t<decltype(T::ELI_getSubComponentSlots())>>
3535
{
3636
static const std::vector<SST::ElementInfoSubComponentSlot>& get() { return T::ELI_getSubComponentSlots(); }
3737
};

0 commit comments

Comments
 (0)