From 0e3cf78e68c3e7e4e62d331d983971982a58f4b3 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Thu, 21 Dec 2023 15:22:30 -0500 Subject: [PATCH] Make static_vector trivially relocatable when T is trivially relocatable --- doc/Jamfile.v2 | 1 + include/boost/container/detail/type_traits.hpp | 8 ++++++++ include/boost/container/static_vector.hpp | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index dbeaee88..ed80ff10 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -42,6 +42,7 @@ doxygen autodoc \"BOOST_COPY_ASSIGN_REF(T)=const T &\" \\ \"BOOST_FWD_REF(a)=a &&\" \\ \"BOOST_CONTAINER_ATTRIBUTE_NODISCARD=[[nodiscard]] \" \\ + \"BOOST_CONTAINER_ATTRIBUTE_TRIVIALLY_RELOCATABLE_IF=\" \\ \"BOOST_NORETURN=[[noreturn]] \" \\ \"BOOST_INTRUSIVE_OPTION_CONSTANT(OPTION_NAME, TYPE, VALUE, CONSTANT_NAME) = template struct OPTION_NAME{};\" \\ \"BOOST_INTRUSIVE_OPTION_TYPE(OPTION_NAME, TYPE, TYPEDEF_EXPR, TYPEDEF_NAME) = template struct OPTION_NAME{};\" \\ diff --git a/include/boost/container/detail/type_traits.hpp b/include/boost/container/detail/type_traits.hpp index ffa061b5..dd916fba 100644 --- a/include/boost/container/detail/type_traits.hpp +++ b/include/boost/container/detail/type_traits.hpp @@ -68,6 +68,14 @@ using ::boost::move_detail::natN; using ::boost::move_detail::max_align_t; using ::boost::move_detail::is_convertible; +// TODO: Move this trait into + +#if __cpp_lib_trivially_relocatable + using ::std::is_trivially_relocatable; +#else + template struct is_trivially_relocatable : std::is_trivially_copyable {}; +#endif + } //namespace dtl { } //namespace container { } //namespace boost { diff --git a/include/boost/container/static_vector.hpp b/include/boost/container/static_vector.hpp index b3d3b4f6..7ee818bb 100644 --- a/include/boost/container/static_vector.hpp +++ b/include/boost/container/static_vector.hpp @@ -149,7 +149,7 @@ struct get_static_vector_allocator //!@tparam Options A type produced from \c boost::container::static_vector_options. If no option //! is specified, by default throw_on_overflow option is set. template -class static_vector +class BOOST_CONTAINER_ATTRIBUTE_TRIVIALLY_RELOCATABLE_IF(dtl::is_trivially_relocatable::value) static_vector : public vector::type> { public: