Fix FixedArray iterator constructor, which should require input_iterator, not forward_iterator PiperOrigin-RevId: 850356318 Change-Id: If728cc6f4c0eedd4729b73860df8498f4fe6a139
diff --git a/absl/container/fixed_array.h b/absl/container/fixed_array.h index b08735f..d47b0e4 100644 --- a/absl/container/fixed_array.h +++ b/absl/container/fixed_array.h
@@ -84,11 +84,9 @@ static constexpr size_t kInlineBytesDefault = 256; using AllocatorTraits = std::allocator_traits<A>; - // std::iterator_traits isn't guaranteed to be SFINAE-friendly until C++17, - // but this seems to be mostly pedantic. template <typename Iterator> - using EnableIfForwardIterator = std::enable_if_t< - base_internal::IsAtLeastForwardIterator<Iterator>::value>; + using EnableIfInputIterator = + std::enable_if_t<base_internal::IsAtLeastInputIterator<Iterator>::value>; static constexpr bool NoexceptCopyable() { return std::is_nothrow_copy_constructible<StorageElement>::value && absl::allocator_is_nothrow<allocator_type>::value; @@ -161,8 +159,8 @@ // Creates an array initialized with the elements from the input // range. The array's size will always be `std::distance(first, last)`. - // REQUIRES: Iterator must be a forward_iterator or better. - template <typename Iterator, EnableIfForwardIterator<Iterator>* = nullptr> + // REQUIRES: Iterator must be a input_iterator or better. + template <typename Iterator, EnableIfInputIterator<Iterator>* = nullptr> FixedArray(Iterator first, Iterator last, const allocator_type& a = allocator_type()) : storage_(std::distance(first, last), a) {