[PATCH] D30608: Make SmallPtrSet count and find able to take const PtrType's
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 7 10:59:48 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297180: Make SmallPtrSet count and find able to take const PtrType's (authored by dannyb).
Changed prior to commit:
https://reviews.llvm.org/D30608?vs=90581&id=90888#toc
Repository:
rL LLVM
https://reviews.llvm.org/D30608
Files:
llvm/trunk/include/llvm/ADT/SmallPtrSet.h
Index: llvm/trunk/include/llvm/ADT/SmallPtrSet.h
===================================================================
--- llvm/trunk/include/llvm/ADT/SmallPtrSet.h
+++ llvm/trunk/include/llvm/ADT/SmallPtrSet.h
@@ -18,6 +18,7 @@
#include "llvm/Config/abi-breaking.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/PointerLikeTypeTraits.h"
+#include "llvm/Support/type_traits.h"
#include <cassert>
#include <cstddef>
#include <cstring>
@@ -343,7 +344,9 @@
/// to avoid encoding a particular small size in the interface boundary.
template <typename PtrType>
class SmallPtrSetImpl : public SmallPtrSetImplBase {
+ using ConstPtrType = typename add_const_past_pointer<PtrType>::type;
typedef PointerLikeTypeTraits<PtrType> PtrTraits;
+ typedef PointerLikeTypeTraits<ConstPtrType> ConstPtrTraits;
protected:
// Constructors that forward to the base.
@@ -375,13 +378,12 @@
bool erase(PtrType Ptr) {
return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
}
-
/// count - Return 1 if the specified pointer is in the set, 0 otherwise.
- size_type count(PtrType Ptr) const {
+ size_type count(ConstPtrType Ptr) const {
return find(Ptr) != endPtr() ? 1 : 0;
}
- iterator find(PtrType Ptr) const {
- auto *P = find_imp(PtrTraits::getAsVoidPointer(Ptr));
+ iterator find(ConstPtrType Ptr) const {
+ auto *P = find_imp(ConstPtrTraits::getAsVoidPointer(Ptr));
return iterator(P, EndPointer());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30608.90888.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170307/f0bed25c/attachment.bin>
More information about the llvm-commits
mailing list