Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit eb3cecd

Browse files
Merge pull request #728 from igchor/merge_stable_1.7_into_stable_1.8
Merge stable 1.7 into stable 1.8
2 parents 13edd10 + 3d585d1 commit eb3cecd

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

include/libpmemobj++/container/detail/contiguous_iterator.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2019, Intel Corporation
2+
* Copyright 2018-2020, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -175,7 +175,7 @@ struct contiguous_iterator {
175175
/**
176176
* Element access operator.
177177
*/
178-
Reference operator[](std::size_t n)
178+
Reference operator[](std::ptrdiff_t n)
179179
{
180180
return ptr[n];
181181
}
@@ -259,7 +259,7 @@ struct range_snapshotting_iterator
259259
*
260260
* Adds element to a transaction.
261261
*/
262-
reference operator[](std::size_t n)
262+
reference operator[](std::ptrdiff_t n)
263263
{
264264
detail::conditional_add_to_tx(&this->ptr[n], 1,
265265
POBJ_XADD_ASSUME_INITIALIZED);
@@ -409,7 +409,7 @@ struct basic_contiguous_iterator
409409
*
410410
* Adds range containing specified element to a transaction.
411411
*/
412-
reference operator[](std::size_t n)
412+
reference operator[](std::ptrdiff_t n)
413413
{
414414
detail::conditional_add_to_tx(&this->ptr[n], 1,
415415
POBJ_XADD_ASSUME_INITIALIZED);

include/libpmemobj++/slice.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2019, Intel Corporation
2+
* Copyright 2018-2020, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -134,7 +134,8 @@ class slice {
134134
if (idx >= size())
135135
throw std::out_of_range("pmem::obj::slice");
136136

137-
return it_begin[idx];
137+
return it_begin[static_cast<typename std::iterator_traits<
138+
Iterator>::difference_type>(idx)];
138139
}
139140

140141
/**
@@ -143,7 +144,8 @@ class slice {
143144
*/
144145
reference operator[](size_type idx)
145146
{
146-
return it_begin[idx];
147+
return it_begin[static_cast<typename std::iterator_traits<
148+
Iterator>::difference_type>(idx)];
147149
}
148150

149151
size_type

tests/array_iterator/array_iterator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2019, Intel Corporation
2+
* Copyright 2018-2020, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -64,7 +64,7 @@ struct Test1 {
6464

6565
swap(it, it2);
6666

67-
it2[c.size() - 1] = 10;
67+
it2[static_cast<std::ptrdiff_t>(c.size() - 1)] = 10;
6868
it[20] = 20;
6969

7070
UT_ASSERT(c[c.size() - 1] == 10);

0 commit comments

Comments
 (0)