Poco::Optional cannot hold classes that don't have a default constructor
Describe the bug
class A {
public:
A(int n) {}
};
int main(int argc, char** argv)
{
std::optional<A> a1; // ok
Poco::Optional<A> a2; // compile error !!!
return 0;
}
This is documented as such and appears to be by design. https://github.com/pocoproject/poco/blob/main/Foundation%2Finclude%2FPoco%2FOptional.h#L45
This is documented as such and appears to be by design. https://github.com/pocoproject/poco/blob/main/Foundation%2Finclude%2FPoco%2FOptional.h#L45
In that way, I cannot replace std::optional/boost::optional to Poco::Optional.
I hope Poco::Optional can do the same things like std::optional/boost::optional do.
Why would you replace std::optional with Poco::Optional?
@andrewauclair I create a pull request to Poco with std::optional, but I got a compile error:
error: 'value' is unavailable: introduced in macOS 10.13
r.value().get().run();
^
/Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/optional:959:27: note: 'value' has been explicitly marked unavailable here
constexpr value_type& value() &
^
It seems like macOS does not fully support the std::optional standard. So that I wanna replace std::optional with Poco::Optional.
See also: https://github.com/octobanana/peaclock/issues/2
The issue was solved by requesting newer macOS target. #4624