Diferentes resultados en Clang y GCC cuando se convierte a std :: opcional <T>
Dado el siguiente código:
#include <iostream>
#include <optional>
struct foo
{
explicit operator std::optional<int>() {
return std::optional<int>( 1 );
}
explicit operator int() {
return 0;
}
};
int main()
{
foo my_foo;
std::optional<int> my_opt( my_foo );
std::cout << "value: " << my_opt.value() << std::endl;
}
gcc 7.2.0 escribe value: 1
.
MSVC 201,7 (15.3) yclang 4.0.0 sin embargo escribe value: 0
.
¿Cuál es el correcto según el estándar C ++?