From e2278d3ab6c3d879f1cd40b510e6bfa5f9d98417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 20 Feb 2026 23:19:32 +0100 Subject: [PATCH] Fixes #332 ("aligned_alloc not available in C++11/14 on XCode 12") --- doc/container.qbk | 2 +- .../boost/container/detail/aligned_allocation.hpp | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index 8592f9c..c095b73 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -1489,7 +1489,7 @@ collect them containers and build [*Boost.Container], a library targeted to a wi * Fixed bugs/issues: * [@https://github.com/boostorg/container/issues/323 GitHub #323: ['"flat_tree::try_emplace UB"]]. * [@https://github.com/boostorg/container/issues/328 GitHub #328: ['"boost::container::deque stores a redundant copy of the allocator, increasing size"]]. - * [@https://github.com/boostorg/container/issues/330 GitHub #330: ['"boost/container/detail/pair.hpp: partial specializations of boost::move_detail traits for std::pair break Unity (jumbo)"]]. + * [@https://github.com/boostorg/container/issues/332 GitHub #332: ['"aligned_alloc not available in C++11/14 on XCode 12"]]. [endsect] diff --git a/include/boost/container/detail/aligned_allocation.hpp b/include/boost/container/detail/aligned_allocation.hpp index 5599dd6..0be52de 100644 --- a/include/boost/container/detail/aligned_allocation.hpp +++ b/include/boost/container/detail/aligned_allocation.hpp @@ -21,25 +21,24 @@ // Platform detection #if defined(_WIN32) && !defined(__CYGWIN__) #define BOOST_CONTAINER_HAS_ALIGNED_MALLOC +#elif BOOST_CXX_VERSION >= 201703L + #define BOOST_CONTAINER_HAS_ALIGNED_ALLOC +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) + //Note: in most C++ compilers __STDC_VERSION__ is not defined, but just in case + #define BOOST_CONTAINER_HAS_ALIGNED_ALLOC #else #include //Include it to detect POSIX features #if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) #define BOOST_CONTAINER_HAS_POSIX_MEMALIGN #elif defined(__APPLE__) - #include - #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 - #define BOOST_CONTAINER_HAS_ALIGNED_ALLOC - #else - #define BOOST_CONTAINER_HAS_POSIX_MEMALIGN - #endif + //All recent Apple OSes (macOS 10.6+, iOS 3.0+, tvOS 9.0+, watchOS 2.0+) support posix_memalign + #define BOOST_CONTAINER_HAS_POSIX_MEMALIGN #elif defined(__ANDROID__) #if (__ANDROID_API__ >= 28) #define BOOST_CONTAINER_HAS_ALIGNED_ALLOC #else #define BOOST_CONTAINER_HAS_POSIX_MEMALIGN #endif - #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) - #define BOOST_CONTAINER_HAS_ALIGNED_ALLOC #endif #endif