From 6fadce975b95952f13ffafdcee88795222b711f3 Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Tue, 26 Jul 2016 19:19:47 -0700 Subject: [PATCH] Applied clang-format. --- include/multi_span.h | 15 ++++++---- include/span.h | 43 ++++++++++++++------------- include/string_span.h | 69 +++++++++++++++++++++++-------------------- 3 files changed, 69 insertions(+), 58 deletions(-) diff --git a/include/multi_span.h b/include/multi_span.h index a63f8ce..cfe2d5c 100644 --- a/include/multi_span.h +++ b/include/multi_span.h @@ -740,7 +740,8 @@ public: } constexpr strided_bounds(const index_type& extents, const index_type& strides) noexcept - : m_extents(extents), m_strides(strides) + : m_extents(extents), + m_strides(strides) { } @@ -837,7 +838,8 @@ public: using index_size_type = typename IndexType::value_type; template explicit bounds_iterator(const Bounds& bnd, value_type curr) noexcept - : boundary_(bnd.index_bounds()), curr_(std::move(curr)) + : boundary_(bnd.index_bounds()), + curr_(std::move(curr)) { static_assert(is_bounds::value, "Bounds type must be provided"); } @@ -1132,7 +1134,7 @@ namespace details template std::enable_if_t< !std::is_same>::value && !std::is_same::value, T> - static_as_span_helper(Arg, Args... args) + static_as_span_helper(Arg, Args... args) { return static_as_span_helper(args...); } @@ -1250,8 +1252,8 @@ public: } // construct from pointer + length - multidimensional - constexpr multi_span(pointer data, bounds_type bounds) noexcept - : data_(data), bounds_(std::move(bounds)) + constexpr multi_span(pointer data, bounds_type bounds) noexcept : data_(data), + bounds_(std::move(bounds)) { Expects((bounds_.size() > 0 && data != nullptr) || bounds_.size() == 0); } @@ -1347,7 +1349,8 @@ public: typename = std::enable_if_t::value && std::is_convertible::value>> constexpr multi_span(multi_span other) noexcept - : data_(other.data_), bounds_(other.bounds_) + : data_(other.data_), + bounds_(other.bounds_) { } diff --git a/include/span.h b/include/span.h index decc8e2..4d8e877 100644 --- a/include/span.h +++ b/include/span.h @@ -120,30 +120,33 @@ namespace details template struct is_allowed_pointer_conversion - : public std::integral_constant::value && std::is_pointer::value && - std::is_convertible::value> + : public std::integral_constant::value && + std::is_pointer::value && + std::is_convertible::value> { }; template struct is_allowed_integral_conversion - : public std::integral_constant::value && std::is_integral::value && - sizeof(From) == sizeof(To) && alignof(From) == alignof(To) && - std::is_convertible::value> + : public std::integral_constant< + bool, std::is_integral::value && std::is_integral::value && + sizeof(From) == sizeof(To) && alignof(From) == alignof(To) && + std::is_convertible::value> { }; template struct is_allowed_extent_conversion - : public std::integral_constant + : public std::integral_constant { }; template struct is_allowed_element_type_conversion : public std::integral_constant>::value || - is_allowed_pointer_conversion::value || - is_allowed_integral_conversion::value> + is_allowed_pointer_conversion::value || + is_allowed_integral_conversion::value> { }; @@ -392,9 +395,7 @@ namespace details void swap(span_iterator& rhs) noexcept { base_type::swap(rhs); } private: - constexpr span_iterator(const base_type& base) : base_type(base) - { - } + constexpr span_iterator(const base_type& base) : base_type(base) {} }; template @@ -431,7 +432,7 @@ namespace details class extent_type { public: - using index_type = std::ptrdiff_t; + using index_type = std::ptrdiff_t; static_assert(Ext >= 0, "A fixed-size span must be >= 0 in size."); @@ -454,7 +455,7 @@ namespace details class extent_type { public: - using index_type = std::ptrdiff_t; + using index_type = std::ptrdiff_t; template explicit constexpr extent_type(extent_type ext) : size_(ext.size()) @@ -504,7 +505,7 @@ public: constexpr span(element_type (&arr)[N]) noexcept : storage_(&arr[0], details::extent_type()) { } - + template > constexpr span(std::array& arr) noexcept : storage_(&arr[0], details::extent_type()) @@ -521,8 +522,7 @@ public: // on Container to be a contiguous sequence container. template ::value && - !details::is_std_array::value && + !details::is_span::value && !details::is_std_array::value && std::is_convertible::value && std::is_convertible().data())>::value>> @@ -549,7 +549,8 @@ public: details::is_allowed_extent_conversion::value && details::is_allowed_element_type_conversion::value>> constexpr span(const span& other) - : storage_(reinterpret_cast(other.data()), details::extent_type(other.size())) + : storage_(reinterpret_cast(other.data()), + details::extent_type(other.size())) { } @@ -559,7 +560,8 @@ public: details::is_allowed_extent_conversion::value && details::is_allowed_element_type_conversion::value>> constexpr span(span&& other) - : storage_(reinterpret_cast(other.data()), details::extent_type(other.size())) + : storage_(reinterpret_cast(other.data()), + details::extent_type(other.size())) { } @@ -664,7 +666,8 @@ private: // [span.comparison], span comparison operators template -constexpr bool operator==(const span& l, const span& r) +constexpr bool operator==(const span& l, + const span& r) { return std::equal(l.begin(), l.end(), r.begin(), r.end()); } @@ -711,7 +714,7 @@ namespace details struct calculate_byte_size : std::integral_constant(sizeof(ElementType) * - static_cast(Extent))> + static_cast(Extent))> { }; diff --git a/include/string_span.h b/include/string_span.h index 723f650..1df7e6e 100644 --- a/include/string_span.h +++ b/include/string_span.h @@ -285,25 +285,27 @@ public: constexpr basic_string_span(element_type (&arr)[N]) : span_(remove_z(arr)) { } - - template > - constexpr basic_string_span(std::array& arr) noexcept - : span_(arr) {} template > - constexpr basic_string_span(const std::array& arr) noexcept - : span_(arr) {} + constexpr basic_string_span(std::array& arr) noexcept : span_(arr) + { + } + + template > + constexpr basic_string_span(const std::array& arr) noexcept : span_(arr) + { + } // Container signature should work for basic_string after C++17 version exists template constexpr basic_string_span(std::basic_string& str) - : span_(&str[0], str.length()) + : span_(&str[0], str.length()) { } template constexpr basic_string_span(const std::basic_string& str) - : span_(&str[0], str.length()) + : span_(&str[0], str.length()) { } @@ -313,7 +315,8 @@ public: !details::is_basic_string_span::value && !details::is_span::value && std::is_convertible::value && - std::is_convertible().data())>::value>> + std::is_convertible().data())>::value>> constexpr basic_string_span(Container& cont) : span_(cont) { } @@ -323,7 +326,8 @@ public: !details::is_basic_string_span::value && !details::is_span::value && std::is_convertible::value && - std::is_convertible().data())>::value>> + std::is_convertible().data())>::value>> constexpr basic_string_span(const Container& cont) : span_(cont) { } @@ -342,53 +346,54 @@ public: template , value_type>::value>> - constexpr basic_string_span(const span, Extent>& other) + constexpr basic_string_span(const span, Extent>& other) : span_(other) { } #endif // from string_span - template ::impl_type, impl_type>::value>> - constexpr basic_string_span(basic_string_span other) + template < + class OtherValueType, std::ptrdiff_t OtherExtent, + class = std::enable_if_t::impl_type, impl_type>::value>> + constexpr basic_string_span(basic_string_span other) : span_(other.data(), other.length()) { } // first Count elements template - constexpr basic_string_span first() const + constexpr basic_string_span first() const { return {span_.template first()}; } - constexpr basic_string_span first(index_type count) const + constexpr basic_string_span first(index_type count) const { return {span_.first(count)}; } // last Count elements template - constexpr basic_string_span last() const + constexpr basic_string_span last() const { return {span_.template last()}; } - constexpr basic_string_span last(index_type count) const + constexpr basic_string_span last(index_type count) const { return {span_.last(count)}; } template - constexpr basic_string_span subspan() const + constexpr basic_string_span subspan() const { return {span_.template subspan()}; } constexpr basic_string_span - subspan(index_type offset, index_type count = dynamic_extent) const + subspan(index_type offset, index_type count = dynamic_extent) const { return {span_.subspan(offset, count)}; } @@ -406,10 +411,10 @@ public: constexpr iterator begin() const noexcept { return span_.begin(); } constexpr iterator end() const noexcept { return span_.end(); } - + constexpr const_iterator cbegin() const noexcept { return span_.cbegin(); } constexpr const_iterator cend() const noexcept { return span_.cend(); } - + constexpr reverse_iterator rbegin() const noexcept { return span_.rbegin(); } constexpr reverse_iterator rend() const noexcept { return span_.rend(); } @@ -417,13 +422,13 @@ public: constexpr const_reverse_iterator crend() const noexcept { return span_.crend(); } private: - static impl_type remove_z(pointer const& sz, std::ptrdiff_t max) + static impl_type remove_z(pointer const& sz, std::ptrdiff_t max) { return {sz, details::length_func()(sz, max)}; } template - static impl_type remove_z(element_type (&sz)[N]) + static impl_type remove_z(element_type (&sz)[N]) { return remove_z(&sz[0], narrow_cast(N)); } @@ -556,8 +561,9 @@ using cwzstring_span = basic_zstring_span; // operator == template ::value || std::is_convertible< - T, gsl::basic_string_span>>::value>> + class = std::enable_if_t< + details::is_basic_string_span::value || + std::is_convertible>>::value>> bool operator==(const gsl::basic_string_span& one, const T& other) noexcept { gsl::basic_string_span> tmp(other); @@ -568,11 +574,10 @@ bool operator==(const gsl::basic_string_span& one, const T& other #endif } -template < - class CharT, std::ptrdiff_t Extent, class T, - class = std::enable_if_t::value && - std::is_convertible>>::value - >> +template ::value && + std::is_convertible>>::value>> bool operator==(const T& one, const gsl::basic_string_span& other) noexcept { gsl::basic_string_span> tmp(one);