/* * Copyright 2008-2018 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // allocator_traits::rebind_alloc and allocator::rebind_traits are from libc++, // dual licensed under the MIT and the University of Illinois Open Source // Licenses. #pragma once #include #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) # pragma GCC system_header #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) # pragma clang system_header #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) # pragma system_header #endif // no system header #include #include #include #include #include THRUST_NAMESPACE_BEGIN namespace detail { // forward declaration for has_member_system template struct allocator_system; namespace allocator_traits_detail { __THRUST_DEFINE_HAS_NESTED_TYPE(has_value_type, value_type) __THRUST_DEFINE_HAS_NESTED_TYPE(has_pointer, pointer) __THRUST_DEFINE_HAS_NESTED_TYPE(has_const_pointer, const_pointer) __THRUST_DEFINE_HAS_NESTED_TYPE(has_reference, reference) __THRUST_DEFINE_HAS_NESTED_TYPE(has_const_reference, const_reference) __THRUST_DEFINE_HAS_NESTED_TYPE(has_void_pointer, void_pointer) __THRUST_DEFINE_HAS_NESTED_TYPE(has_const_void_pointer, const_void_pointer) __THRUST_DEFINE_HAS_NESTED_TYPE(has_difference_type, difference_type) __THRUST_DEFINE_HAS_NESTED_TYPE(has_size_type, size_type) __THRUST_DEFINE_HAS_NESTED_TYPE(has_propagate_on_container_copy_assignment, propagate_on_container_copy_assignment) __THRUST_DEFINE_HAS_NESTED_TYPE(has_propagate_on_container_move_assignment, propagate_on_container_move_assignment) __THRUST_DEFINE_HAS_NESTED_TYPE(has_propagate_on_container_swap, propagate_on_container_swap) __THRUST_DEFINE_HAS_NESTED_TYPE(has_system_type, system_type) __THRUST_DEFINE_HAS_NESTED_TYPE(has_is_always_equal, is_always_equal) __THRUST_DEFINE_HAS_MEMBER_FUNCTION(has_member_system_impl, system) template struct has_rebind { typedef char yes_type; typedef int no_type; template static yes_type test(typename S::template rebind::other*); template static no_type test(...); static bool const value = sizeof(test(0)) == sizeof(yes_type); typedef thrust::detail::integral_constant type; }; _CCCL_SUPPRESS_DEPRECATED_PUSH // The following fields of std::allocator have been deprecated (since C++17). // There's no way to detect it other than explicit specialization. #if _CCCL_STD_VER >= 2017 # define THRUST_SPECIALIZE_DEPRECATED(trait_name) \ template \ struct trait_name> : false_type \ {}; THRUST_SPECIALIZE_DEPRECATED(has_is_always_equal) THRUST_SPECIALIZE_DEPRECATED(has_pointer) THRUST_SPECIALIZE_DEPRECATED(has_const_pointer) THRUST_SPECIALIZE_DEPRECATED(has_reference) THRUST_SPECIALIZE_DEPRECATED(has_const_reference) # undef THRUST_SPECIALIZE_DEPRECATED template struct has_rebind, U> : false_type {}; #endif template struct nested_pointer { typedef typename T::pointer type; }; template struct nested_const_pointer { typedef typename T::const_pointer type; }; template struct nested_reference { typedef typename T::reference type; }; template struct nested_const_reference { typedef typename T::const_reference type; }; template struct nested_void_pointer { typedef typename T::void_pointer type; }; template struct nested_const_void_pointer { typedef typename T::const_void_pointer type; }; template struct nested_difference_type { typedef typename T::difference_type type; }; template struct nested_size_type { typedef typename T::size_type type; }; template struct nested_propagate_on_container_copy_assignment { typedef typename T::propagate_on_container_copy_assignment type; }; template struct nested_propagate_on_container_move_assignment { typedef typename T::propagate_on_container_move_assignment type; }; template struct nested_propagate_on_container_swap { typedef typename T::propagate_on_container_swap type; }; template struct nested_is_always_equal { typedef typename T::is_always_equal type; }; template struct nested_system_type { typedef typename T::system_type type; }; template struct has_member_system { typedef typename allocator_system::type system_type; typedef typename has_member_system_impl::type type; static const bool value = type::value; }; _CCCL_SUPPRESS_DEPRECATED_POP template ::value> struct rebind_alloc { typedef typename Alloc::template rebind::other type; }; template