From f8bcb7d9eb44be91a04882eb972fbef328c24cae Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Tue, 17 Mar 2020 15:04:58 -0700 Subject: [PATCH] applied clang-format --- include/gsl/span | 43 +++++++++++++++++------------- tests/span_compatibility_tests.cpp | 22 +++++++-------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/include/gsl/span b/include/gsl/span index 469a2db..566f731 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -21,9 +21,9 @@ #include // for byte #include // for narrow_cast, narrow -#include // for array -#include // for ptrdiff_t, size_t, nullptr_t -#include // for reverse_iterator, distance, random_access_... +#include // for array +#include // for ptrdiff_t, size_t, nullptr_t +#include // for reverse_iterator, distance, random_access_... #include // for enable_if_t, declval, is_convertible, inte... #if defined(_MSC_VER) && !defined(__clang__) @@ -441,18 +441,20 @@ public: : storage_(KnownNotNull{arr + 0}, details::extent_type()) {} - template ::value && - details::is_allowed_element_type_conversion::value), int> = 0> + template < + class T, std::size_t N, + std::enable_if_t<(details::is_allowed_extent_conversion::value && + details::is_allowed_element_type_conversion::value), + int> = 0> constexpr span(std::array& arr) noexcept : storage_(KnownNotNull{arr.data()}, details::extent_type()) {} template ::value && - details::is_allowed_element_type_conversion::value), - int> = 0> + std::enable_if_t< + (details::is_allowed_extent_conversion::value && + details::is_allowed_element_type_conversion::value), + int> = 0> constexpr span(const std::array& arr) noexcept : storage_(KnownNotNull{arr.data()}, details::extent_type()) {} @@ -463,7 +465,9 @@ public: class = std::enable_if_t< !details::is_span::value && !details::is_std_array::value && std::is_pointer().data())>::value && - std::is_convertible().data())>(*)[], element_type(*)[]>::value>> + std::is_convertible< + std::remove_pointer_t().data())> (*)[], + element_type (*)[]>::value>> constexpr span(Container& cont) noexcept : span(cont.data(), cont.size()) {} @@ -472,7 +476,9 @@ public: std::is_const::value && !details::is_span::value && !details::is_std_array::value && std::is_pointer().data())>::value && - std::is_convertible().data())>(*)[], element_type(*)[]>::value>> + std::is_convertible().data())> (*)[], + element_type (*)[]>::value>> constexpr span(const Container& cont) noexcept : span(cont.data(), cont.size()) {} @@ -501,8 +507,8 @@ public: template // clang-format off GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute - // clang-format on - constexpr span last() const noexcept + // clang-format on + constexpr span last() const noexcept { Expects(Count <= size()); return {data() + (size() - Count), Count}; @@ -511,9 +517,9 @@ public: template // clang-format off GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute - // clang-format on - constexpr auto subspan() const noexcept -> - typename details::calculate_subspan_type::type + // clang-format on + constexpr auto subspan() const noexcept -> + typename details::calculate_subspan_type::type { Expects((size() >= Offset) && (Count == dynamic_extent || (Count <= size() - Offset))); @@ -674,7 +680,8 @@ private: template constexpr span make_subspan(size_type offset, size_type count, - subspan_selector) const noexcept + subspan_selector) const + noexcept { const span tmp(*this); return tmp.subspan(offset, count); diff --git a/tests/span_compatibility_tests.cpp b/tests/span_compatibility_tests.cpp index acd85c5..d8226ec 100644 --- a/tests/span_compatibility_tests.cpp +++ b/tests/span_compatibility_tests.cpp @@ -24,7 +24,7 @@ #include // for reverse_iterator, operator-, operator== #include // for integral_constant<>::value, is_default_co... #include -#include // for vector +#include // for vector using namespace std; using namespace gsl; @@ -46,7 +46,7 @@ TEST(span_compatibility_tests, assertion_tests) { int arr[3]{10, 20, 30}; std::array stl{{100, 200, 300}}; - std::array stl_nullptr{{nullptr,nullptr,nullptr}}; + std::array stl_nullptr{{nullptr, nullptr, nullptr}}; #if __cplusplus >= 201703l // This std::is_convertible_v 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); - static_assert(std::is_same); + static_assert(std::is_same < decltype(span{stl_nullptr}), span); + static_assert(std::is_same < decltype(span{std::as_const(stl_nullptr)}), + span); } #endif @@ -1070,21 +1071,20 @@ static_assert(std::is_convertible&, gsl::span>::va static_assert(std::is_convertible&, gsl::span>::value, "std::is_convertible&, gsl::span>"); - #if __cplusplus >= 201703l template static constexpr bool AsWritableBytesCompilesFor = false; template -static constexpr bool AsWritableBytesCompilesFor()))>> = - true; +static constexpr bool + AsWritableBytesCompilesFor()))>> = true; static_assert(AsWritableBytesCompilesFor>, - "AsWritableBytesCompilesFor>"); + "AsWritableBytesCompilesFor>"); static_assert(AsWritableBytesCompilesFor>, - "AsWritableBytesCompilesFor>"); + "AsWritableBytesCompilesFor>"); static_assert(!AsWritableBytesCompilesFor>, - "!AsWritableBytesCompilesFor>"); + "!AsWritableBytesCompilesFor>"); static_assert(!AsWritableBytesCompilesFor>, - "!AsWritableBytesCompilesFor>"); + "!AsWritableBytesCompilesFor>"); #endif // __cplusplus >= 201703l