yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

Is it possiable to disable exception?

Open owent opened this issue 5 years ago • 2 comments
trafficstars

Is it possiable to disable exception? In some environment, exception and RTTI is disabled, I found RTTI is only used by gtest, but there is no way to disable exception. I think it's better to provide a error handle instead of throw when exception is disabled.

owent avatar Jul 31 '20 02:07 owent

It would require the std::expected (see https://github.com/jbeder/yaml-cpp/issues/696) which is not likely to arrive within years.

champignoom avatar Dec 11 '20 00:12 champignoom

std::expected is available with some compilers. I'm thinking of making a fork that supports this for my own needs/desires. I think a good interface would look something like

template<T>
std::expected<T, YAML::Exception>
YAML::Node::expect() const noexcept;

// example
auto result = node["value"].expect<std::string>();

Since this would be similar to the Node::as method. If I get it to a point that feels stable, are there guidelines for contributing somewhere?

josiest avatar Nov 13 '22 01:11 josiest