Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
_allocator_traits.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2019 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 
17 
18 
19 */
20 
21 #ifndef __TBB_allocator_traits_H
22 #define __TBB_allocator_traits_H
23 
24 #include "../tbb_stddef.h" // true/false_type
25 
26 #if __TBB_ALLOCATOR_TRAITS_PRESENT
27 #include <memory> // for allocator_traits
28 #endif
29 
30 #if __TBB_CPP11_RVALUE_REF_PRESENT
31 #include <utility> // for std::move
32 #endif
33 
34 // For allocator_swap helper
35 #include __TBB_STD_SWAP_HEADER
36 
37 namespace tbb {
38 namespace internal {
39 
42 #if __TBB_ALLOCATOR_TRAITS_PRESENT
45 #else
48 #endif
49 
50 #if __TBB_CPP11_RVALUE_REF_PRESENT
51 template <typename MyAlloc, typename OtherAlloc>
54 inline void allocator_move_assignment(MyAlloc& my_allocator, OtherAlloc& other_allocator, traits_true_type) {
55  my_allocator = std::move(other_allocator);
56 }
57 template <typename MyAlloc, typename OtherAlloc>
58 inline void allocator_move_assignment(MyAlloc&, OtherAlloc&, traits_false_type) { /* NO MOVE */ }
59 #endif
60 
63 template <typename MyAlloc, typename OtherAlloc>
64 inline void allocator_swap(MyAlloc& my_allocator, OtherAlloc& other_allocator, traits_true_type) {
65  using std::swap;
66  swap(my_allocator, other_allocator);
67 }
68 template <typename MyAlloc, typename OtherAlloc>
69 inline void allocator_swap(MyAlloc&, OtherAlloc&, traits_false_type) { /* NO SWAP */ }
70 
71 #if __TBB_ALLOCATOR_TRAITS_PRESENT
72 using std::allocator_traits;
73 #else
74 template<typename Alloc>
78  // C++03 allocator doesn't have to be assignable or swappable, therefore
79  // define these traits as false_type to do not require additional operations
80  // that are not supposed to be in.
84 
85  typedef Alloc allocator_type;
87 
88  typedef typename allocator_type::pointer pointer;
89  typedef typename allocator_type::const_pointer const_pointer;
90  typedef typename allocator_type::difference_type difference_type;
91  typedef typename allocator_type::size_type size_type;
92 
93  template <typename U> struct rebind_alloc {
94  typedef typename Alloc::template rebind<U>::other other;
95  };
96 };
97 #endif // __TBB_ALLOCATOR_TRAITS_PRESENT
98 
101 template<typename Alloc, typename T>
103 #if __TBB_ALLOCATOR_TRAITS_PRESENT
104  typedef typename allocator_traits<Alloc>::template rebind_alloc<T> type;
105 #else
107 #endif
108 };
109 
110 }} // namespace tbb::internal
111 
112 #endif // __TBB_allocator_traits_H
113 
allocator_type::difference_type difference_type
tbb::internal::false_type propagate_on_container_move_assignment
allocator_type::const_pointer const_pointer
bool_constant< true > true_type
Definition: tbb_stddef.h:472
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
void swap(atomic< T > &lhs, atomic< T > &rhs)
Definition: atomic.h:539
allocator_type::pointer pointer
allocator_type::value_type value_type
tbb::internal::false_type propagate_on_container_swap
The graph class.
tbb::internal::true_type traits_true_type
void allocator_move_assignment(MyAlloc &my_allocator, OtherAlloc &other_allocator, traits_true_type)
Alloc::template rebind< U >::other other
allocator_traits< Alloc >::template rebind_alloc< T >::other type
tbb::internal::false_type propagate_on_container_copy_assignment
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:309
void allocator_swap(MyAlloc &my_allocator, OtherAlloc &other_allocator, traits_true_type)
tbb::internal::false_type traits_false_type
bool_constant< false > false_type
Definition: tbb_stddef.h:473
allocator_type::size_type size_type

Copyright © 2005-2019 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.