From f7488a2e4dd5911bd0a1c340c6e2ab2adfd5ffb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 3 Jun 2026 19:26:17 +0200 Subject: [PATCH] Added BOOST_CONTAINER_RETURNS_NONNULL and BOOST_CONTAINER_NONNULL to placement new --- include/boost/container/detail/placement_new.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/boost/container/detail/placement_new.hpp b/include/boost/container/detail/placement_new.hpp index 6d7ead8..0d3aa68 100644 --- a/include/boost/container/detail/placement_new.hpp +++ b/include/boost/container/detail/placement_new.hpp @@ -11,10 +11,15 @@ /////////////////////////////////////////////////////////////////////////////// #include +#include //BOOST_CONTAINER_RETURNS_NONNULL struct boost_container_new_t{}; //avoid including +//returns_nonnull lets the compiler drop the null check the new-expression +//otherwise performs on the result of this custom placement operator new; +//nonnull(2) tells it the passed pointer 'p' is never null either. +BOOST_CONTAINER_RETURNS_NONNULL BOOST_CONTAINER_NONNULL(2) inline void *operator new(std::size_t, void *p, boost_container_new_t) { return p; }