]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | ////////////////////////////////////////////////////////////////////////////// |
2 | // | |
3 | // (C) Copyright Ion Gaztanaga 2014-2014. | |
4 | // | |
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) | |
8 | // | |
9 | // See http://www.boost.org/libs/container for documentation. | |
10 | // | |
11 | ////////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP | |
14 | #define BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP | |
15 | ||
16 | #ifndef BOOST_CONFIG_HPP | |
17 | # include <boost/config.hpp> | |
18 | #endif | |
19 | ||
20 | #if defined(BOOST_HAS_PRAGMA_ONCE) | |
21 | # pragma once | |
22 | #endif | |
23 | ||
24 | #include <boost/container/allocator_traits.hpp> | |
25 | #include <boost/container/detail/iterators.hpp> | |
26 | #include <boost/container/detail/value_init.hpp> | |
27 | ||
28 | namespace boost { | |
29 | namespace container { | |
30 | ||
31 | //In place construction | |
32 | ||
1e59de90 TL |
33 | struct iterator_arg_t{}; |
34 | ||
7c673cae FG |
35 | template<class Allocator, class T, class InpIt> |
36 | BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T* dest, InpIt source) | |
37 | { boost::container::allocator_traits<Allocator>::construct(a, dest, *source); } | |
38 | ||
1e59de90 TL |
39 | template<class Allocator, class T, class U> |
40 | BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, value_init_construct_iterator<U>) | |
7c673cae FG |
41 | { |
42 | boost::container::allocator_traits<Allocator>::construct(a, dest); | |
43 | } | |
44 | ||
1e59de90 | 45 | template <class T> |
7c673cae FG |
46 | class default_init_construct_iterator; |
47 | ||
1e59de90 TL |
48 | template<class Allocator, class T, class U> |
49 | BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, default_init_construct_iterator<U>) | |
7c673cae FG |
50 | { |
51 | boost::container::allocator_traits<Allocator>::construct(a, dest, default_init); | |
52 | } | |
53 | ||
1e59de90 | 54 | template <class T, class EmplaceFunctor> |
7c673cae FG |
55 | class emplace_iterator; |
56 | ||
1e59de90 TL |
57 | template<class Allocator, class T, class U, class EF> |
58 | BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, emplace_iterator<U, EF> ei) | |
7c673cae FG |
59 | { |
60 | ei.construct_in_place(a, dest); | |
61 | } | |
62 | ||
63 | //Assignment | |
64 | ||
65 | template<class DstIt, class InpIt> | |
66 | BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, InpIt source) | |
67 | { *dest = *source; } | |
68 | ||
1e59de90 TL |
69 | template<class DstIt, class U> |
70 | BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, value_init_construct_iterator<U>) | |
7c673cae | 71 | { |
11fdf7f2 | 72 | dtl::value_init<U> val; |
7c673cae FG |
73 | *dest = boost::move(val.get()); |
74 | } | |
75 | ||
1e59de90 | 76 | template <class DstIt> |
7c673cae FG |
77 | class default_init_construct_iterator; |
78 | ||
79 | template<class DstIt, class U, class D> | |
1e59de90 | 80 | BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, default_init_construct_iterator<U>) |
7c673cae FG |
81 | { |
82 | U u; | |
83 | *dest = boost::move(u); | |
84 | } | |
85 | ||
1e59de90 | 86 | template <class T, class EmplaceFunctor> |
7c673cae FG |
87 | class emplace_iterator; |
88 | ||
1e59de90 TL |
89 | template<class DstIt, class U, class EF> |
90 | BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, emplace_iterator<U, EF> ei) | |
7c673cae FG |
91 | { |
92 | ei.assign_in_place(dest); | |
93 | } | |
94 | ||
95 | } //namespace container { | |
96 | } //namespace boost { | |
97 | ||
98 | #endif //#ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP |