Skip to content

Commit 54a3d15

Browse files
committed
Change tuple_size/tuple_element pair specializations to use const.
1 parent 20f1c6a commit 54a3d15

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

testing/pair.cu

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ void TestPairTupleSize(void)
218218
{
219219
int result = thrust::tuple_size< thrust::pair<int,int> >::value;
220220
ASSERT_EQUAL(2, result);
221+
222+
// test const pair
223+
int const_result = thrust::tuple_size< thrust::pair<int,int> const >::value;
224+
ASSERT_EQUAL(2, const_result);
221225
};
222226
DECLARE_UNITTEST(TestPairTupleSize);
223227

@@ -229,6 +233,13 @@ void TestPairTupleElement(void)
229233

230234
ASSERT_EQUAL_QUIET(typeid(int), typeid(type0));
231235
ASSERT_EQUAL_QUIET(typeid(float), typeid(type1));
236+
237+
// test const pair
238+
typedef thrust::tuple_element<0, thrust::pair<int, float> const>::type const_type0;
239+
typedef thrust::tuple_element<1, thrust::pair<int, float> const>::type const_type1;
240+
241+
ASSERT_EQUAL_QUIET(typeid(int const), typeid(const_type0));
242+
ASSERT_EQUAL_QUIET(typeid(float const), typeid(const_type1));
232243
};
233244
DECLARE_UNITTEST(TestPairTupleElement);
234245

thrust/detail/pair.inl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,21 @@ template <typename T1, typename T2>
140140

141141
// specializations of tuple_element for pair
142142
template<typename T1, typename T2>
143-
struct tuple_element<0, pair<T1,T2> >
143+
struct tuple_element<0, const pair<T1,T2> >
144144
{
145145
typedef T1 type;
146146
}; // end tuple_element
147147

148148
template<typename T1, typename T2>
149-
struct tuple_element<1, pair<T1,T2> >
149+
struct tuple_element<1, const pair<T1,T2> >
150150
{
151151
typedef T2 type;
152152
}; // end tuple_element
153153

154154

155155
// specialization of tuple_size for pair
156156
template<typename T1, typename T2>
157-
struct tuple_size< pair<T1,T2 > >
157+
struct tuple_size< const pair<T1,T2 > >
158158
{
159159
static const unsigned int value = 2;
160160
}; // end tuple_size

0 commit comments

Comments
 (0)