[libcxx-commits] [libcxx] c73a491 - [libcxx][span] Remove tuple interface

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 14 05:26:01 PDT 2020


Author: Michael Schellenberger Costa
Date: 2020-05-14T08:25:49-04:00
New Revision: c73a491d10b8f0258c02385fe14ad0626e8c8efd

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

LOG: [libcxx][span] Remove tuple interface

This implements P2116 by removing the tuple interface from std::span.

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

Added: 
    

Modified: 
    libcxx/include/span
    libcxx/www/cxx2a_status.html

Removed: 
    libcxx/test/std/containers/views/span.tuple/get.fail.cpp
    libcxx/test/std/containers/views/span.tuple/get.pass.cpp
    libcxx/test/std/containers/views/span.tuple/tuple_element.fail.cpp
    libcxx/test/std/containers/views/span.tuple/tuple_element.pass.cpp
    libcxx/test/std/containers/views/span.tuple/tuple_size.fail.cpp
    libcxx/test/std/containers/views/span.tuple/tuple_size.pass.cpp


################################################################################
diff  --git a/libcxx/include/span b/libcxx/include/span
index 018bf5190573..207beeb5e309 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -539,34 +539,6 @@ private:
     size_type __size;
 };
 
-//  tuple interface
-template <class _Tp, size_t _Size>
-struct _LIBCPP_TEMPLATE_VIS tuple_size<span<_Tp, _Size>>
-    : public integral_constant<size_t, _Size> {};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS tuple_size<span<_Tp, dynamic_extent>>; // declared but not defined
-
-
-template <size_t _Ip, class _Tp, size_t _Size>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, span<_Tp, _Size>>
-{
-    static_assert( dynamic_extent != _Size, "std::tuple_element<> not supported for std::span<T, dynamic_extent>");
-    static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::span)");
-    typedef _Tp type;
-};
-
-template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY constexpr
-_Tp&
-get(span<_Tp, _Size> __s) noexcept
-{
-    static_assert( dynamic_extent != _Size, "std::get<> not supported for std::span<T, dynamic_extent>");
-    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::span)");
-    return __s[_Ip];
-}
-
-
 //  as_bytes & as_writable_bytes
 template <class _Tp, size_t _Extent>
 _LIBCPP_INLINE_VISIBILITY

diff  --git a/libcxx/test/std/containers/views/span.tuple/get.fail.cpp b/libcxx/test/std/containers/views/span.tuple/get.fail.cpp
deleted file mode 100644
index 7544ea3cd586..000000000000
--- a/libcxx/test/std/containers/views/span.tuple/get.fail.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
-
-// <span>
-
-// template <size_t _Ip, ElementType, size_t Extent>
-//   constexpr ElementType& get(span<ElementType, Extent> s) noexcept;
-
-#include <span>
-
-#include "test_macros.h"
-
-
-int main(int, char**)
-{
-//  No get for dynamic spans
-    constexpr int arr [] = {0,1,2,3,4,5,6,7,8,9};
-    (void) std::get< 0>(std::span<const int,  0>(arr, (size_t)0)); // expected-error-re at span:* {{static_assert failed{{( due to requirement '.*')?}} "Index out of bounds in std::get<> (std::span)"}}
-    (void) std::get< 5>(std::span<const int,  5>(arr,         5)); // expected-error-re at span:* {{static_assert failed{{( due to requirement '.*')?}} "Index out of bounds in std::get<> (std::span)"}}
-    (void) std::get<20>(std::span<const int, 10>(arr,        10)); // expected-error-re at span:* {{static_assert failed{{( due to requirement '.*')?}} "Index out of bounds in std::get<> (std::span)"}}
-
-  return 0;
-}

diff  --git a/libcxx/test/std/containers/views/span.tuple/get.pass.cpp b/libcxx/test/std/containers/views/span.tuple/get.pass.cpp
deleted file mode 100644
index b2bed4e15011..000000000000
--- a/libcxx/test/std/containers/views/span.tuple/get.pass.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-// -*- C++ -*-
-//===------------------------------ span ---------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===---------------------------------------------------------------------===//
-// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
-
-// <span>
-
-// template <size_t _Ip, ElementType, size_t Extent>
-//   constexpr ElementType& get(span<ElementType, Extent> s) noexcept;
-//
-
-
-#include <span>
-#include <cassert>
-#include <string>
-
-#include "test_macros.h"
-
-
-template <size_t Idx, typename Span>
-constexpr bool testConstexprSpan(Span sp, typename Span::pointer ptr)
-{
-    ASSERT_NOEXCEPT(std::get<Idx>(sp));
-    return std::addressof(std::get<Idx>(sp)) == ptr;
-}
-
-
-template <size_t Idx, typename Span>
-void testRuntimeSpan(Span sp, typename Span::pointer ptr)
-{
-    ASSERT_NOEXCEPT(std::get<Idx>(sp));
-    assert(std::addressof(std::get<Idx>(sp)) == ptr);
-}
-
-struct A{};
-constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
-          int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
-
-int main(int, char**)
-{
-
-//  static size
-    static_assert(testConstexprSpan<0>(std::span<const int, 4>(iArr1, 4), iArr1 + 0), "");
-    static_assert(testConstexprSpan<1>(std::span<const int, 4>(iArr1, 4), iArr1 + 1), "");
-    static_assert(testConstexprSpan<2>(std::span<const int, 4>(iArr1, 4), iArr1 + 2), "");
-    static_assert(testConstexprSpan<3>(std::span<const int, 4>(iArr1, 4), iArr1 + 3), "");
-
-    static_assert(testConstexprSpan<0>(std::span<const int, 1>(iArr1 + 1, 1), iArr1 + 1), "");
-    static_assert(testConstexprSpan<1>(std::span<const int, 2>(iArr1 + 2, 2), iArr1 + 3), "");
-    static_assert(testConstexprSpan<2>(std::span<const int, 3>(iArr1 + 3, 3), iArr1 + 5), "");
-    static_assert(testConstexprSpan<3>(std::span<const int, 4>(iArr1 + 4, 4), iArr1 + 7), "");
-
-//  static size
-    testRuntimeSpan<0>(std::span<int, 4>(iArr2, 4), iArr2);
-    testRuntimeSpan<1>(std::span<int, 4>(iArr2, 4), iArr2 + 1);
-    testRuntimeSpan<2>(std::span<int, 4>(iArr2, 4), iArr2 + 2);
-    testRuntimeSpan<3>(std::span<int, 4>(iArr2, 4), iArr2 + 3);
-
-    testRuntimeSpan<0>(std::span<int, 1>(iArr2 + 1, 1), iArr2 + 1);
-    testRuntimeSpan<1>(std::span<int, 2>(iArr2 + 2, 2), iArr2 + 3);
-    testRuntimeSpan<2>(std::span<int, 3>(iArr2 + 3, 3), iArr2 + 5);
-    testRuntimeSpan<3>(std::span<int, 4>(iArr2 + 4, 4), iArr2 + 7);
-
-
-    std::string s;
-    testRuntimeSpan<0>(std::span<std::string, 1>(&s, 1), &s);
-
-
-  return 0;
-}

diff  --git a/libcxx/test/std/containers/views/span.tuple/tuple_element.fail.cpp b/libcxx/test/std/containers/views/span.tuple/tuple_element.fail.cpp
deleted file mode 100644
index 4ecec6bda3f3..000000000000
--- a/libcxx/test/std/containers/views/span.tuple/tuple_element.fail.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
-
-// <span>
-
-// tuple_element<I, span<T, N> >::type
-
-#include <span>
-
-#include "test_macros.h"
-
-
-int main(int, char**)
-{
-//  No tuple_element for dynamic spans
-    using T1 = typename std::tuple_element< 0, std::span<int,  0>>::type; // expected-error-re at span:* {{static_assert failed{{( due to requirement '.*')?}} "Index out of bounds in std::tuple_element<> (std::span)"}}
-    using T2 = typename std::tuple_element< 5, std::span<int,  5>>::type; // expected-error-re at span:* {{static_assert failed{{( due to requirement '.*')?}} "Index out of bounds in std::tuple_element<> (std::span)"}}
-    using T3 = typename std::tuple_element<20, std::span<int, 10>>::type; // expected-error-re at span:* {{static_assert failed{{( due to requirement '.*')?}} "Index out of bounds in std::tuple_element<> (std::span)"}}
-
-    return 0;
-}

diff  --git a/libcxx/test/std/containers/views/span.tuple/tuple_element.pass.cpp b/libcxx/test/std/containers/views/span.tuple/tuple_element.pass.cpp
deleted file mode 100644
index 777cb857dc83..000000000000
--- a/libcxx/test/std/containers/views/span.tuple/tuple_element.pass.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
-
-// <span>
-
-// tuple_element<I, span<T, N> >::type
-
-#include <span>
-
-#include "test_macros.h"
-
-template <class T, std::size_t N, std::size_t Idx>
-void test()
-{
-    {
-    typedef std::span<T, N> C;
-    ASSERT_SAME_TYPE(typename std::tuple_element<Idx, C>::type, T);
-    }
-    {
-    typedef std::span<T const, N> C;
-    ASSERT_SAME_TYPE(typename std::tuple_element<Idx, C>::type, T const);
-    }
-    {
-    typedef std::span<T volatile, N> C;
-    ASSERT_SAME_TYPE(typename std::tuple_element<Idx, C>::type, T volatile);
-    }
-    {
-    typedef std::span<T const volatile, N> C;
-    ASSERT_SAME_TYPE(typename std::tuple_element<Idx, C>::type, T const volatile);
-    }
-}
-
-int main(int, char**)
-{
-    test<double, 3, 0>();
-    test<double, 3, 1>();
-    test<double, 3, 2>();
-
-    test<int, 5, 0>();
-    test<int, 5, 1>();
-    test<int, 5, 2>();
-    test<int, 5, 3>();
-    test<int, 5, 4>();
-
-  return 0;
-}

diff  --git a/libcxx/test/std/containers/views/span.tuple/tuple_size.fail.cpp b/libcxx/test/std/containers/views/span.tuple/tuple_size.fail.cpp
deleted file mode 100644
index d7a54403b29f..000000000000
--- a/libcxx/test/std/containers/views/span.tuple/tuple_size.fail.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
-
-// <span>
-
-// tuple_size<span<T, N> >::value
-
-#include <span>
-
-int main(int, char**)
-{
-    (void) std::tuple_size<std::span<double>>::value; // expected-error-re {{implicit instantiation of undefined template 'std:{{.*}}:tuple_size<std:{{.*}}:span<double, {{.*}}}}
-    (void) std::tuple_size<std::span<int>>::value;    // expected-error-re {{implicit instantiation of undefined template 'std:{{.*}}:tuple_size<std:{{.*}}:span<int, {{.*}}}}
-    return 0;
-}

diff  --git a/libcxx/test/std/containers/views/span.tuple/tuple_size.pass.cpp b/libcxx/test/std/containers/views/span.tuple/tuple_size.pass.cpp
deleted file mode 100644
index 1e8b8d0a9c4a..000000000000
--- a/libcxx/test/std/containers/views/span.tuple/tuple_size.pass.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
-
-// <span>
-
-// tuple_size<span<T, N> >::value
-
-#include <span>
-
-#include "test_macros.h"
-
-template <class T, std::size_t N>
-void test()
-{
-    {
-    typedef std::span<T, N> C;
-    static_assert((std::tuple_size<C>::value == N), "");
-    }
-    {
-    typedef std::span<T const, N> C;
-    static_assert((std::tuple_size<C>::value == N), "");
-    }
-    {
-    typedef std::span<T volatile, N> C;
-    static_assert((std::tuple_size<C>::value == N), "");
-    }
-    {
-    typedef std::span<T const volatile, N> C;
-    static_assert((std::tuple_size<C>::value == N), "");
-    }
-}
-
-int main(int, char**)
-{
-    test<double, 0>();
-    test<double, 3>();
-    test<double, 5>();
-
-  return 0;
-}

diff  --git a/libcxx/www/cxx2a_status.html b/libcxx/www/cxx2a_status.html
index 4b715e7a40f3..73d41c625f7a 100644
--- a/libcxx/www/cxx2a_status.html
+++ b/libcxx/www/cxx2a_status.html
@@ -253,7 +253,7 @@ <h3>Paper Status</h3>
 	<tr><td><a href="https://wg21.link/P2101">P2101</a></td><td>LWG</td><td>'Models' subsumes 'satisfies' (Wording for US298 and US300)</td><td>Prague</td><td><i> </i></td><td></td></tr>
 	<tr><td><a href="https://wg21.link/P2102">P2102</a></td><td>LWG</td><td>Make 'implicit expression variations' more explicit (Wording for US185)</td><td>Prague</td><td><i> </i></td><td></td></tr>
 	<tr><td><a href="https://wg21.link/P2106">P2106</a></td><td>LWG</td><td>Alternative wording for GB315 and GB316</td><td>Prague</td><td><i> </i></td><td></td></tr>
-	<tr><td><a href="https://wg21.link/P2116">P2116</a></td><td>LWG</td><td>Remove tuple-like protocol support from fixed-extent span</td><td>Prague</td><td><i> </i></td><td></td></tr>
+	<tr><td><a href="https://wg21.link/P2116">P2116</a></td><td>LWG</td><td>Remove tuple-like protocol support from fixed-extent span</td><td>Prague</td><td>Complete</td><td>11.0</td></tr>
 <!--  	<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr> -->
   </table>
 


        


More information about the libcxx-commits mailing list