mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-01 09:18:45 +00:00
[ADT] Change iterator_adaptor_base's default template arguments to forward more underlying typedefs
Reviewers: chandlerc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23217 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278157 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b2b51a4ba6
commit
2962e3e6b2
@ -155,7 +155,14 @@ template <
|
||||
typename T = typename std::iterator_traits<WrappedIteratorT>::value_type,
|
||||
typename DifferenceTypeT =
|
||||
typename std::iterator_traits<WrappedIteratorT>::difference_type,
|
||||
typename PointerT = T *, typename ReferenceT = T &,
|
||||
typename PointerT = typename std::conditional<
|
||||
std::is_same<T, typename std::iterator_traits<
|
||||
WrappedIteratorT>::value_type>::value,
|
||||
typename std::iterator_traits<WrappedIteratorT>::pointer, T *>::type,
|
||||
typename ReferenceT = typename std::conditional<
|
||||
std::is_same<T, typename std::iterator_traits<
|
||||
WrappedIteratorT>::value_type>::value,
|
||||
typename std::iterator_traits<WrappedIteratorT>::reference, T &>::type,
|
||||
// Don't provide these, they are mostly to act as aliases below.
|
||||
typename WrappedTraitsT = std::iterator_traits<WrappedIteratorT>>
|
||||
class iterator_adaptor_base
|
||||
|
@ -16,6 +16,24 @@ using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
template <int> struct Shadow;
|
||||
|
||||
struct WeirdIter : std::iterator<std::input_iterator_tag, Shadow<0>, Shadow<1>,
|
||||
Shadow<2>, Shadow<3>> {};
|
||||
|
||||
struct AdaptedIter : iterator_adaptor_base<AdaptedIter, WeirdIter> {};
|
||||
|
||||
// Test that iterator_adaptor_base forwards typedefs, if value_type is
|
||||
// unchanged.
|
||||
static_assert(std::is_same<typename AdaptedIter::value_type, Shadow<0>>::value,
|
||||
"");
|
||||
static_assert(
|
||||
std::is_same<typename AdaptedIter::difference_type, Shadow<1>>::value, "");
|
||||
static_assert(std::is_same<typename AdaptedIter::pointer, Shadow<2>>::value,
|
||||
"");
|
||||
static_assert(std::is_same<typename AdaptedIter::reference, Shadow<3>>::value,
|
||||
"");
|
||||
|
||||
TEST(PointeeIteratorTest, Basic) {
|
||||
int arr[4] = { 1, 2, 3, 4 };
|
||||
SmallVector<int *, 4> V;
|
||||
|
Loading…
Reference in New Issue
Block a user