From 44b1835633d720607dd37aed513f460c8e46e92e Mon Sep 17 00:00:00 2001 From: Martijn Otto Date: Wed, 17 Jan 2024 10:52:33 +0100 Subject: [PATCH] Allow null for `std::optional` --- dev/json_dto/pub.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dev/json_dto/pub.hpp b/dev/json_dto/pub.hpp index c404ffb..37a5d66 100644 --- a/dev/json_dto/pub.hpp +++ b/dev/json_dto/pub.hpp @@ -1604,6 +1604,15 @@ default_on_null( nullable_t< Field_Type > & f ) f.reset(); } +#if defined( JSON_DTO_SUPPORTS_STD_OPTIONAL ) +template< typename FieldType > +void +default_on_null( std::optional< FieldType > & f ) +{ + f.reset(); +} +#endif + template< typename Field_Type, typename Field_Default_Value_Type > void set_default_value( Field_Type & f, Field_Default_Value_Type && default_value )