1 /*
2     Copyright (c) 2005-2021 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 #ifndef __TBB_detail__containers_helpers_H
18 #define __TBB_detail__containers_helpers_H
19 
20 #include "_template_helpers.h"
21 #include "_allocator_traits.h"
22 #include <type_traits>
23 #include <memory>
24 #include <functional>
25 
26 namespace tbb {
27 namespace detail {
28 inline namespace d0 {
29 
30 template <typename Compare, typename = void>
31 struct comp_is_transparent : std::false_type {};
32 
33 template <typename Compare>
34 struct comp_is_transparent<Compare, tbb::detail::void_t<typename Compare::is_transparent>> : std::true_type {};
35 
36 template <typename Key, typename Hasher, typename KeyEqual, typename = void >
37 struct has_transparent_key_equal : std::false_type { using type = KeyEqual; };
38 
39 template <typename Key, typename Hasher, typename KeyEqual>
40 struct has_transparent_key_equal<Key, Hasher, KeyEqual, tbb::detail::void_t<typename Hasher::transparent_key_equal>> : std::true_type {
41     using type = typename Hasher::transparent_key_equal;
42     static_assert(comp_is_transparent<type>::value, "Hash::transparent_key_equal::is_transparent is not valid or does not denote a type.");
43     static_assert((std::is_same<KeyEqual, std::equal_to<Key>>::value ||
44         std::is_same<typename Hasher::transparent_key_equal, KeyEqual>::value), "KeyEqual is a different type than equal_to<Key> or Hash::transparent_key_equal.");
45  };
46 
47 struct is_iterator_impl {
48 template <typename T>
49 using iter_traits_category = typename std::iterator_traits<T>::iterator_category;
50 
51 template <typename T>
52 using input_iter_category = typename std::enable_if<std::is_base_of<std::input_iterator_tag, iter_traits_category<T>>::value>::type;
53 }; // struct is_iterator_impl
54 
55 template <typename T>
56 using is_input_iterator = supports<T, is_iterator_impl::iter_traits_category, is_iterator_impl::input_iter_category>;
57 
58 #if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
59 template <typename T>
60 inline constexpr bool is_input_iterator_v = is_input_iterator<T>::value;
61 #endif
62 
63 } // inline namespace d0
64 } // namespace detail
65 } // namespace tbb
66 
67 #endif // __TBB_detail__containers_helpers_H
68