From 028925cababf51cb7ab6ed683c31d0fe3d3fd4de Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Sat, 10 Feb 2018 18:05:17 -0800 Subject: [PATCH] Removed from-smart-ptr constructors. --- include/gsl/span | 14 ------- tests/span_tests.cpp | 98 -------------------------------------------- 2 files changed, 112 deletions(-) diff --git a/include/gsl/span b/include/gsl/span index bd9a21d..fa76ed5 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -26,7 +26,6 @@ #include // for ptrdiff_t, size_t, nullptr_t #include // for reverse_iterator, distance, random_access_... #include -#include // for unique_ptr, shared_ptr #include #include // for enable_if_t, declval, is_convertible, inte... #include @@ -369,19 +368,6 @@ public: { } - template > - constexpr span(const std::unique_ptr& ptr, index_type count) - : storage_(ptr.get(), count) - { - } - - constexpr span(const std::unique_ptr& ptr) : storage_(ptr.get(), ptr.get() ? 1 : 0) - { - } - constexpr span(const std::shared_ptr& ptr) : storage_(ptr.get(), ptr.get() ? 1 : 0) - { - } - // NB: the SFINAE here uses .data() as a incomplete/imperfect proxy for the requirement // on Container to be a contiguous sequence container. template (4); - - { - span s{ptr}; - CHECK((s.length() == 1 && s.data() == ptr.get())); - CHECK(s[0] == 4); - } - - { - auto s = make_span(ptr); - CHECK((s.length() == 1 && s.data() == ptr.get())); - CHECK(s[0] == 4); - } - } - - { - auto ptr = std::unique_ptr{nullptr}; - - { - span s{ptr}; - CHECK((s.length() == 0 && s.data() == nullptr)); - } - - { - auto s = make_span(ptr); - CHECK((s.length() == 0 && s.data() == nullptr)); - } - } - - { - auto arr = std::make_unique(4); - - for (auto i = 0U; i < 4; i++) arr[i] = gsl::narrow_cast(i + 1); - - { - span s{arr, 4}; - CHECK((s.length() == 4 && s.data() == arr.get())); - CHECK((s[0] == 1 && s[1] == 2)); - } - - { - auto s = make_span(arr, 4); - CHECK((s.length() == 4 && s.data() == arr.get())); - CHECK((s[0] == 1 && s[1] == 2)); - } - } - - { - auto arr = std::unique_ptr{nullptr}; - - { - span s{arr, 0}; - CHECK((s.length() == 0 && s.data() == nullptr)); - } - - { - auto s = make_span(arr, 0); - CHECK((s.length() == 0 && s.data() == nullptr)); - } - } -} - -TEST_CASE("from_shared_pointer_construction") -{ - { - auto ptr = std::make_shared(4); - - { - span s{ptr}; - CHECK((s.length() == 1 && s.data() == ptr.get())); - CHECK((s[0] == 4)); - } - - { - auto s = make_span(ptr); - CHECK((s.length() == 1 && s.data() == ptr.get())); - CHECK((s[0] == 4)); - } - } - - { - auto ptr = std::shared_ptr{nullptr}; - - { - span s{ptr}; - CHECK((s.length() == 0 && s.data() == nullptr)); - } - - { - auto s = make_span(ptr); - CHECK((s.length() == 0 && s.data() == nullptr)); - } - } -} - TEST_CASE("from_container_constructor") { std::vector v = {1, 2, 3};