From df1c971e39e245cda39d4a2e63934dd2da5bb462 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Sat, 28 Oct 2017 00:24:26 +0000 Subject: [PATCH] [ADT] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). llvm-svn: 316818 --- include/llvm/ADT/FoldingSet.h | 44 ++++------- include/llvm/ADT/PointerIntPair.h | 31 +++++--- include/llvm/ADT/PointerSumType.h | 50 ++++++------ include/llvm/ADT/PointerUnion.h | 79 ++++++++++--------- include/llvm/ADT/STLExtras.h | 124 ++++++++++++++++-------------- include/llvm/ADT/Twine.h | 54 ++++++------- 6 files changed, 196 insertions(+), 186 deletions(-) diff --git a/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h index c5987a947e1..e363e69d032 100644 --- a/include/llvm/ADT/FoldingSet.h +++ b/include/llvm/ADT/FoldingSet.h @@ -1,4 +1,4 @@ -//===-- llvm/ADT/FoldingSet.h - Uniquing Hash Set ---------------*- C++ -*-===// +//===- llvm/ADT/FoldingSet.h - Uniquing Hash Set ----------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -115,11 +115,9 @@ class FoldingSetBase { protected: /// Buckets - Array of bucket chains. - /// void **Buckets; /// NumBuckets - Length of the Buckets array. Always a power of 2. - /// unsigned NumBuckets; /// NumNodes - Number of nodes in the folding set. Growth occurs when NumNodes @@ -135,14 +133,13 @@ public: //===--------------------------------------------------------------------===// /// Node - This class is used to maintain the singly linked bucket list in /// a folding set. - /// class Node { private: // NextInFoldingSetBucket - next link in the bucket list. - void *NextInFoldingSetBucket; + void *NextInFoldingSetBucket = nullptr; public: - Node() : NextInFoldingSetBucket(nullptr) {} + Node() = default; // Accessors void *getNextInBucket() const { return NextInFoldingSetBucket; } @@ -221,7 +218,6 @@ protected: /// DefaultFoldingSetTrait - This class provides default implementations /// for FoldingSetTrait implementations. -/// template struct DefaultFoldingSetTrait { static void Profile(const T &X, FoldingSetNodeID &ID) { X.Profile(ID); @@ -307,7 +303,6 @@ public: /// FoldingSetNodeID - This class is used to gather all the unique data bits of /// a node. When all the bits are gathered this class is used to produce a /// hash value for the node. -/// class FoldingSetNodeID { /// Bits - Vector of all the data bits that make the node unique. /// Use a SmallVector to avoid a heap allocation in the common case. @@ -320,7 +315,6 @@ public: : Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {} /// Add* - Add various data types to Bit data. - /// void AddPointer(const void *Ptr); void AddInteger(signed I); void AddInteger(unsigned I); @@ -344,7 +338,6 @@ public: unsigned ComputeHash() const; /// operator== - Used to compare two nodes to each other. - /// bool operator==(const FoldingSetNodeID &RHS) const; bool operator==(const FoldingSetNodeIDRef RHS) const; @@ -363,7 +356,7 @@ public: }; // Convenience type to hide the implementation of the folding set. -typedef FoldingSetBase::Node FoldingSetNode; +using FoldingSetNode = FoldingSetBase::Node; template class FoldingSetIterator; template class FoldingSetBucketIterator; @@ -415,15 +408,17 @@ protected: ~FoldingSetImpl() = default; public: - typedef FoldingSetIterator iterator; + using iterator = FoldingSetIterator; + iterator begin() { return iterator(Buckets); } iterator end() { return iterator(Buckets+NumBuckets); } - typedef FoldingSetIterator const_iterator; + using const_iterator = FoldingSetIterator; + const_iterator begin() const { return const_iterator(Buckets); } const_iterator end() const { return const_iterator(Buckets+NumBuckets); } - typedef FoldingSetBucketIterator bucket_iterator; + using bucket_iterator = FoldingSetBucketIterator; bucket_iterator bucket_begin(unsigned hash) { return bucket_iterator(Buckets + (hash & (NumBuckets-1))); @@ -503,9 +498,7 @@ template class FoldingSet final : public FoldingSetImpl { } public: - explicit FoldingSet(unsigned Log2InitSize = 6) - : Super(Log2InitSize) {} - + explicit FoldingSet(unsigned Log2InitSize = 6) : Super(Log2InitSize) {} FoldingSet(FoldingSet &&Arg) = default; FoldingSet &operator=(FoldingSet &&RHS) = default; }; @@ -552,8 +545,7 @@ class ContextualFoldingSet final : public FoldingSetImpl { public: explicit ContextualFoldingSet(Ctx Context, unsigned Log2InitSize = 6) - : Super(Log2InitSize), Context(Context) - {} + : Super(Log2InitSize), Context(Context) {} Ctx getContext() const { return Context; } }; @@ -569,15 +561,15 @@ class FoldingSetVector { VectorT Vector; public: - explicit FoldingSetVector(unsigned Log2InitSize = 6) - : Set(Log2InitSize) { - } + explicit FoldingSetVector(unsigned Log2InitSize = 6) : Set(Log2InitSize) {} + + using iterator = pointee_iterator; - typedef pointee_iterator iterator; iterator begin() { return Vector.begin(); } iterator end() { return Vector.end(); } - typedef pointee_iterator const_iterator; + using const_iterator = pointee_iterator; + const_iterator begin() const { return Vector.begin(); } const_iterator end() const { return Vector.end(); } @@ -667,15 +659,13 @@ public: /// FoldingSetBucketIteratorImpl - This is the common bucket iterator support /// shared by all folding sets, which knows how to walk a particular bucket /// of a folding set hash table. - class FoldingSetBucketIteratorImpl { protected: void *Ptr; explicit FoldingSetBucketIteratorImpl(void **Bucket); - FoldingSetBucketIteratorImpl(void **Bucket, bool) - : Ptr(Bucket) {} + FoldingSetBucketIteratorImpl(void **Bucket, bool) : Ptr(Bucket) {} void advance() { void *Probe = static_cast(Ptr)->getNextInBucket(); diff --git a/include/llvm/ADT/PointerIntPair.h b/include/llvm/ADT/PointerIntPair.h index eb5a3369900..884d05155bf 100644 --- a/include/llvm/ADT/PointerIntPair.h +++ b/include/llvm/ADT/PointerIntPair.h @@ -14,15 +14,14 @@ #ifndef LLVM_ADT_POINTERINTPAIR_H #define LLVM_ADT_POINTERINTPAIR_H -#include "llvm/Support/Compiler.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include +#include #include namespace llvm { template struct DenseMapInfo; - template struct PointerIntPairInfo; @@ -39,25 +38,24 @@ struct PointerIntPairInfo; /// for something else. For example, this allows: /// PointerIntPair, 1, bool> /// ... and the two bools will land in different bits. -/// template , typename Info = PointerIntPairInfo> class PointerIntPair { - intptr_t Value; + intptr_t Value = 0; public: - constexpr PointerIntPair() : Value(0) {} + constexpr PointerIntPair() = default; + PointerIntPair(PointerTy PtrVal, IntType IntVal) { setPointerAndInt(PtrVal, IntVal); } + explicit PointerIntPair(PointerTy PtrVal) { initWithPointer(PtrVal); } PointerTy getPointer() const { return Info::getPointer(Value); } - IntType getInt() const { - return (IntType)Info::getInt(Value); - } + IntType getInt() const { return (IntType)Info::getInt(Value); } void setPointer(PointerTy PtrVal) { Value = Info::updatePointer(Value, PtrVal); @@ -88,6 +86,7 @@ public: } void *getOpaqueValue() const { return reinterpret_cast(Value); } + void setFromOpaqueValue(void *Val) { Value = reinterpret_cast(Val); } @@ -108,14 +107,18 @@ public: bool operator==(const PointerIntPair &RHS) const { return Value == RHS.Value; } + bool operator!=(const PointerIntPair &RHS) const { return Value != RHS.Value; } + bool operator<(const PointerIntPair &RHS) const { return Value < RHS.Value; } bool operator>(const PointerIntPair &RHS) const { return Value > RHS.Value; } + bool operator<=(const PointerIntPair &RHS) const { return Value <= RHS.Value; } + bool operator>=(const PointerIntPair &RHS) const { return Value >= RHS.Value; } @@ -180,21 +183,25 @@ struct isPodLike> { // Provide specialization of DenseMapInfo for PointerIntPair. template struct DenseMapInfo> { - typedef PointerIntPair Ty; + using Ty = PointerIntPair; + static Ty getEmptyKey() { uintptr_t Val = static_cast(-1); Val <<= PointerLikeTypeTraits::NumLowBitsAvailable; return Ty::getFromOpaqueValue(reinterpret_cast(Val)); } + static Ty getTombstoneKey() { uintptr_t Val = static_cast(-2); Val <<= PointerLikeTypeTraits::NumLowBitsAvailable; return Ty::getFromOpaqueValue(reinterpret_cast(Val)); } + static unsigned getHashValue(Ty V) { uintptr_t IV = reinterpret_cast(V.getOpaqueValue()); return unsigned(IV) ^ unsigned(IV >> 9); } + static bool isEqual(const Ty &LHS, const Ty &RHS) { return LHS == RHS; } }; @@ -207,16 +214,20 @@ struct PointerLikeTypeTraits< getAsVoidPointer(const PointerIntPair &P) { return P.getOpaqueValue(); } + static inline PointerIntPair getFromVoidPointer(void *P) { return PointerIntPair::getFromOpaqueValue(P); } + static inline PointerIntPair getFromVoidPointer(const void *P) { return PointerIntPair::getFromOpaqueValue(P); } + enum { NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits }; }; } // end namespace llvm -#endif + +#endif // LLVM_ADT_POINTERINTPAIR_H diff --git a/include/llvm/ADT/PointerSumType.h b/include/llvm/ADT/PointerSumType.h index 1a49e062dc2..e37957160d9 100644 --- a/include/llvm/ADT/PointerSumType.h +++ b/include/llvm/ADT/PointerSumType.h @@ -11,8 +11,10 @@ #define LLVM_ADT_POINTERSUMTYPE_H #include "llvm/ADT/DenseMapInfo.h" -#include "llvm/Support/Compiler.h" #include "llvm/Support/PointerLikeTypeTraits.h" +#include +#include +#include namespace llvm { @@ -24,16 +26,15 @@ template > struct PointerSumTypeMember { enum { Tag = N }; - typedef PointerArgT PointerT; - typedef TraitsArgT TraitsT; + using PointerT = PointerArgT; + using TraitsT = TraitsArgT; }; namespace detail { -template -struct PointerSumTypeHelper; +template struct PointerSumTypeHelper; -} +} // end namespace detail /// A sum type over pointer-like types. /// @@ -60,12 +61,12 @@ struct PointerSumTypeHelper; /// There is no support for constructing or accessing with a dynamic tag as /// that would fundamentally violate the type safety provided by the sum type. template class PointerSumType { - uintptr_t Value; + uintptr_t Value = 0; - typedef detail::PointerSumTypeHelper HelperT; + using HelperT = detail::PointerSumTypeHelper; public: - constexpr PointerSumType() : Value(0) {} + constexpr PointerSumType() = default; /// A typed constructor for a specific tagged member of the sum type. template @@ -128,14 +129,14 @@ struct PointerSumTypeHelper : MemberTs... { template static void LookupOverload(...); template struct Lookup { // Compute a particular member type by resolving the lookup helper ovorload. - typedef decltype(LookupOverload( - static_cast(nullptr))) MemberT; + using MemberT = decltype( + LookupOverload(static_cast(nullptr))); /// The Nth member's pointer type. - typedef typename MemberT::PointerT PointerT; + using PointerT = typename MemberT::PointerT; /// The Nth member's traits type. - typedef typename MemberT::TraitsT TraitsT; + using TraitsT = typename MemberT::TraitsT; }; // Next we need to compute the number of bits available for the discriminant @@ -171,35 +172,36 @@ struct PointerSumTypeHelper : MemberTs... { "Each member must pass the checker."); }; -} +} // end namespace detail // Teach DenseMap how to use PointerSumTypes as keys. template struct DenseMapInfo> { - typedef PointerSumType SumType; - - typedef detail::PointerSumTypeHelper HelperT; + using SumType = PointerSumType; + using HelperT = detail::PointerSumTypeHelper; enum { SomeTag = HelperT::MinTag }; - typedef typename HelperT::template Lookup::PointerT - SomePointerT; - typedef DenseMapInfo SomePointerInfo; + using SomePointerT = + typename HelperT::template Lookup::PointerT; + using SomePointerInfo = DenseMapInfo; static inline SumType getEmptyKey() { return SumType::create(SomePointerInfo::getEmptyKey()); } + static inline SumType getTombstoneKey() { - return SumType::create( - SomePointerInfo::getTombstoneKey()); + return SumType::create(SomePointerInfo::getTombstoneKey()); } + static unsigned getHashValue(const SumType &Arg) { uintptr_t OpaqueValue = Arg.getOpaqueValue(); return DenseMapInfo::getHashValue(OpaqueValue); } + static bool isEqual(const SumType &LHS, const SumType &RHS) { return LHS == RHS; } }; -} +} // end namespace llvm -#endif +#endif // LLVM_ADT_POINTERSUMTYPE_H diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h index d019edb57e5..4276859e925 100644 --- a/include/llvm/ADT/PointerUnion.h +++ b/include/llvm/ADT/PointerUnion.h @@ -25,7 +25,7 @@ namespace llvm { template struct PointerUnionTypeSelectorReturn { - typedef T Return; + using Return = T; }; /// Get a type based on whether two types are the same or not. @@ -33,25 +33,25 @@ template struct PointerUnionTypeSelectorReturn { /// For: /// /// \code -/// typedef typename PointerUnionTypeSelector::Return Ret; +/// using Ret = typename PointerUnionTypeSelector::Return; /// \endcode /// /// Ret will be EQ type if T1 is same as T2 or NE type otherwise. template struct PointerUnionTypeSelector { - typedef typename PointerUnionTypeSelectorReturn::Return Return; + using Return = typename PointerUnionTypeSelectorReturn::Return; }; template struct PointerUnionTypeSelector { - typedef typename PointerUnionTypeSelectorReturn::Return Return; + using Return = typename PointerUnionTypeSelectorReturn::Return; }; template struct PointerUnionTypeSelectorReturn< PointerUnionTypeSelector> { - typedef - typename PointerUnionTypeSelector::Return Return; + using Return = + typename PointerUnionTypeSelector::Return; }; /// Provide PointerLikeTypeTraits for void* that is used by PointerUnion @@ -86,8 +86,8 @@ public: /// X = P.get(); // runtime assertion failure. template class PointerUnion { public: - typedef PointerIntPair> - ValTy; + using ValTy = + PointerIntPair>; private: ValTy Val; @@ -102,7 +102,6 @@ private: public: PointerUnion() = default; - PointerUnion(PT1 V) : Val(const_cast( PointerLikeTypeTraits::getAsVoidPointer(V))) {} @@ -117,14 +116,15 @@ public: // we recursively strip off low bits if we have a nested PointerUnion. return !PointerLikeTypeTraits::getFromVoidPointer(Val.getPointer()); } + explicit operator bool() const { return !isNull(); } /// Test if the Union currently holds the type matching T. template int is() const { - typedef typename ::llvm::PointerUnionTypeSelector< - PT1, T, IsPT1, ::llvm::PointerUnionTypeSelector< - PT2, T, IsPT2, UNION_DOESNT_CONTAIN_TYPE>>::Return - Ty; + using Ty = typename ::llvm::PointerUnionTypeSelector< + PT1, T, IsPT1, + ::llvm::PointerUnionTypeSelector>>::Return; int TyNo = Ty::Num; return static_cast(Val.getInt()) == TyNo; } @@ -158,7 +158,8 @@ public: assert( get() == Val.getPointer() && "Can't get the address because PointerLikeTypeTraits changes the ptr"); - return const_cast(reinterpret_cast(Val.getAddrOfPointer())); + return const_cast( + reinterpret_cast(Val.getAddrOfPointer())); } /// Assignment from nullptr which just clears the union. @@ -227,19 +228,22 @@ struct PointerLikeTypeTraits> { /// for usage. template class PointerUnion3 { public: - typedef PointerUnion InnerUnion; - typedef PointerUnion ValTy; + using InnerUnion = PointerUnion; + using ValTy = PointerUnion; private: ValTy Val; struct IsInnerUnion { ValTy Val; + IsInnerUnion(ValTy val) : Val(val) {} + template int is() const { return Val.template is() && Val.template get().template is(); } + template T get() const { return Val.template get().template get(); } @@ -247,14 +251,15 @@ private: struct IsPT3 { ValTy Val; + IsPT3(ValTy val) : Val(val) {} + template int is() const { return Val.template is(); } template T get() const { return Val.template get(); } }; public: PointerUnion3() = default; - PointerUnion3(PT1 V) { Val = InnerUnion(V); } PointerUnion3(PT2 V) { Val = InnerUnion(V); } PointerUnion3(PT3 V) { Val = V; } @@ -267,10 +272,9 @@ public: /// Test if the Union currently holds the type matching T. template int is() const { // If T is PT1/PT2 choose IsInnerUnion otherwise choose IsPT3. - typedef typename ::llvm::PointerUnionTypeSelector< + using Ty = typename ::llvm::PointerUnionTypeSelector< PT1, T, IsInnerUnion, - ::llvm::PointerUnionTypeSelector>::Return - Ty; + ::llvm::PointerUnionTypeSelector>::Return; return Ty(Val).template is(); } @@ -280,10 +284,9 @@ public: template T get() const { assert(is() && "Invalid accessor called"); // If T is PT1/PT2 choose IsInnerUnion otherwise choose IsPT3. - typedef typename ::llvm::PointerUnionTypeSelector< + using Ty = typename ::llvm::PointerUnionTypeSelector< PT1, T, IsInnerUnion, - ::llvm::PointerUnionTypeSelector>::Return - Ty; + ::llvm::PointerUnionTypeSelector>::Return; return Ty(Val).template get(); } @@ -348,16 +351,15 @@ struct PointerLikeTypeTraits> { template class PointerUnion4 { public: - typedef PointerUnion InnerUnion1; - typedef PointerUnion InnerUnion2; - typedef PointerUnion ValTy; + using InnerUnion1 = PointerUnion; + using InnerUnion2 = PointerUnion; + using ValTy = PointerUnion; private: ValTy Val; public: PointerUnion4() = default; - PointerUnion4(PT1 V) { Val = InnerUnion1(V); } PointerUnion4(PT2 V) { Val = InnerUnion1(V); } PointerUnion4(PT3 V) { Val = InnerUnion2(V); } @@ -371,9 +373,10 @@ public: /// Test if the Union currently holds the type matching T. template int is() const { // If T is PT1/PT2 choose InnerUnion1 otherwise choose InnerUnion2. - typedef typename ::llvm::PointerUnionTypeSelector< - PT1, T, InnerUnion1, ::llvm::PointerUnionTypeSelector< - PT2, T, InnerUnion1, InnerUnion2>>::Return Ty; + using Ty = typename ::llvm::PointerUnionTypeSelector< + PT1, T, InnerUnion1, + ::llvm::PointerUnionTypeSelector>::Return; return Val.template is() && Val.template get().template is(); } @@ -383,9 +386,10 @@ public: template T get() const { assert(is() && "Invalid accessor called"); // If T is PT1/PT2 choose InnerUnion1 otherwise choose InnerUnion2. - typedef typename ::llvm::PointerUnionTypeSelector< - PT1, T, InnerUnion1, ::llvm::PointerUnionTypeSelector< - PT2, T, InnerUnion1, InnerUnion2>>::Return Ty; + using Ty = typename ::llvm::PointerUnionTypeSelector< + PT1, T, InnerUnion1, + ::llvm::PointerUnionTypeSelector>::Return; return Val.template get().template get(); } @@ -452,18 +456,21 @@ struct PointerLikeTypeTraits> { // Teach DenseMap how to use PointerUnions as keys. template struct DenseMapInfo> { - typedef PointerUnion Pair; - typedef DenseMapInfo FirstInfo; - typedef DenseMapInfo SecondInfo; + using Pair = PointerUnion; + using FirstInfo = DenseMapInfo; + using SecondInfo = DenseMapInfo; static inline Pair getEmptyKey() { return Pair(FirstInfo::getEmptyKey()); } + static inline Pair getTombstoneKey() { return Pair(FirstInfo::getTombstoneKey()); } + static unsigned getHashValue(const Pair &PairVal) { intptr_t key = (intptr_t)PairVal.getOpaqueValue(); return DenseMapInfo::getHashValue(key); } + static bool isEqual(const Pair &LHS, const Pair &RHS) { return LHS.template is() == RHS.template is() && (LHS.template is() ? FirstInfo::isEqual(LHS.template get(), diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 1d1eb601a33..3ec9dfe5de0 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -17,23 +17,24 @@ #ifndef LLVM_ADT_STLEXTRAS_H #define LLVM_ADT_STLEXTRAS_H -#include // for std::all_of -#include -#include // for std::size_t -#include // for qsort -#include -#include -#include -#include -#include -#include // for std::pair - #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" -#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace llvm { @@ -50,7 +51,7 @@ template using ValueOfRange = typename std::remove_reference()))>::type; -} // End detail namespace +} // end namespace detail //===----------------------------------------------------------------------===// // Extra additions to @@ -58,6 +59,7 @@ using ValueOfRange = typename std::remove_reference struct identity { using argument_type = Ty; + Ty &operator()(Ty &self) const { return self; } @@ -88,7 +90,7 @@ template class function_ref; template class function_ref { - Ret (*callback)(intptr_t callable, Params ...params); + Ret (*callback)(intptr_t callable, Params ...params) = nullptr; intptr_t callable; template @@ -98,7 +100,7 @@ class function_ref { } public: - function_ref() : callback(nullptr) {} + function_ref() = default; template function_ref(Callable &&callable, @@ -107,6 +109,7 @@ public: function_ref>::value>::type * = nullptr) : callback(callback_fn::type>), callable(reinterpret_cast(&callable)) {} + Ret operator()(Params ...params) const { return callback(callable, std::forward(params)...); } @@ -118,41 +121,34 @@ public: // delete on something. It is used like this: // // for_each(V.begin(), B.end(), deleter); -// template inline void deleter(T *Ptr) { delete Ptr; } - - //===----------------------------------------------------------------------===// // Extra additions to //===----------------------------------------------------------------------===// // mapped_iterator - This is a simple iterator adapter that causes a function to // be applied whenever operator* is invoked on the iterator. -// template class mapped_iterator { RootIt current; UnaryFunc Fn; + public: - typedef typename std::iterator_traits::iterator_category - iterator_category; - typedef typename std::iterator_traits::difference_type - difference_type; - typedef decltype(std::declval()(*std::declval())) - value_type; + using iterator_category = + typename std::iterator_traits::iterator_category; + using difference_type = + typename std::iterator_traits::difference_type; + using value_type = + decltype(std::declval()(*std::declval())); - typedef void pointer; - //typedef typename UnaryFunc::result_type *pointer; - typedef void reference; // Can't modify value returned by fn + using pointer = void; + using reference = void; // Can't modify value returned by fn - typedef RootIt iterator_type; - - inline const RootIt &getCurrent() const { return current; } - inline const UnaryFunc &getFunc() const { return Fn; } + using iterator_type = RootIt; inline explicit mapped_iterator(const RootIt &I, UnaryFunc F) : current(I), Fn(F) {} @@ -204,6 +200,9 @@ public: difference_type operator-(const mapped_iterator &X) const { return current - X.current; } + + inline const RootIt &getCurrent() const { return current; } + inline const UnaryFunc &getFunc() const { return Fn; } }; template @@ -213,10 +212,8 @@ operator+(typename mapped_iterator::difference_type N, return mapped_iterator(X.getCurrent() - N, X.getFunc()); } - // map_iterator - Provide a convenient way to create mapped_iterators, just like // make_pair is useful for creating pairs... -// template inline mapped_iterator map_iterator(const ItTy &I, FuncTy F) { return mapped_iterator(I, F); @@ -224,8 +221,8 @@ inline mapped_iterator map_iterator(const ItTy &I, FuncTy F) { /// Helper to determine if type T has a member called rbegin(). template class has_rbegin_impl { - typedef char yes[1]; - typedef char no[2]; + using yes = char[1]; + using no = char[2]; template static yes& test(Inner *I, decltype(I->rbegin()) * = nullptr); @@ -363,12 +360,13 @@ template struct index_sequence; template struct index_sequence_for; namespace detail { + using std::declval; // We have to alias this since inlining the actual type at the usage site // in the parameter list of iterator_facade_base<> below ICEs MSVC 2017. template struct ZipTupleType { - typedef std::tuple())...> type; + using type = std::tuple())...>; }; template @@ -454,11 +452,11 @@ class zip_shortest : public zip_common, Iters...> { public: using Base = zip_common, Iters...>; + zip_shortest(Iters &&... ts) : Base(std::forward(ts)...) {} + bool operator==(const zip_shortest &other) const { return !test(other, index_sequence_for{}); } - - zip_shortest(Iters &&... ts) : Base(std::forward(ts)...) {} }; template