is_optional_like

Determine if T should be treated as an optional.

Synopsis

Defined in header <boost/json/conversion.hpp>.

template<
    class T>
struct is_optional_like;

This trait is deprecated and will be removed in Boost 1.92.0. Switch to using conversion_category_for and optional_category.

Optionals are serialised as null if empty, or as the stored type otherwise.

Given t, a glvalue of type T, if

  • decltype( t.value() ) is well-formed and isn’t a void type; and

  • t.reset() is well-formed;

then the trait provides the member constant value that is equal to true. Otherwise, value is equal to false.

Users can specialize the trait for their own types if they don’t want them to be treated as optionals. For example:

namespace boost {
namespace json {

template <>
struct is_optional_like<your::optional> : std::false_type
{ };

} // namespace boost
} // namespace json

Types Satisfying the Trait

Convenience header <boost/json.hpp>.