#include <https://raw.githubusercontent.com/martinmoene/optional-lite/master/include/nonstd/optional.hpp>
#include <iostream>
struct Type {
Type(int) {
std::cout << "construct" << std::endl;
}
Type(Type &&) {
std::cout << "move" << std::endl;
}
~Type() {
std::cout << "destruct" << std::endl;
}
};
int main()
{
nonstd::optional<Type> t(0);
return t.has_value();
}
construct
move
destruct
destruct
Code to reproduce:
Expected:
Output:
Live code: https://godbolt.org/z/5T575q (gcc 7.5 vs gcc latest output)