Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-17 08:39:40

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2025-2025. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/container for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 #ifndef BOOST_CONTAINER_DETAIL_OPERATOR_NEW_HELPERS_HPP
0011 #define BOOST_CONTAINER_DETAIL_OPERATOR_NEW_HELPERS_HPP
0012 
0013 #ifndef BOOST_CONFIG_HPP
0014 #  include <boost/config.hpp>
0015 #endif
0016 
0017 #if defined(BOOST_HAS_PRAGMA_ONCE)
0018 #  pragma once
0019 #endif
0020 
0021 #include <boost/container/detail/std_fwd.hpp>
0022 #include <boost/container/throw_exception.hpp>
0023 
0024 namespace boost {
0025 namespace container {
0026 namespace dtl {
0027 
0028 template <class T>
0029 T* operator_new_allocate(std::size_t count)
0030 {
0031    const std::size_t max_count = std::size_t(-1)/(2*sizeof(T));
0032    if(BOOST_UNLIKELY(count > max_count))
0033       throw_bad_alloc();
0034    #if defined(__cpp_aligned_new)
0035    BOOST_IF_CONSTEXPR(__STDCPP_DEFAULT_NEW_ALIGNMENT__ < alignof(T)) {
0036       return static_cast<T*>(::operator new(count*sizeof(T), std::align_val_t(alignof(T))));
0037    }
0038    #endif
0039    return static_cast<T*>(::operator new(count*sizeof(T)));
0040 }
0041 
0042 template <class T>
0043 void operator_delete_deallocate(T* ptr, std::size_t n) BOOST_NOEXCEPT_OR_NOTHROW
0044 {
0045    (void)n;
0046    #ifdef __cpp_aligned_new
0047    BOOST_IF_CONSTEXPR(__STDCPP_DEFAULT_NEW_ALIGNMENT__ < alignof(T)) {
0048       # if defined(__cpp_sized_deallocation)
0049       ::operator delete((void*)ptr, n * sizeof(T), std::align_val_t(alignof(T)));
0050       #else
0051       ::operator delete((void*)ptr, std::align_val_t(alignof(T)));
0052       # endif
0053       return;
0054    }
0055    #endif
0056 
0057    # if defined(__cpp_sized_deallocation)
0058    ::operator delete((void*)ptr, n * sizeof(T));
0059    #else
0060    ::operator delete((void*)ptr);
0061    # endif
0062 }
0063 
0064 }  //namespace dtl {
0065 }  //namespace container {
0066 }  //namespace boost {
0067 
0068 #endif   //#ifndef BOOST_CONTAINER_DETAIL_OPERATOR_NEW_HELPERS_HPP