~ubuntu-branches/ubuntu/trusty/libthrust/trusty

« back to all changes in this revision

Viewing changes to iterator/detail/universal_categories.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Beckmann
  • Date: 2011-05-28 09:32:48 UTC
  • Revision ID: james.westby@ubuntu.com-20110528093248-np3euv5sj7fw3nyv
Tags: upstream-1.4.0
ImportĀ upstreamĀ versionĀ 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright 2008-2011 NVIDIA 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
#pragma once
 
18
 
 
19
#include <thrust/detail/config.h>
 
20
#include <thrust/iterator/iterator_categories.h>
 
21
#include <thrust/iterator/detail/backend_iterator_categories.h>
 
22
 
 
23
namespace thrust
 
24
{
 
25
 
 
26
// define these types without inheritance to avoid ambiguous conversion to base classes
 
27
 
 
28
struct input_universal_iterator_tag
 
29
{
 
30
  operator input_host_iterator_tag () {return input_host_iterator_tag();}
 
31
 
 
32
  operator thrust::detail::input_cuda_device_iterator_tag () {return thrust::detail::input_cuda_device_iterator_tag();}
 
33
 
 
34
  operator detail::input_omp_device_iterator_tag () {return detail::input_omp_device_iterator_tag();}
 
35
};
 
36
 
 
37
struct output_universal_iterator_tag
 
38
{
 
39
  operator output_host_iterator_tag () {return output_host_iterator_tag();}
 
40
 
 
41
  operator detail::output_cuda_device_iterator_tag () {return detail::output_cuda_device_iterator_tag();}
 
42
 
 
43
  operator detail::output_omp_device_iterator_tag () {return detail::output_omp_device_iterator_tag();}
 
44
};
 
45
 
 
46
struct forward_universal_iterator_tag
 
47
  : input_universal_iterator_tag
 
48
{
 
49
  operator forward_host_iterator_tag () {return forward_host_iterator_tag();};
 
50
 
 
51
  operator detail::forward_cuda_device_iterator_tag () {return detail::forward_cuda_device_iterator_tag();};
 
52
 
 
53
  operator detail::forward_omp_device_iterator_tag () {return detail::forward_omp_device_iterator_tag();};
 
54
};
 
55
 
 
56
struct bidirectional_universal_iterator_tag
 
57
  : forward_universal_iterator_tag
 
58
{
 
59
  operator bidirectional_host_iterator_tag () {return bidirectional_host_iterator_tag();};
 
60
 
 
61
  operator detail::bidirectional_cuda_device_iterator_tag () {return detail::bidirectional_cuda_device_iterator_tag();};
 
62
 
 
63
  operator detail::bidirectional_omp_device_iterator_tag () {return detail::bidirectional_omp_device_iterator_tag();};
 
64
};
 
65
 
 
66
 
 
67
namespace detail
 
68
{
 
69
 
 
70
// create this struct to control conversion precedence in random_access_universal_iterator_tag
 
71
template<typename T>
 
72
struct one_degree_of_separation
 
73
  : T
 
74
{
 
75
};
 
76
 
 
77
} // end detail
 
78
 
 
79
 
 
80
struct random_access_universal_iterator_tag
 
81
{
 
82
  // these conversions are all P0
 
83
  operator random_access_host_iterator_tag () {return random_access_host_iterator_tag();};
 
84
 
 
85
  operator random_access_device_iterator_tag () {return random_access_device_iterator_tag();};
 
86
 
 
87
  operator detail::random_access_cuda_device_iterator_tag () {return detail::random_access_cuda_device_iterator_tag();};
 
88
 
 
89
  operator detail::random_access_omp_device_iterator_tag () {return detail::random_access_omp_device_iterator_tag();};
 
90
 
 
91
  // bidirectional_universal_iterator_tag is P1
 
92
  operator detail::one_degree_of_separation<bidirectional_universal_iterator_tag> () {return detail::one_degree_of_separation<bidirectional_universal_iterator_tag>();}
 
93
 
 
94
};
 
95
 
 
96
 
 
97
} // end thrust
 
98