sol2
sol2 copied to clipboard
how to convert `std::optional` to `sol::optional`?
pretty certain there's easier way to do this but i can't seem to find any info on neither docs nor github issues
std::optional<tripoint> stdOpt = choose_adjacent( message, allow_vertical.value_or( false ) );
if( stdOpt.has_value() )
{
return sol::optional<tripoint>( *stdOpt );
}
return sol::optional<tripoint>();
Concise code would be:
auto solOpt = (stdOpt ? sol::optional<tripoint>(*stdOpt) : sol::nullopt);
🧟