Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:30

0001 /*
0002 Copyright 2019 Glen Joseph Fernandes
0003 (glenjofe@gmail.com)
0004 
0005 Distributed under the Boost Software License, Version 1.0.
0006 (http://www.boost.org/LICENSE_1_0.txt)
0007 */
0008 #ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP
0009 #define BOOST_CORE_NOINIT_ADAPTOR_HPP
0010 
0011 #include <boost/core/allocator_access.hpp>
0012 
0013 namespace boost {
0014 
0015 template<class A>
0016 struct noinit_adaptor
0017     : A {
0018     typedef void _default_construct_destroy;
0019 
0020     template<class U>
0021     struct rebind {
0022         typedef noinit_adaptor<typename allocator_rebind<A, U>::type> other;
0023     };
0024 
0025     noinit_adaptor()
0026         : A() { }
0027 
0028 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0029     template<class U>
0030     noinit_adaptor(U&& u) BOOST_NOEXCEPT
0031         : A(std::forward<U>(u)) { }
0032 #else
0033     template<class U>
0034     noinit_adaptor(const U& u) BOOST_NOEXCEPT
0035         : A(u) { }
0036 
0037     template<class U>
0038     noinit_adaptor(U& u) BOOST_NOEXCEPT
0039         : A(u) { }
0040 #endif
0041 
0042     template<class U>
0043     noinit_adaptor(const noinit_adaptor<U>& u) BOOST_NOEXCEPT
0044         : A(static_cast<const A&>(u)) { }
0045 
0046     template<class U>
0047     void construct(U* p) {
0048         ::new((void*)p) U;
0049     }
0050 
0051 #if defined(BOOST_NO_CXX11_ALLOCATOR)
0052     template<class U, class V>
0053     void construct(U* p, const V& v) {
0054         ::new((void*)p) U(v);
0055     }
0056 #endif
0057 
0058     template<class U>
0059     void destroy(U* p) {
0060         p->~U();
0061         (void)p;
0062     }
0063 };
0064 
0065 template<class T, class U>
0066 inline bool
0067 operator==(const noinit_adaptor<T>& lhs,
0068     const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
0069 {
0070     return static_cast<const T&>(lhs) == static_cast<const U&>(rhs);
0071 }
0072 
0073 template<class T, class U>
0074 inline bool
0075 operator!=(const noinit_adaptor<T>& lhs,
0076     const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
0077 {
0078     return !(lhs == rhs);
0079 }
0080 
0081 template<class A>
0082 inline noinit_adaptor<A>
0083 noinit_adapt(const A& a) BOOST_NOEXCEPT
0084 {
0085     return noinit_adaptor<A>(a);
0086 }
0087 
0088 } /* boost */
0089 
0090 #endif