2 Copyright 2019 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP
9 #define BOOST_CORE_NOINIT_ADAPTOR_HPP
11 #include <boost/config.hpp>
12 #if !defined(BOOST_NO_CXX11_ALLOCATOR)
16 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
27 #if !defined(BOOST_NO_CXX11_ALLOCATOR)
28 typedef noinit_adaptor<typename std::allocator_traits<A>::template
29 rebind_alloc<U> > other;
31 typedef noinit_adaptor<typename A::template rebind<U>::other> other;
38 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
40 noinit_adaptor(U&& u) BOOST_NOEXCEPT
41 : A(std::forward<U>(u)) { }
44 noinit_adaptor(const U& u) BOOST_NOEXCEPT
49 noinit_adaptor(const noinit_adaptor<U>& u) BOOST_NOEXCEPT
50 : A(static_cast<const U&>(u)) { }
53 void construct(U* p) {
57 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
58 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
59 template<class U, class V, class... Args>
60 void construct(U* p, V&& v, Args&&... args) {
61 ::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
64 template<class U, class V>
65 void construct(U* p, V&& v) {
66 ::new((void*)p) U(std::forward<V>(v));
70 template<class U, class V>
71 void construct(U* p, const V& v) {
75 template<class U, class V>
76 void construct(U* p, V& v) {
87 template<class T, class U>
89 operator==(const noinit_adaptor<T>& lhs,
90 const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
92 return static_cast<const T&>(lhs) == static_cast<const U&>(rhs);
95 template<class T, class U>
97 operator!=(const noinit_adaptor<T>& lhs,
98 const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
100 return !(lhs == rhs);
104 inline noinit_adaptor<A>
105 noinit_adapt(const A& a) BOOST_NOEXCEPT
107 return noinit_adaptor<A>(a);