diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2019-02-25 18:32:57 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2019-02-25 18:32:57 +0000 |
| commit | 310b75e51995e8a9aeae0ea6c6d7922324453f57 (patch) | |
| tree | b95f9c4025fa388bdb9a39442a9f55e90faf66d6 /libcxx/test/std | |
| parent | a20bd2735e0ecb3ba9e483af86576c3d5175f457 (diff) | |
| download | bcm5719-llvm-310b75e51995e8a9aeae0ea6c6d7922324453f57.tar.gz bcm5719-llvm-310b75e51995e8a9aeae0ea6c6d7922324453f57.zip | |
LWG3101 - span's Container constructors need another constraint. Reviewed as https://reviews.llvm.org/D57058.
llvm-svn: 354805
Diffstat (limited to 'libcxx/test/std')
| -rw-r--r-- | libcxx/test/std/containers/views/span.cons/container.fail.cpp | 27 | ||||
| -rw-r--r-- | libcxx/test/std/containers/views/span.cons/container.pass.cpp | 33 |
2 files changed, 10 insertions, 50 deletions
diff --git a/libcxx/test/std/containers/views/span.cons/container.fail.cpp b/libcxx/test/std/containers/views/span.cons/container.fail.cpp index d0fb5656d21..9bc13a61069 100644 --- a/libcxx/test/std/containers/views/span.cons/container.fail.cpp +++ b/libcxx/test/std/containers/views/span.cons/container.fail.cpp @@ -16,6 +16,7 @@ // constexpr span(const Container& cont); // // Remarks: These constructors shall not participate in overload resolution unless: +// — extent == dynamic_extent, // — Container is not a specialization of span, // — Container is not a specialization of array, // — is_array_v<Container> is false, @@ -69,37 +70,28 @@ int main(int, char**) // Making non-const spans from const sources (a temporary binds to `const &`) { std::span<int> s1{IsAContainer<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<int>'}} - std::span<int, 0> s2{IsAContainer<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<int, 0>'}} std::span<int> s3{std::vector<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<int>'}} - std::span<int, 0> s4{std::vector<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<int, 0>'}} } // Missing size and/or data { std::span<const int> s1{NotAContainerNoData<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int>'}} - std::span<const int, 0> s2{NotAContainerNoData<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int, 0>'}} std::span<const int> s3{NotAContainerNoSize<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int>'}} - std::span<const int, 0> s4{NotAContainerNoSize<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int, 0>'}} std::span<const int> s5{NotAContainerPrivate<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int>'}} - std::span<const int, 0> s6{NotAContainerPrivate<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int, 0>'}} // Again with the standard containers std::span<const int> s11{std::deque<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int>'}} - std::span<const int, 0> s12{std::deque<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int, 0>'}} std::span<const int> s13{std::list<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int>'}} - std::span<const int, 0> s14{std::list<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int, 0>'}} std::span<const int> s15{std::forward_list<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int>'}} - std::span<const int, 0> s16{std::forward_list<int>()}; // expected-error {{no matching constructor for initialization of 'std::span<const int, 0>'}} } // Not the same type { IsAContainer<int> c; std::span<float> s1{c}; // expected-error {{no matching constructor for initialization of 'std::span<float>'}} - std::span<float, 0> s2{c}; // expected-error {{no matching constructor for initialization of 'std::span<float, 0>'}} } -// CV wrong (dynamically sized) +// CV wrong { IsAContainer<const int> c; IsAContainer<const volatile int> cv; @@ -114,19 +106,10 @@ int main(int, char**) std::span< volatile int> s7{cv}; // expected-error {{no matching constructor for initialization of 'std::span<volatile int>'}} } -// CV wrong (statically sized) +// statically sized { - IsAContainer<const int> c; - IsAContainer<const volatile int> cv; - IsAContainer< volatile int> v; - - std::span< int,1> s1{c}; // expected-error {{no matching constructor for initialization of 'std::span<int, 1>'}} - std::span< int,1> s2{v}; // expected-error {{no matching constructor for initialization of 'std::span<int, 1>'}} - std::span< int,1> s3{cv}; // expected-error {{no matching constructor for initialization of 'std::span<int, 1>'}} - std::span<const int,1> s4{v}; // expected-error {{no matching constructor for initialization of 'std::span<const int, 1>'}} - std::span<const int,1> s5{cv}; // expected-error {{no matching constructor for initialization of 'std::span<const int, 1>'}} - std::span< volatile int,1> s6{c}; // expected-error {{no matching constructor for initialization of 'std::span<volatile int, 1>'}} - std::span< volatile int,1> s7{cv}; // expected-error {{no matching constructor for initialization of 'std::span<volatile int, 1>'}} + IsAContainer<int> c; + std::span<int,1> s1{c}; // expected-error {{no matching constructor for initialization of 'std::span<int, 1>'}} } diff --git a/libcxx/test/std/containers/views/span.cons/container.pass.cpp b/libcxx/test/std/containers/views/span.cons/container.pass.cpp index 07aac9229f0..d42013bd268 100644 --- a/libcxx/test/std/containers/views/span.cons/container.pass.cpp +++ b/libcxx/test/std/containers/views/span.cons/container.pass.cpp @@ -16,6 +16,7 @@ // constexpr span(const Container& cont); // // Remarks: These constructors shall not participate in overload resolution unless: +// — extent == dynamic_extent, // — Container is not a specialization of span, // — Container is not a specialization of array, // — is_array_v<Container> is false, @@ -48,17 +49,12 @@ void checkCV() { std::vector<int> v = {1,2,3}; -// Types the same (dynamic sized) +// Types the same { std::span< int> s1{v}; // a span< int> pointing at int. } -// Types the same (static sized) - { - std::span< int,3> s1{v}; // a span< int> pointing at int. - } - -// types different (dynamic sized) +// types different { std::span<const int> s1{v}; // a span<const int> pointing at int. std::span< volatile int> s2{v}; // a span< volatile int> pointing at int. @@ -66,24 +62,12 @@ void checkCV() std::span<const volatile int> s4{v}; // a span<const volatile int> pointing at int. } -// types different (static sized) - { - std::span<const int,3> s1{v}; // a span<const int> pointing at int. - std::span< volatile int,3> s2{v}; // a span< volatile int> pointing at int. - std::span< volatile int,3> s3{v}; // a span< volatile int> pointing at const int. - std::span<const volatile int,3> s4{v}; // a span<const volatile int> pointing at int. - } - // Constructing a const view from a temporary { std::span<const int> s1{IsAContainer<int>()}; - std::span<const int, 0> s2{IsAContainer<int>()}; std::span<const int> s3{std::vector<int>()}; - std::span<const int, 0> s4{std::vector<int>()}; (void) s1; - (void) s2; (void) s3; - (void) s4; } } @@ -92,11 +76,8 @@ template <typename T> constexpr bool testConstexprSpan() { constexpr IsAContainer<const T> val{}; - std::span<const T> s1{val}; - std::span<const T, 1> s2{val}; - return - s1.data() == val.getV() && s1.size() == 1 - && s2.data() == val.getV() && s2.size() == 1; + std::span<const T> s1{val}; + return s1.data() == val.getV() && s1.size() == 1; } @@ -107,12 +88,8 @@ void testRuntimeSpan() const IsAContainer<T> cVal; std::span<T> s1{val}; std::span<const T> s2{cVal}; - std::span<T, 1> s3{val}; - std::span<const T, 1> s4{cVal}; assert(s1.data() == val.getV() && s1.size() == 1); assert(s2.data() == cVal.getV() && s2.size() == 1); - assert(s3.data() == val.getV() && s3.size() == 1); - assert(s4.data() == cVal.getV() && s4.size() == 1); } struct A{}; |

