Skip to content

Commit fec72d2

Browse files
committedSep 20, 2018
Fix DenseSet::ConstIterator typedefs
Fix DenseSet::ConstIterator pointer/reference typedefs to be const Patch by Brad Moody! Differential Revision: https://reviews.llvm.org/D52260 llvm-svn: 342697
1 parent e590943 commit fec72d2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
 

‎llvm/include/llvm/ADT/DenseSet.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ class DenseSetImpl {
136136
public:
137137
using difference_type = typename MapTy::const_iterator::difference_type;
138138
using value_type = ValueT;
139-
using pointer = value_type *;
140-
using reference = value_type &;
139+
using pointer = const value_type *;
140+
using reference = const value_type &;
141141
using iterator_category = std::forward_iterator_tag;
142142

143143
ConstIterator() = default;

‎llvm/unittests/ADT/DenseSetTest.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ using namespace llvm;
1515

1616
namespace {
1717

18+
static_assert(std::is_const<std::remove_pointer<
19+
DenseSet<int>::const_iterator::pointer>::type>::value,
20+
"Iterator pointer type should be const");
21+
static_assert(std::is_const<std::remove_reference<
22+
DenseSet<int>::const_iterator::reference>::type>::value,
23+
"Iterator reference type should be const");
24+
1825
// Test hashing with a set of only two entries.
1926
TEST(DenseSetTest, DoubleEntrySetTest) {
2027
llvm::DenseSet<unsigned> set(2);

0 commit comments

Comments
 (0)
Please sign in to comment.