1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2014-2014.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // See http://www.boost.org/libs/container for documentation.
11 //////////////////////////////////////////////////////////////////////////////
13 #ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP
14 #define BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP
16 #ifndef BOOST_CONFIG_HPP
17 # include <boost/config.hpp>
20 #if defined(BOOST_HAS_PRAGMA_ONCE)
24 #include <boost/container/allocator_traits.hpp>
25 #include <boost/container/detail/iterators.hpp>
26 #include <boost/container/detail/value_init.hpp>
31 //In place construction
33 template<class Allocator, class T, class InpIt>
34 BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T* dest, InpIt source)
35 { boost::container::allocator_traits<Allocator>::construct(a, dest, *source); }
37 template<class Allocator, class T, class U, class D>
38 BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, value_init_construct_iterator<U, D>)
40 boost::container::allocator_traits<Allocator>::construct(a, dest);
43 template <class T, class Difference>
44 class default_init_construct_iterator;
46 template<class Allocator, class T, class U, class D>
47 BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, default_init_construct_iterator<U, D>)
49 boost::container::allocator_traits<Allocator>::construct(a, dest, default_init);
52 template <class T, class EmplaceFunctor, class Difference>
53 class emplace_iterator;
55 template<class Allocator, class T, class U, class EF, class D>
56 BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, emplace_iterator<U, EF, D> ei)
58 ei.construct_in_place(a, dest);
63 template<class DstIt, class InpIt>
64 BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, InpIt source)
67 template<class DstIt, class U, class D>
68 BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, value_init_construct_iterator<U, D>)
70 container_detail::value_init<U> val;
71 *dest = boost::move(val.get());
74 template <class DstIt, class Difference>
75 class default_init_construct_iterator;
77 template<class DstIt, class U, class D>
78 BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, default_init_construct_iterator<U, D>)
81 *dest = boost::move(u);
84 template <class T, class EmplaceFunctor, class Difference>
85 class emplace_iterator;
87 template<class DstIt, class U, class EF, class D>
88 BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, emplace_iterator<U, EF, D> ei)
90 ei.assign_in_place(dest);
93 } //namespace container {
96 #endif //#ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP