I am having a mixed C++14/C++17 codebase and I want to enable a function isEmpty
only if I am having std::optional
at hand. So, I tried SFINAE:
template <typename T, typename int_<decltype(std::nullopt)>::type = 0>
inline bool isEmpty(const std::optional<T>& v) {
return !v;
}
However, that doesn't work.
How can I conditionally compile isEmpty
if std::optional
is there?