Вопросы по теме 'boost-optional'

Как вернуть boost::Optional в неинициализированное состояние?
Как я могу «сбросить»/«сбросить» boost::optional ? optional<int> x; if( x ) { // We won't hit this since x is uninitialized } x = 3; if( x ) { // Now we will hit this since x has been initialized } // What should I do here to bring x...
27845 просмотров
schedule 18.09.2022

Может ли бросить неинициализированный конструктор std::Optional или boost::Optional?
Можно ли объявить любой из следующих методов шаблона noexcept ? template <typename T> std::optional<T> foo(const T& value) // noexcept? { try { // code possibly returning a T or a std::nullopt } catch(...) {...
1091 просмотров
schedule 18.04.2024

Почему boost::Optional‹T› не может быть преобразован в bool для целей std::is_convertible
У меня есть auto result = std::is_convertible < boost::optional<int> , bool >::value; static_assert( result , "task should return bool" ); и он не компилируется. Определение std::is_convertible : template<...
324 просмотров
schedule 27.08.2023