Code:
#include <https://raw.githubusercontent.com/martinmoene/optional-lite/master/include/nonstd/optional.hpp>
#include <iostream>
#include <string>
int main()
{
nonstd::optional<std::string> s;
s = "test";
std::cout << (*s == "test") << std::endl;
std::cout << (s.value_or("") == "test") << std::endl; // comment this line
std::cout << (s->empty()) << std::endl;
}
Output:
1
1
1
Expected output:
1
1
0
If I comment line with value_or it works just fine. GCC version also works as expected, but clang and msvc does not.
Live code: https://godbolt.org/z/frqjfr
Code:
Output:
1
1
1
Expected output:
1
1
0
If I comment line with
value_orit works just fine. GCC version also works as expected, but clang and msvc does not.Live code: https://godbolt.org/z/frqjfr