Probably this means that I have misunderstood the meaning of explicit
in general, but with specific example below, what allows a std::optional
to be used as a conditon of an if
, if its conversion operator to bool
is explicit?
#include <iostream>
#include <optional>
int main() {
std::optional<int> x;
if (x)
std::cout << x.value();
else
std::cout << "nothing";
}