[libcxx-commits] [libcxx] 416b156 - [libcxx] Remove swap for std::span

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 20 11:34:30 PDT 2020


Author: Jan Wilken Dörrie
Date: 2020-05-20T14:34:21-04:00
New Revision: 416b1560c597455dfae9e58d2a249d4061d729bf

URL: https://github.com/llvm/llvm-project/commit/416b1560c597455dfae9e58d2a249d4061d729bf
DIFF: https://github.com/llvm/llvm-project/commit/416b1560c597455dfae9e58d2a249d4061d729bf.diff

LOG: [libcxx] Remove swap for std::span

This change removes both the member function swap and the free function
overload of swap for std::span. While swap is a member and overloaded
for every other container in the standard library [1], it is neither a
member function nor a free function overload for std::span [2].
Thus the corresponding implementation should be removed.

[1] https://eel.is/c++draft/libraryindex#:swap
[2] https://eel.is/c++draft/span.overview

Differential Revision: https://reviews.llvm.org/D69827

Added: 
    

Modified: 
    libcxx/include/span

Removed: 
    


################################################################################
diff  --git a/libcxx/include/span b/libcxx/include/span
index 7ae0bdbd06b3..b307c98aee20 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -343,13 +343,6 @@ public:
     _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator        rbegin() const noexcept { return reverse_iterator(end()); }
     _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator          rend() const noexcept { return reverse_iterator(begin()); }
 
-    _LIBCPP_INLINE_VISIBILITY constexpr void swap(span &__other) noexcept
-    {
-        pointer __p = __data;
-        __data = __other.__data;
-        __other.__data = __p;
-    }
-
     _LIBCPP_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noexcept
     { return span<const byte, _Extent * sizeof(element_type)>{reinterpret_cast<const byte *>(data()), size_bytes()}; }
 
@@ -509,17 +502,6 @@ public:
     _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator        rbegin() const noexcept { return reverse_iterator(end()); }
     _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator          rend() const noexcept { return reverse_iterator(begin()); }
 
-    _LIBCPP_INLINE_VISIBILITY constexpr void swap(span &__other) noexcept
-    {
-        pointer __p = __data;
-        __data = __other.__data;
-        __other.__data = __p;
-
-        size_type __sz = __size;
-        __size = __other.__size;
-        __other.__size = __sz;
-    }
-
     _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept
     { return {reinterpret_cast<const byte *>(data()), size_bytes()}; }
 
@@ -544,12 +526,6 @@ auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept
 -> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())>
 { return __s.__as_writable_bytes(); }
 
-template <class _Tp, size_t _Extent>
-_LIBCPP_INLINE_VISIBILITY
-constexpr void swap(span<_Tp, _Extent> &__lhs, span<_Tp, _Extent> &__rhs) noexcept
-{ __lhs.swap(__rhs); }
-
-
 //  Deduction guides
 template<class _Tp, size_t _Sz>
     span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;


        


More information about the libcxx-commits mailing list