[PATCH] D58088: [adt] Add raw_pointer_iterator to iterate over std::unique_ptr<> collections
Glen Fernandes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 20 17:29:38 PST 2019
glenjofe added a comment.
> That looks simple enough. I haven't gone through the spec but something as simple as:
>
> namespace llvm {
> template<class Ptr>
> auto to_address(const Ptr &P) noexcept { return P.operator->(); }
> template<class T>
> constexpr T* to_address(T* P) noexcept { return P; }
> }
>
>
> seems to cover the majority of it (and definitely the bits I need). It's just the std::pointer_traits<Ptr>::to_address(p) based implementation of the fancy pointer overload that's missing.
If it is named `to_address` and intended to convert any pointer to a raw pointer then it should be:
namespace llvm {
template<class T>
constexpr T* to_address(T* p) noexcept { return p; }
template<class Ptr>
typename std::pointer_traits<Ptr>::element_type* to_address(const Ptr &p) noexcept { return llvm::to_address(p.operator->()); }
}
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58088/new/
https://reviews.llvm.org/D58088
More information about the llvm-commits
mailing list