Removed from-smart-ptr constructors. (#611)

As per feedback during standardization discussions.
This commit is contained in:
Neil MacIntosh 2018-02-10 20:02:05 -08:00 committed by GitHub
parent 64a7dae4c6
commit 87e22faa7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 112 deletions

View File

@ -26,7 +26,6 @@
#include <cstddef> // for ptrdiff_t, size_t, nullptr_t
#include <iterator> // for reverse_iterator, distance, random_access_...
#include <limits>
#include <memory> // for unique_ptr, shared_ptr
#include <stdexcept>
#include <type_traits> // for enable_if_t, declval, is_convertible, inte...
#include <utility>
@ -369,19 +368,6 @@ public:
{
}
template <class ArrayElementType = std::add_pointer<element_type>>
constexpr span(const std::unique_ptr<ArrayElementType>& ptr, index_type count)
: storage_(ptr.get(), count)
{
}
constexpr span(const std::unique_ptr<ElementType>& ptr) : storage_(ptr.get(), ptr.get() ? 1 : 0)
{
}
constexpr span(const std::shared_ptr<ElementType>& 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 <class Container,

View File

@ -586,104 +586,6 @@ TEST_CASE("from_std_array_const_constructor")
}
}
TEST_CASE("from_unique_pointer_construction")
{
{
auto ptr = std::make_unique<int>(4);
{
span<int> 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<int>{nullptr};
{
span<int> 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<int[]>(4);
for (auto i = 0U; i < 4; i++) arr[i] = gsl::narrow_cast<int>(i + 1);
{
span<int> 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<int[]>{nullptr};
{
span<int> 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<int>(4);
{
span<int> 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<int>{nullptr};
{
span<int> 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<int> v = {1, 2, 3};