Skip to content

Commit ea2d0be

Browse files
[Support] Simplify setDefaultImpl (NFC)
We can use "constexpr if" to combine the two variants of functions.
1 parent a1bcc8f commit ea2d0be

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

llvm/include/llvm/Support/CommandLine.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,18 +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+
template <class T> void setDefaultImpl() {
1463+
if constexpr (std::is_assignable_v<T &, T>) {
1464+
const OptionValue<DataType> &V = this->getDefault();
1465+
if (V.hasValue())
1466+
this->setValue(V.getValue());
1467+
else
1468+
this->setValue(T());
1469+
}
14691470
}
14701471

1471-
template <class T, class = std::enable_if_t<!std::is_assignable_v<T &, T>>>
1472-
void setDefaultImpl(...) {}
1473-
14741472
void setDefault() override { setDefaultImpl<DataType>(); }
14751473

14761474
void done() {

0 commit comments

Comments
 (0)