Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 08:06:30

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2014-2014.
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // See http://www.boost.org/libs/container for documentation.
0010 //
0011 //////////////////////////////////////////////////////////////////////////////
0012 
0013 #ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP
0014 #define BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP
0015 
0016 #ifndef BOOST_CONFIG_HPP
0017 #  include <boost/config.hpp>
0018 #endif
0019 
0020 #if defined(BOOST_HAS_PRAGMA_ONCE)
0021 #  pragma once
0022 #endif
0023 
0024 #include <boost/container/allocator_traits.hpp>
0025 #include <boost/container/detail/iterators.hpp>
0026 #include <boost/container/detail/value_init.hpp>
0027 #include <boost/container/detail/is_pair.hpp>
0028 
0029 namespace boost {
0030 namespace container {
0031 
0032 //In place construction
0033 
0034 struct iterator_arg_t{};
0035 
0036 template<class Allocator, class T, class InpIt>
0037 BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T* dest, InpIt source)
0038 {     boost::container::allocator_traits<Allocator>::construct(a, dest, *source);  }
0039 
0040 template<class Allocator, class T, class U>
0041 BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, value_init_construct_iterator<U>)
0042 {
0043    boost::container::allocator_traits<Allocator>::construct(a, dest);
0044 }
0045 
0046 template <class T>
0047 class default_init_construct_iterator;
0048 
0049 template<class Allocator, class T, class U>
0050 BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, default_init_construct_iterator<U>)
0051 {
0052    boost::container::allocator_traits<Allocator>::construct(a, dest, default_init);
0053 }
0054 
0055 template <class T, class EmplaceFunctor>
0056 class emplace_iterator;
0057 
0058 template<class Allocator, class T, class U, class EF>
0059 BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, emplace_iterator<U, EF> ei)
0060 {
0061    ei.construct_in_place(a, dest);
0062 }
0063 
0064 //Assignment
0065 
0066 template<class T, class U>
0067 BOOST_CONTAINER_FORCEINLINE
0068    typename dtl::disable_if_c
0069       <  dtl::is_pair<typename dtl::remove_reference<T>::type>::value
0070       && dtl::is_pair<typename dtl::remove_reference<U>::type>::value
0071       , void>::type
0072 assign_in_place_ref(T &t, BOOST_FWD_REF(U) u)
0073 {  t = ::boost::forward<U>(u);  }
0074 
0075 template<class T, class U>
0076 BOOST_CONTAINER_FORCEINLINE
0077    typename dtl::enable_if_c
0078       <  dtl::is_pair<typename dtl::remove_reference<T>::type>::value
0079       && dtl::is_pair<typename dtl::remove_reference<U>::type>::value
0080       , void>::type
0081 assign_in_place_ref(T &t, const U &u)
0082 {
0083    assign_in_place_ref(t.first, u.first);
0084    assign_in_place_ref(t.second, u.second);
0085 }
0086 
0087 template<class T, class U>
0088 BOOST_CONTAINER_FORCEINLINE
0089    typename dtl::enable_if_c
0090       <  dtl::is_pair<typename dtl::remove_reference<T>::type>::value
0091       && dtl::is_pair<typename dtl::remove_reference<U>::type>::value
0092       , void>::type
0093 assign_in_place_ref(T &t, BOOST_RV_REF(U) u)
0094 {
0095    assign_in_place_ref(t.first,  ::boost::move(u.first));
0096    assign_in_place_ref(t.second, ::boost::move(u.second));
0097 }
0098 
0099 template<class DstIt, class InpIt>
0100 BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, InpIt source)
0101 {  assign_in_place_ref(*dest, *source);  }
0102 
0103 template<class DstIt, class U>
0104 BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, value_init_construct_iterator<U>)
0105 {
0106    dtl::value_init<U> val;
0107    *dest = boost::move(val.get());
0108 }
0109 
0110 template <class DstIt>
0111 class default_init_construct_iterator;
0112 
0113 template<class DstIt, class U, class D>
0114 BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, default_init_construct_iterator<U>)
0115 {
0116    U u;
0117    *dest = boost::move(u);
0118 }
0119 
0120 template <class T, class EmplaceFunctor>
0121 class emplace_iterator;
0122 
0123 template<class DstIt, class U, class EF>
0124 BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, emplace_iterator<U, EF> ei)
0125 {
0126    ei.assign_in_place(dest);
0127 }
0128 
0129 }  //namespace container {
0130 }  //namespace boost {
0131 
0132 #endif   //#ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP