diff options
author | Daniel Sanders <daniel_l_sanders@apple.com> | 2019-02-20 18:08:48 +0000 |
---|---|---|
committer | Daniel Sanders <daniel_l_sanders@apple.com> | 2019-02-20 18:08:48 +0000 |
commit | 9e302c6231ea3053281d731668c48078d5a0641b (patch) | |
tree | 997205f6961f96d84affcd5cba347a4b4d281ac1 /llvm/include | |
parent | 3316eb5bb8025e67415796f657bfae5e5374afae (diff) | |
download | bcm5719-llvm-9e302c6231ea3053281d731668c48078d5a0641b.tar.gz bcm5719-llvm-9e302c6231ea3053281d731668c48078d5a0641b.zip |
Add partial implementation of std::to_address() as llvm::to_address()
Summary:
Following on from the review for D58088, this patch provides the
prerequisite to_address() implementation that's needed to have
pointer_iterator support unique_ptr.
The late bound return should be removed once we move to C++14 to better
align with the C++20 declaration. Also, this implementation can be removed
once we move to C++20 where it's defined as std::to_addres()
The std::pointer_traits<>::to_address(p) variations of these overloads has
not been implemented.
Reviewers: dblaikie, paquette
Reviewed By: dblaikie
Subscribers: dexonsmith, kristina, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58421
llvm-svn: 354491
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/ADT/STLExtras.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h index 9a891d193e6..abc23b71d51 100644 --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -1576,6 +1576,19 @@ bool hasNItemsOrMore( return true; } +/// Returns a raw pointer that represents the same address as the argument. +/// +/// The late bound return should be removed once we move to C++14 to better +/// align with the C++20 declaration. Also, this implementation can be removed +/// once we move to C++20 where it's defined as std::to_addres() +/// +/// The std::pointer_traits<>::to_address(p) variations of these overloads has +/// not been implemented. +template <class Ptr> auto to_address(const Ptr &P) -> decltype(P.operator->()) { + return P.operator->(); +} +template <class T> constexpr T *to_address(T *P) { return P; } + } // end namespace llvm #endif // LLVM_ADT_STLEXTRAS_H |