/* Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP #define BOOST_CORE_NOINIT_ADAPTOR_HPP #include namespace boost { template struct noinit_adaptor : A { template struct rebind { typedef noinit_adaptor::type> other; }; noinit_adaptor() : A() { } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template noinit_adaptor(U&& u) BOOST_NOEXCEPT : A(std::forward(u)) { } #else template noinit_adaptor(const U& u) BOOST_NOEXCEPT : A(u) { } template noinit_adaptor(U& u) BOOST_NOEXCEPT : A(u) { } #endif template noinit_adaptor(const noinit_adaptor& u) BOOST_NOEXCEPT : A(static_cast(u)) { } template void construct(U* p) { ::new((void*)p) U; } #if defined(BOOST_NO_CXX11_ALLOCATOR) template void construct(U* p, const V& v) { ::new((void*)p) U(v); } #endif template void destroy(U* p) { p->~U(); (void)p; } }; template inline bool operator==(const noinit_adaptor& lhs, const noinit_adaptor& rhs) BOOST_NOEXCEPT { return static_cast(lhs) == static_cast(rhs); } template inline bool operator!=(const noinit_adaptor& lhs, const noinit_adaptor& rhs) BOOST_NOEXCEPT { return !(lhs == rhs); } template inline noinit_adaptor noinit_adapt(const A& a) BOOST_NOEXCEPT { return noinit_adaptor(a); } } /* boost */ #endif