Skip to content

Commit 849e749

Browse files
committed
[libc++][NFC] Remove several redundant #if _LIBCPP_STD_VER > 17 in <span>
It turns out that the whole header is only enabled in C++20 and above, so these checks were redundant (and always true). Differential Revision: https://reviews.llvm.org/D121604
1 parent 294eca3 commit 849e749

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

libcxx/include/span

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
158158
inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
159159
template <typename _Tp, size_t _Extent = dynamic_extent> class span;
160160

161-
162161
template <class _Tp>
163162
struct __is_std_array : false_type {};
164163

@@ -171,7 +170,7 @@ struct __is_std_span : false_type {};
171170
template <class _Tp, size_t _Sz>
172171
struct __is_std_span<span<_Tp, _Sz>> : true_type {};
173172

174-
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
173+
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
175174
template <class _Range, class _ElementType>
176175
concept __span_compatible_range =
177176
ranges::contiguous_range<_Range> &&
@@ -181,7 +180,7 @@ concept __span_compatible_range =
181180
!__is_std_array<remove_cvref_t<_Range>>::value &&
182181
!is_array_v<remove_cvref_t<_Range>> &&
183182
is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
184-
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
183+
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
185184

186185
template <typename _Tp, size_t _Extent>
187186
class _LIBCPP_TEMPLATE_VIS span {
@@ -211,7 +210,6 @@ public:
211210
constexpr span (const span&) noexcept = default;
212211
constexpr span& operator=(const span&) noexcept = default;
213212

214-
#if _LIBCPP_STD_VER > 17
215213
template <class _It,
216214
enable_if_t<contiguous_iterator<_It> &&
217215
is_convertible_v<remove_reference_t<iter_reference_t<_It>>(*)[], element_type (*)[]>,
@@ -235,7 +233,6 @@ public:
235233
_LIBCPP_ASSERT(__last - __first == _Extent,
236234
"invalid range in span's constructor (iterator, sentinel): last - first != extent");
237235
}
238-
#endif // _LIBCPP_STD_VER > 17
239236

240237
_LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {}
241238

@@ -249,13 +246,13 @@ public:
249246
_LIBCPP_INLINE_VISIBILITY
250247
constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
251248

252-
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
249+
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
253250
template <__span_compatible_range<element_type> _Range>
254251
_LIBCPP_INLINE_VISIBILITY
255252
constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} {
256253
_LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");
257254
}
258-
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
255+
#endif
259256

260257
template <class _OtherElementType>
261258
_LIBCPP_INLINE_VISIBILITY
@@ -402,7 +399,6 @@ public:
402399
constexpr span (const span&) noexcept = default;
403400
constexpr span& operator=(const span&) noexcept = default;
404401

405-
#if _LIBCPP_STD_VER > 17
406402
template <class _It,
407403
enable_if_t<contiguous_iterator<_It> &&
408404
is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]>,
@@ -419,7 +415,6 @@ public:
419415
_LIBCPP_INLINE_VISIBILITY
420416
constexpr span(_It __first, _End __last)
421417
: __data(_VSTD::to_address(__first)), __size(__last - __first) {}
422-
#endif // _LIBCPP_STD_VER > 17
423418

424419
template <size_t _Sz>
425420
_LIBCPP_INLINE_VISIBILITY
@@ -435,11 +430,11 @@ public:
435430
_LIBCPP_INLINE_VISIBILITY
436431
constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
437432

438-
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
433+
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
439434
template <__span_compatible_range<element_type> _Range>
440435
_LIBCPP_INLINE_VISIBILITY
441436
constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}
442-
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
437+
#endif
443438

444439
template <class _OtherElementType, size_t _OtherExtent>
445440
_LIBCPP_INLINE_VISIBILITY
@@ -544,13 +539,11 @@ private:
544539
size_type __size;
545540
};
546541

547-
#if _LIBCPP_STD_VER > 17
548542
template <class _Tp, size_t _Extent>
549543
inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true;
550544

551545
template <class _ElementType, size_t _Extent>
552546
inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true;
553-
#endif // _LIBCPP_STD_VER > 17
554547

555548
// as_bytes & as_writable_bytes
556549
template <class _Tp, size_t _Extent>
@@ -579,7 +572,7 @@ template<class _Tp, size_t _Sz>
579572
template<class _Tp, size_t _Sz>
580573
span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
581574

582-
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
575+
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
583576
template<ranges::contiguous_range _Range>
584577
span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;
585578
#endif

0 commit comments

Comments
 (0)