mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
applied clang-format
This commit is contained in:
parent
9b3ac8d681
commit
f8bcb7d9eb
@ -441,17 +441,19 @@ public:
|
||||
: storage_(KnownNotNull{arr + 0}, details::extent_type<N>())
|
||||
{}
|
||||
|
||||
template <class T, std::size_t N,
|
||||
template <
|
||||
class T, std::size_t N,
|
||||
std::enable_if_t<(details::is_allowed_extent_conversion<N, Extent>::value &&
|
||||
details::is_allowed_element_type_conversion<T, element_type>::value), int> = 0>
|
||||
details::is_allowed_element_type_conversion<T, element_type>::value),
|
||||
int> = 0>
|
||||
constexpr span(std::array<T, N>& arr) noexcept
|
||||
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
|
||||
{}
|
||||
|
||||
template <class T, std::size_t N,
|
||||
std::enable_if_t<(details::is_allowed_extent_conversion<N, Extent>::value &&
|
||||
details::is_allowed_element_type_conversion<const T,
|
||||
element_type>::value),
|
||||
std::enable_if_t<
|
||||
(details::is_allowed_extent_conversion<N, Extent>::value &&
|
||||
details::is_allowed_element_type_conversion<const T, element_type>::value),
|
||||
int> = 0>
|
||||
constexpr span(const std::array<T, N>& arr) noexcept
|
||||
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
|
||||
@ -463,7 +465,9 @@ public:
|
||||
class = std::enable_if_t<
|
||||
!details::is_span<Container>::value && !details::is_std_array<Container>::value &&
|
||||
std::is_pointer<decltype(std::declval<Container&>().data())>::value &&
|
||||
std::is_convertible<std::remove_pointer_t<decltype(std::declval<Container&>().data())>(*)[], element_type(*)[]>::value>>
|
||||
std::is_convertible<
|
||||
std::remove_pointer_t<decltype(std::declval<Container&>().data())> (*)[],
|
||||
element_type (*)[]>::value>>
|
||||
constexpr span(Container& cont) noexcept : span(cont.data(), cont.size())
|
||||
{}
|
||||
|
||||
@ -472,7 +476,9 @@ public:
|
||||
std::is_const<element_type>::value && !details::is_span<Container>::value &&
|
||||
!details::is_std_array<Container>::value &&
|
||||
std::is_pointer<decltype(std::declval<const Container&>().data())>::value &&
|
||||
std::is_convertible<std::remove_pointer_t<decltype(std::declval<const Container&>().data())>(*)[], element_type(*)[]>::value>>
|
||||
std::is_convertible<std::remove_pointer_t<
|
||||
decltype(std::declval<const Container&>().data())> (*)[],
|
||||
element_type (*)[]>::value>>
|
||||
constexpr span(const Container& cont) noexcept : span(cont.data(), cont.size())
|
||||
{}
|
||||
|
||||
@ -674,7 +680,8 @@ private:
|
||||
|
||||
template <std::size_t CallerExtent>
|
||||
constexpr span<element_type, dynamic_extent> make_subspan(size_type offset, size_type count,
|
||||
subspan_selector<CallerExtent>) const noexcept
|
||||
subspan_selector<CallerExtent>) const
|
||||
noexcept
|
||||
{
|
||||
const span<element_type, dynamic_extent> tmp(*this);
|
||||
return tmp.subspan(offset, count);
|
||||
|
@ -46,7 +46,7 @@ TEST(span_compatibility_tests, assertion_tests)
|
||||
{
|
||||
int arr[3]{10, 20, 30};
|
||||
std::array<int, 3> stl{{100, 200, 300}};
|
||||
std::array<int*, 3> stl_nullptr{{nullptr,nullptr,nullptr}};
|
||||
std::array<int*, 3> stl_nullptr{{nullptr, nullptr, nullptr}};
|
||||
|
||||
#if __cplusplus >= 201703l
|
||||
// This std::is_convertible_v<int*(*)[], int const* const(*)[]> fails for C++14
|
||||
@ -60,8 +60,9 @@ TEST(span_compatibility_tests, assertion_tests)
|
||||
EXPECT_TRUE(sp_const_nullptr_2.data() == stl_nullptr.data());
|
||||
EXPECT_TRUE(sp_const_nullptr_2.size() == 3);
|
||||
|
||||
static_assert(std::is_same<decltype(span{stl_nullptr}), span<int*, 3>);
|
||||
static_assert(std::is_same<decltype(span{std::as_const(stl_nullptr)}), span<int* const, 3>);
|
||||
static_assert(std::is_same < decltype(span{stl_nullptr}), span<int*, 3>);
|
||||
static_assert(std::is_same < decltype(span{std::as_const(stl_nullptr)}),
|
||||
span<int* const, 3>);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1070,14 +1071,13 @@ static_assert(std::is_convertible<std::array<int, 3>&, gsl::span<const int>>::va
|
||||
static_assert(std::is_convertible<const std::array<int, 3>&, gsl::span<const int>>::value,
|
||||
"std::is_convertible<const std::array<int, 3>&, gsl::span<const int>>");
|
||||
|
||||
|
||||
#if __cplusplus >= 201703l
|
||||
template <typename U, typename = void>
|
||||
static constexpr bool AsWritableBytesCompilesFor = false;
|
||||
|
||||
template <typename U>
|
||||
static constexpr bool AsWritableBytesCompilesFor<U, void_t<decltype(as_writable_bytes(declval<U>()))>> =
|
||||
true;
|
||||
static constexpr bool
|
||||
AsWritableBytesCompilesFor<U, void_t<decltype(as_writable_bytes(declval<U>()))>> = true;
|
||||
|
||||
static_assert(AsWritableBytesCompilesFor<gsl::span<int>>,
|
||||
"AsWritableBytesCompilesFor<gsl::span<int>>");
|
||||
|
Loading…
Reference in New Issue
Block a user