Skip to content

Commit 4ca8f65

Browse files
[Support] Simplify setDefaultImpl (NFC) (llvm#137528)
We can use "constexpr if" to combine the two variants of functions.
1 parent 10f379e commit 4ca8f65

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

llvm/include/llvm/Support/CommandLine.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,20 +1459,16 @@ class opt
14591459
}
14601460
}
14611461

1462-
template <class T, class = std::enable_if_t<std::is_assignable_v<T &, T>>>
1463-
void setDefaultImpl() {
1464-
const OptionValue<DataType> &V = this->getDefault();
1465-
if (V.hasValue())
1466-
this->setValue(V.getValue());
1467-
else
1468-
this->setValue(T());
1462+
void setDefault() override {
1463+
if constexpr (std::is_assignable_v<DataType &, DataType>) {
1464+
const OptionValue<DataType> &V = this->getDefault();
1465+
if (V.hasValue())
1466+
this->setValue(V.getValue());
1467+
else
1468+
this->setValue(DataType());
1469+
}
14691470
}
14701471

1471-
template <class T, class = std::enable_if_t<!std::is_assignable_v<T &, T>>>
1472-
void setDefaultImpl(...) {}
1473-
1474-
void setDefault() override { setDefaultImpl<DataType>(); }
1475-
14761472
void done() {
14771473
addArgument();
14781474
Parser.initialize();

0 commit comments

Comments
 (0)