mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
msvc and gcc work locally
This commit is contained in:
parent
d8fa68c4a5
commit
dd78144c2e
@ -418,7 +418,8 @@ public:
|
|||||||
// "Dependent" is needed to make "std::enable_if_t<Dependent || Extent == 0 || Extent
|
// "Dependent" is needed to make "std::enable_if_t<Dependent || Extent == 0 || Extent
|
||||||
// == dynamic_extent>" SFINAE, since "std::enable_if_t<Extent == 0 || Extent ==
|
// == dynamic_extent>" SFINAE, since "std::enable_if_t<Extent == 0 || Extent ==
|
||||||
// dynamic_extent>" is ill-formed when Extent is greater than 0.
|
// dynamic_extent>" is ill-formed when Extent is greater than 0.
|
||||||
class = std::enable_if_t<(Dependent || Extent == 0 || Extent == dynamic_extent)>>
|
class = std::enable_if_t<(Dependent ||
|
||||||
|
details::is_allowed_extent_conversion<0, Extent>::value)>>
|
||||||
constexpr span() noexcept : storage_(nullptr, details::extent_type<0>())
|
constexpr span() noexcept : storage_(nullptr, details::extent_type<0>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -430,36 +431,31 @@ public:
|
|||||||
constexpr span(pointer firstElem, pointer lastElem) noexcept
|
constexpr span(pointer firstElem, pointer lastElem) noexcept
|
||||||
: storage_(firstElem, static_cast<std::size_t>(std::distance(firstElem, lastElem)))
|
: storage_(firstElem, static_cast<std::size_t>(std::distance(firstElem, lastElem)))
|
||||||
{
|
{
|
||||||
if (Extent != dynamic_extent) { Expects(lastElem - firstElem == static_cast<difference_type>(Extent)); }
|
if (Extent != dynamic_extent)
|
||||||
|
{ Expects(lastElem - firstElem == static_cast<difference_type>(Extent)); }
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N,
|
||||||
|
std::enable_if_t<details::is_allowed_extent_conversion<N, Extent>::value, int> = 0>
|
||||||
constexpr span(element_type (&arr)[N]) noexcept
|
constexpr span(element_type (&arr)[N]) noexcept
|
||||||
: storage_(KnownNotNull{std::addressof(arr[0])}, details::extent_type<N>())
|
: storage_(KnownNotNull{std::addressof(arr[0])}, details::extent_type<N>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <std::size_t N, std::size_t Ext = Extent,
|
template <std::size_t N,
|
||||||
std::enable_if_t<(N == Ext || Ext == dynamic_extent), int> = 0>
|
std::enable_if_t<details::is_allowed_extent_conversion<N, Extent>::value, int> = 0>
|
||||||
constexpr span(std::array<value_type, N>& arr) noexcept
|
constexpr span(std::array<element_type, N>& arr) noexcept
|
||||||
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
|
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <std::size_t N, std::size_t Ext = Extent,
|
template <std::size_t N,
|
||||||
std::enable_if_t<((N == Ext || Ext == dynamic_extent) &&
|
std::enable_if_t<(details::is_allowed_extent_conversion<N, Extent>::value &&
|
||||||
std::is_convertible<const value_type*, element_type*>::value),
|
details::is_allowed_element_type_conversion<const value_type,
|
||||||
|
element_type>::value),
|
||||||
int> = 0>
|
int> = 0>
|
||||||
constexpr span(const std::array<value_type, N>& arr) noexcept
|
constexpr span(const std::array<value_type, N>& arr) noexcept
|
||||||
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
|
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
constexpr span(std::array<value_type, 0>&) noexcept
|
|
||||||
: storage_(static_cast<pointer>(nullptr), details::extent_type<0>())
|
|
||||||
{}
|
|
||||||
|
|
||||||
constexpr span(const std::array<value_type, 0>&) noexcept
|
|
||||||
: storage_(static_cast<pointer>(nullptr), details::extent_type<0>())
|
|
||||||
{}
|
|
||||||
|
|
||||||
// NB: the SFINAE here uses .data() as a incomplete/imperfect proxy for the requirement
|
// NB: the SFINAE here uses .data() as a incomplete/imperfect proxy for the requirement
|
||||||
// on Container to be a contiguous sequence container.
|
// on Container to be a contiguous sequence container.
|
||||||
template <class Container,
|
template <class Container,
|
||||||
@ -474,6 +470,7 @@ public:
|
|||||||
template <class Container,
|
template <class Container,
|
||||||
class = std::enable_if_t<
|
class = std::enable_if_t<
|
||||||
std::is_const<element_type>::value && !details::is_span<Container>::value &&
|
std::is_const<element_type>::value && !details::is_span<Container>::value &&
|
||||||
|
!details::is_std_array<Container>::value &&
|
||||||
std::is_convertible<typename Container::pointer, pointer>::value &&
|
std::is_convertible<typename Container::pointer, pointer>::value &&
|
||||||
std::is_convertible<decltype(std::declval<Container&>().data()), pointer>::value>>
|
std::is_convertible<decltype(std::declval<Container&>().data()), pointer>::value>>
|
||||||
constexpr span(const Container& cont) noexcept : span(cont.data(), cont.size())
|
constexpr span(const Container& cont) noexcept : span(cont.data(), cont.size())
|
||||||
@ -686,8 +683,8 @@ private:
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
||||||
// clang-format on
|
// clang-format on
|
||||||
constexpr span<element_type, dynamic_extent> make_subspan(size_type offset, size_type count,
|
constexpr span<element_type, dynamic_extent>
|
||||||
subspan_selector<dynamic_extent>) const
|
make_subspan(size_type offset, size_type count, subspan_selector<dynamic_extent>) const
|
||||||
{
|
{
|
||||||
Expects(size() >= offset);
|
Expects(size() >= offset);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user