Skip to content

Commit 293784a

Browse files
committed
Example conversion for optional, using [[trivially_relocatable(bool)]].
1 parent 1282055 commit 293784a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/__config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,14 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
12811281
#define _LIBCPP_HAS_NO_IS_AGGREGATE
12821282
#endif
12831283

1284+
#ifndef _LIBCPP_TRIVIALLY_RELOCATABLE
1285+
#if __has_extension(trivially_relocatable)
1286+
#define _LIBCPP_TRIVIALLY_RELOCATABLE(x) [[clang::trivially_relocatable(x)]]
1287+
#else
1288+
#define _LIBCPP_TRIVIALLY_RELOCATABLE(x)
1289+
#endif
1290+
#endif
1291+
12841292
#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
12851293
#define _LIBCPP_HAS_NO_COROUTINES
12861294
#endif

include/optional

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ using __optional_sfinae_assign_base_t = __sfinae_assign_base<
581581
>;
582582

583583
template <class _Tp>
584-
class optional
584+
class _LIBCPP_TRIVIALLY_RELOCATABLE(is_trivially_relocatable<_Tp>::value) optional
585585
: private __optional_move_assign_base<_Tp>
586586
, private __optional_sfinae_ctor_base_t<_Tp>
587587
, private __optional_sfinae_assign_base_t<_Tp>

0 commit comments

Comments
 (0)