applied clang-format

This commit is contained in:
Jordan Maples 2020-03-17 15:04:58 -07:00
parent 9b3ac8d681
commit f8bcb7d9eb
2 changed files with 36 additions and 29 deletions

View File

@ -441,17 +441,19 @@ public:
: storage_(KnownNotNull{arr + 0}, details::extent_type<N>()) : 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 && 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 constexpr span(std::array<T, N>& arr) noexcept
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>()) : storage_(KnownNotNull{arr.data()}, 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 && std::enable_if_t<
details::is_allowed_element_type_conversion<const T, (details::is_allowed_extent_conversion<N, Extent>::value &&
element_type>::value), details::is_allowed_element_type_conversion<const T, element_type>::value),
int> = 0> int> = 0>
constexpr span(const std::array<T, N>& arr) noexcept constexpr span(const std::array<T, N>& arr) noexcept
: storage_(KnownNotNull{arr.data()}, details::extent_type<N>()) : storage_(KnownNotNull{arr.data()}, details::extent_type<N>())
@ -463,7 +465,9 @@ public:
class = std::enable_if_t< class = std::enable_if_t<
!details::is_span<Container>::value && !details::is_std_array<Container>::value && !details::is_span<Container>::value && !details::is_std_array<Container>::value &&
std::is_pointer<decltype(std::declval<Container&>().data())>::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()) 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 && std::is_const<element_type>::value && !details::is_span<Container>::value &&
!details::is_std_array<Container>::value && !details::is_std_array<Container>::value &&
std::is_pointer<decltype(std::declval<const Container&>().data())>::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()) constexpr span(const Container& cont) noexcept : span(cont.data(), cont.size())
{} {}
@ -674,7 +680,8 @@ private:
template <std::size_t CallerExtent> template <std::size_t CallerExtent>
constexpr span<element_type, dynamic_extent> make_subspan(size_type offset, size_type count, 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); const span<element_type, dynamic_extent> tmp(*this);
return tmp.subspan(offset, count); return tmp.subspan(offset, count);

View File

@ -46,7 +46,7 @@ TEST(span_compatibility_tests, assertion_tests)
{ {
int arr[3]{10, 20, 30}; int arr[3]{10, 20, 30};
std::array<int, 3> stl{{100, 200, 300}}; 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 #if __cplusplus >= 201703l
// This std::is_convertible_v<int*(*)[], int const* const(*)[]> fails for C++14 // 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.data() == stl_nullptr.data());
EXPECT_TRUE(sp_const_nullptr_2.size() == 3); 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{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{std::as_const(stl_nullptr)}),
span<int* const, 3>);
} }
#endif #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, 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>>"); "std::is_convertible<const std::array<int, 3>&, gsl::span<const int>>");
#if __cplusplus >= 201703l #if __cplusplus >= 201703l
template <typename U, typename = void> template <typename U, typename = void>
static constexpr bool AsWritableBytesCompilesFor = false; static constexpr bool AsWritableBytesCompilesFor = false;
template <typename U> template <typename U>
static constexpr bool AsWritableBytesCompilesFor<U, void_t<decltype(as_writable_bytes(declval<U>()))>> = static constexpr bool
true; AsWritableBytesCompilesFor<U, void_t<decltype(as_writable_bytes(declval<U>()))>> = true;
static_assert(AsWritableBytesCompilesFor<gsl::span<int>>, static_assert(AsWritableBytesCompilesFor<gsl::span<int>>,
"AsWritableBytesCompilesFor<gsl::span<int>>"); "AsWritableBytesCompilesFor<gsl::span<int>>");