2 * Copyright 2008-2013 NVIDIA Corporation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <thrust/detail/config.h>
20 #include <thrust/detail/type_traits/pointer_traits.h>
21 #include <thrust/iterator/iterator_traits.h>
28 template<typename T, typename Tag, typename Pointer> class tagged_allocator;
30 template<typename Tag, typename Pointer>
31 class tagged_allocator<void, Tag, Pointer>
34 typedef void value_type;
35 typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<void>::other pointer;
36 typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<const void>::other const_pointer;
37 typedef std::size_t size_type;
38 typedef typename thrust::detail::pointer_traits<Pointer>::difference_type difference_type;
39 typedef Tag system_type;
44 typedef tagged_allocator<U,Tag,Pointer> other;
48 template<typename T, typename Tag, typename Pointer>
49 class tagged_allocator
53 typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<T>::other pointer;
54 typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<const T>::other const_pointer;
55 typedef typename thrust::iterator_reference<pointer>::type reference;
56 typedef typename thrust::iterator_reference<const_pointer>::type const_reference;
57 typedef std::size_t size_type;
58 typedef typename thrust::detail::pointer_traits<pointer>::difference_type difference_type;
59 typedef Tag system_type;
64 typedef tagged_allocator<U,Tag,Pointer> other;
68 inline tagged_allocator();
71 inline tagged_allocator(const tagged_allocator &);
73 template<typename U, typename OtherPointer>
75 inline tagged_allocator(const tagged_allocator<U, Tag, OtherPointer> &);
78 inline ~tagged_allocator();
81 pointer address(reference x) const;
84 const_pointer address(const_reference x) const;
86 size_type max_size() const;
89 template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
91 bool operator==(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &);
93 template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
95 bool operator!=(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &);
100 #include <thrust/detail/allocator/tagged_allocator.inl>