Skip to content

Commit c9cc29c

Browse files
committed
A different way to solve #23.
1 parent c3b1281 commit c9cc29c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

dev/json_dto/pub.hpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@
6363
#define JSON_DTO_NODISCARD
6464
#endif
6565

66+
// Handle the presence of std::launder.
67+
#if __cpp_lib_launder >= 201606L
68+
#define JSON_DTO_STD_LAUNDER(x) std::launder(x)
69+
#else
70+
#define JSON_DTO_STD_LAUNDER(x) x
71+
#endif
72+
6673
namespace json_dto
6774
{
6875

@@ -1161,13 +1168,13 @@ struct nullable_t
11611168
Field_Type *
11621169
field_ptr() noexcept
11631170
{
1164-
return reinterpret_cast< Field_Type * >( m_image_space );
1171+
return JSON_DTO_STD_LAUNDER( reinterpret_cast< Field_Type * >( m_image_space ) );
11651172
}
11661173

11671174
const Field_Type *
11681175
field_ptr() const noexcept
11691176
{
1170-
return reinterpret_cast< const Field_Type * >( m_image_space );
1177+
return JSON_DTO_STD_LAUNDER( reinterpret_cast< const Field_Type * >( m_image_space ) );
11711178
}
11721179

11731180
Field_Type &

0 commit comments

Comments
 (0)