1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_RELOCATABLE_H 10 #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_RELOCATABLE_H 11 12 #include <__config> 13 #include <__type_traits/enable_if.h> 14 #include <__type_traits/integral_constant.h> 15 #include <__type_traits/is_same.h> 16 #include <__type_traits/is_trivially_copyable.h> 17 18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 19 # pragma GCC system_header 20 #endif 21 22 _LIBCPP_BEGIN_NAMESPACE_STD 23 24 // A type is trivially relocatable if a move construct + destroy of the original object is equivalent to 25 // `memcpy(dst, src, sizeof(T))`. 26 27 #if __has_builtin(__is_trivially_relocatable) 28 template <class _Tp, class = void> 29 struct __libcpp_is_trivially_relocatable : integral_constant<bool, __is_trivially_relocatable(_Tp)> {}; 30 #else 31 template <class _Tp, class = void> 32 struct __libcpp_is_trivially_relocatable : is_trivially_copyable<_Tp> {}; 33 #endif 34 35 template <class _Tp> 36 struct __libcpp_is_trivially_relocatable<_Tp, 37 __enable_if_t<is_same<_Tp, typename _Tp::__trivially_relocatable>::value> > 38 : true_type {}; 39 40 _LIBCPP_END_NAMESPACE_STD 41 42 #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_RELOCATABLE_H 43