Skip to content

Commit 7f43a28

Browse files
committed
Use std::monostate
1 parent b8cb380 commit 7f43a28

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ struct InfoTreeNode {
123123
static constexpr uint64_t IndentSize = 4;
124124

125125
std::string Key;
126-
struct None {};
127-
using VariantType = std::variant<uint64_t, std::string, bool, None>;
126+
using VariantType = std::variant<uint64_t, std::string, bool, std::monostate>;
128127
VariantType Value;
129128
std::string Units;
130129
// Need to specify a default value number of elements here as `InfoTreeNode`'s
@@ -134,15 +133,15 @@ struct InfoTreeNode {
134133
// * The same key can appear multiple times
135134
std::unique_ptr<llvm::SmallVector<InfoTreeNode, 8>> Children;
136135

137-
InfoTreeNode() : InfoTreeNode("", None{}, "") {}
136+
InfoTreeNode() : InfoTreeNode("", std::monostate{}, "") {}
138137
InfoTreeNode(std::string Key, VariantType Value, std::string Units)
139138
: Key(Key), Value(Value), Units(Units) {}
140139

141140
/// Add a new info entry as a child of this node. The entry requires at least
142141
/// a key string in \p Key. The value in \p Value is optional and can be any
143142
/// type that is representable as a string. The units in \p Units is optional
144143
/// and must be a string.
145-
template <typename T = None>
144+
template <typename T = std::monostate>
146145
InfoTreeNode *add(std::string Key, T Value = T(),
147146
const std::string &Units = std::string()) {
148147
assert(!Key.empty() && "Invalid info key");
@@ -151,7 +150,7 @@ struct InfoTreeNode {
151150
Children = std::make_unique<llvm::SmallVector<InfoTreeNode, 8>>();
152151

153152
VariantType ValueVariant;
154-
if constexpr (std::is_same_v<T, bool> || std::is_same_v<T, None>)
153+
if constexpr (std::is_same_v<T, bool> || std::is_same_v<T, std::monostate>)
155154
ValueVariant = Value;
156155
else if constexpr (std::is_arithmetic_v<T>)
157156
ValueVariant = static_cast<uint64_t>(Value);
@@ -197,7 +196,7 @@ struct InfoTreeNode {
197196
llvm::outs() << (V ? "Yes" : "No");
198197
else if constexpr (std::is_same_v<T, uint64_t>)
199198
llvm::outs() << V;
200-
else if constexpr (std::is_same_v<T, None>) {
199+
else if constexpr (std::is_same_v<T, std::monostate>) {
201200
// Do nothing
202201
} else
203202
static_assert(false, "doPrint visit not exhaustive");

0 commit comments

Comments
 (0)