Skip to content

Commit 69f6000

Browse files
committed
[opt-transform-range] Do not assume that Range::iterator exists.
The reason not to do this is that some important range adapters (e.x. llvm::iterator_range) do not have such a typedef. Rather than changing upstream this commit just fixes the problem by inferring the iterator type from the result of Range::begin(). TLDR: This makes OptionalTransformRange work with llvm::iterator_range.
1 parent 07bcf5a commit 69f6000

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/swift/Basic/STLExtras.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ makeOptionalTransformIterator(Iterator current, Iterator end,
611611

612612
/// A range filtered and transformed by the optional transform.
613613
template <typename Range, typename OptionalTransform,
614-
typename Iterator = typename Range::iterator>
614+
typename Iterator = decltype(std::declval<Range>().begin())>
615615
class OptionalTransformRange {
616616

617617
Iterator First, Last;

0 commit comments

Comments
 (0)