Applied clang-format.

This commit is contained in:
Neil MacIntosh 2016-07-26 19:19:47 -07:00
parent 4de3d4e3e3
commit 6fadce975b
3 changed files with 69 additions and 58 deletions

View File

@ -740,7 +740,8 @@ public:
} }
constexpr strided_bounds(const index_type& extents, const index_type& strides) noexcept 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; using index_size_type = typename IndexType::value_type;
template <typename Bounds> template <typename Bounds>
explicit bounds_iterator(const Bounds& bnd, value_type curr) noexcept 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<Bounds>::value, "Bounds type must be provided"); static_assert(is_bounds<Bounds>::value, "Bounds type must be provided");
} }
@ -1132,7 +1134,7 @@ namespace details
template <typename T, typename Arg, typename... Args> template <typename T, typename Arg, typename... Args>
std::enable_if_t< std::enable_if_t<
!std::is_same<Arg, dim<dynamic_range>>::value && !std::is_same<Arg, Sep>::value, T> !std::is_same<Arg, dim<dynamic_range>>::value && !std::is_same<Arg, Sep>::value, T>
static_as_span_helper(Arg, Args... args) static_as_span_helper(Arg, Args... args)
{ {
return static_as_span_helper<T>(args...); return static_as_span_helper<T>(args...);
} }
@ -1250,8 +1252,8 @@ public:
} }
// construct from pointer + length - multidimensional // construct from pointer + length - multidimensional
constexpr multi_span(pointer data, bounds_type bounds) noexcept constexpr multi_span(pointer data, bounds_type bounds) noexcept : data_(data),
: data_(data), bounds_(std::move(bounds)) bounds_(std::move(bounds))
{ {
Expects((bounds_.size() > 0 && data != nullptr) || bounds_.size() == 0); Expects((bounds_.size() > 0 && data != nullptr) || bounds_.size() == 0);
} }
@ -1347,7 +1349,8 @@ public:
typename = std::enable_if_t<std::is_convertible<OtherValueType, ValueType>::value && typename = std::enable_if_t<std::is_convertible<OtherValueType, ValueType>::value &&
std::is_convertible<OtherBounds, bounds_type>::value>> std::is_convertible<OtherBounds, bounds_type>::value>>
constexpr multi_span(multi_span<OtherValueType, OtherDimensions...> other) noexcept constexpr multi_span(multi_span<OtherValueType, OtherDimensions...> other) noexcept
: data_(other.data_), bounds_(other.bounds_) : data_(other.data_),
bounds_(other.bounds_)
{ {
} }

View File

@ -120,30 +120,33 @@ namespace details
template <class From, class To> template <class From, class To>
struct is_allowed_pointer_conversion struct is_allowed_pointer_conversion
: public std::integral_constant<bool, std::is_pointer<From>::value && std::is_pointer<To>::value && : public std::integral_constant<bool, std::is_pointer<From>::value &&
std::is_convertible<From, To>::value> std::is_pointer<To>::value &&
std::is_convertible<From, To>::value>
{ {
}; };
template <class From, class To> template <class From, class To>
struct is_allowed_integral_conversion struct is_allowed_integral_conversion
: public std::integral_constant<bool, std::is_integral<From>::value && std::is_integral<To>::value && : public std::integral_constant<
sizeof(From) == sizeof(To) && alignof(From) == alignof(To) && bool, std::is_integral<From>::value && std::is_integral<To>::value &&
std::is_convertible<From, To>::value> sizeof(From) == sizeof(To) && alignof(From) == alignof(To) &&
std::is_convertible<From, To>::value>
{ {
}; };
template <std::ptrdiff_t From, std::ptrdiff_t To> template <std::ptrdiff_t From, std::ptrdiff_t To>
struct is_allowed_extent_conversion struct is_allowed_extent_conversion
: public std::integral_constant<bool, From == To || From == gsl::dynamic_extent || To == gsl::dynamic_extent> : public std::integral_constant<bool, From == To || From == gsl::dynamic_extent ||
To == gsl::dynamic_extent>
{ {
}; };
template <class From, class To> template <class From, class To>
struct is_allowed_element_type_conversion struct is_allowed_element_type_conversion
: public std::integral_constant<bool, std::is_same<From, std::remove_cv_t<To>>::value || : public std::integral_constant<bool, std::is_same<From, std::remove_cv_t<To>>::value ||
is_allowed_pointer_conversion<From, To>::value || is_allowed_pointer_conversion<From, To>::value ||
is_allowed_integral_conversion<From, To>::value> is_allowed_integral_conversion<From, To>::value>
{ {
}; };
@ -392,9 +395,7 @@ namespace details
void swap(span_iterator& rhs) noexcept { base_type::swap(rhs); } void swap(span_iterator& rhs) noexcept { base_type::swap(rhs); }
private: private:
constexpr span_iterator(const base_type& base) : base_type(base) constexpr span_iterator(const base_type& base) : base_type(base) {}
{
}
}; };
template <typename Span> template <typename Span>
@ -431,7 +432,7 @@ namespace details
class extent_type class extent_type
{ {
public: 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."); static_assert(Ext >= 0, "A fixed-size span must be >= 0 in size.");
@ -454,7 +455,7 @@ namespace details
class extent_type<dynamic_extent> class extent_type<dynamic_extent>
{ {
public: public:
using index_type = std::ptrdiff_t; using index_type = std::ptrdiff_t;
template <index_type Other> template <index_type Other>
explicit constexpr extent_type(extent_type<Other> ext) : size_(ext.size()) explicit constexpr extent_type(extent_type<Other> ext) : size_(ext.size())
@ -504,7 +505,7 @@ public:
constexpr span(element_type (&arr)[N]) noexcept : storage_(&arr[0], details::extent_type<N>()) constexpr span(element_type (&arr)[N]) noexcept : storage_(&arr[0], details::extent_type<N>())
{ {
} }
template <size_t N, class ArrayElementType = std::remove_const_t<element_type>> template <size_t N, class ArrayElementType = std::remove_const_t<element_type>>
constexpr span(std::array<ArrayElementType, N>& arr) noexcept constexpr span(std::array<ArrayElementType, N>& arr) noexcept
: storage_(&arr[0], details::extent_type<N>()) : storage_(&arr[0], details::extent_type<N>())
@ -521,8 +522,7 @@ public:
// on Container to be a contiguous sequence container. // on Container to be a contiguous sequence container.
template <class Container, template <class Container,
class = std::enable_if_t< class = std::enable_if_t<
!details::is_span<Container>::value && !details::is_span<Container>::value && !details::is_std_array<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<typename Container::pointer, std::is_convertible<typename Container::pointer,
decltype(std::declval<Container>().data())>::value>> decltype(std::declval<Container>().data())>::value>>
@ -549,7 +549,8 @@ public:
details::is_allowed_extent_conversion<OtherExtent, Extent>::value && details::is_allowed_extent_conversion<OtherExtent, Extent>::value &&
details::is_allowed_element_type_conversion<OtherElementType, element_type>::value>> details::is_allowed_element_type_conversion<OtherElementType, element_type>::value>>
constexpr span(const span<OtherElementType, OtherExtent>& other) constexpr span(const span<OtherElementType, OtherExtent>& other)
: storage_(reinterpret_cast<pointer>(other.data()), details::extent_type<OtherExtent>(other.size())) : storage_(reinterpret_cast<pointer>(other.data()),
details::extent_type<OtherExtent>(other.size()))
{ {
} }
@ -559,7 +560,8 @@ public:
details::is_allowed_extent_conversion<OtherExtent, Extent>::value && details::is_allowed_extent_conversion<OtherExtent, Extent>::value &&
details::is_allowed_element_type_conversion<OtherElementType, element_type>::value>> details::is_allowed_element_type_conversion<OtherElementType, element_type>::value>>
constexpr span(span<OtherElementType, OtherExtent>&& other) constexpr span(span<OtherElementType, OtherExtent>&& other)
: storage_(reinterpret_cast<pointer>(other.data()), details::extent_type<OtherExtent>(other.size())) : storage_(reinterpret_cast<pointer>(other.data()),
details::extent_type<OtherExtent>(other.size()))
{ {
} }
@ -664,7 +666,8 @@ private:
// [span.comparison], span comparison operators // [span.comparison], span comparison operators
template <class ElementType, std::ptrdiff_t FirstExtent, std::ptrdiff_t SecondExtent> template <class ElementType, std::ptrdiff_t FirstExtent, std::ptrdiff_t SecondExtent>
constexpr bool operator==(const span<ElementType, FirstExtent>& l, const span<ElementType, SecondExtent>& r) constexpr bool operator==(const span<ElementType, FirstExtent>& l,
const span<ElementType, SecondExtent>& r)
{ {
return std::equal(l.begin(), l.end(), r.begin(), r.end()); return std::equal(l.begin(), l.end(), r.begin(), r.end());
} }
@ -711,7 +714,7 @@ namespace details
struct calculate_byte_size struct calculate_byte_size
: std::integral_constant<std::ptrdiff_t, : std::integral_constant<std::ptrdiff_t,
static_cast<std::ptrdiff_t>(sizeof(ElementType) * static_cast<std::ptrdiff_t>(sizeof(ElementType) *
static_cast<std::size_t>(Extent))> static_cast<std::size_t>(Extent))>
{ {
}; };

View File

@ -285,25 +285,27 @@ public:
constexpr basic_string_span(element_type (&arr)[N]) : span_(remove_z(arr)) constexpr basic_string_span(element_type (&arr)[N]) : span_(remove_z(arr))
{ {
} }
template <size_t N, class ArrayElementType = std::remove_const_t<element_type>>
constexpr basic_string_span(std::array<ArrayElementType, N>& arr) noexcept
: span_(arr) {}
template <size_t N, class ArrayElementType = std::remove_const_t<element_type>> template <size_t N, class ArrayElementType = std::remove_const_t<element_type>>
constexpr basic_string_span(const std::array<ArrayElementType, N>& arr) noexcept constexpr basic_string_span(std::array<ArrayElementType, N>& arr) noexcept : span_(arr)
: span_(arr) {} {
}
template <size_t N, class ArrayElementType = std::remove_const_t<element_type>>
constexpr basic_string_span(const std::array<ArrayElementType, N>& arr) noexcept : span_(arr)
{
}
// Container signature should work for basic_string after C++17 version exists // Container signature should work for basic_string after C++17 version exists
template <class Traits, class Allocator> template <class Traits, class Allocator>
constexpr basic_string_span(std::basic_string<element_type, Traits, Allocator>& str) constexpr basic_string_span(std::basic_string<element_type, Traits, Allocator>& str)
: span_(&str[0], str.length()) : span_(&str[0], str.length())
{ {
} }
template <class Traits, class Allocator> template <class Traits, class Allocator>
constexpr basic_string_span(const std::basic_string<element_type, Traits, Allocator>& str) constexpr basic_string_span(const std::basic_string<element_type, Traits, Allocator>& str)
: span_(&str[0], str.length()) : span_(&str[0], str.length())
{ {
} }
@ -313,7 +315,8 @@ public:
!details::is_basic_string_span<Container>::value && !details::is_basic_string_span<Container>::value &&
!details::is_span<Container>::value && !details::is_span<Container>::value &&
std::is_convertible<typename Container::pointer, pointer>::value && std::is_convertible<typename Container::pointer, pointer>::value &&
std::is_convertible<typename Container::pointer, decltype(std::declval<Container>().data())>::value>> std::is_convertible<typename Container::pointer,
decltype(std::declval<Container>().data())>::value>>
constexpr basic_string_span(Container& cont) : span_(cont) constexpr basic_string_span(Container& cont) : span_(cont)
{ {
} }
@ -323,7 +326,8 @@ public:
!details::is_basic_string_span<Container>::value && !details::is_basic_string_span<Container>::value &&
!details::is_span<Container>::value && !details::is_span<Container>::value &&
std::is_convertible<typename Container::pointer, pointer>::value && std::is_convertible<typename Container::pointer, pointer>::value &&
std::is_convertible<typename Container::pointer, decltype(std::declval<Container>().data())>::value>> std::is_convertible<typename Container::pointer,
decltype(std::declval<Container>().data())>::value>>
constexpr basic_string_span(const Container& cont) : span_(cont) constexpr basic_string_span(const Container& cont) : span_(cont)
{ {
} }
@ -342,53 +346,54 @@ public:
template <typename = std::enable_if_t< template <typename = std::enable_if_t<
!std::is_same<std::remove_const_t<element_type>, value_type>::value>> !std::is_same<std::remove_const_t<element_type>, value_type>::value>>
constexpr basic_string_span(const span<std::remove_const_t<element_type>, Extent>& other) constexpr basic_string_span(const span<std::remove_const_t<element_type>, Extent>& other)
: span_(other) : span_(other)
{ {
} }
#endif #endif
// from string_span // from string_span
template <class OtherValueType, std::ptrdiff_t OtherExtent, template <
class = std::enable_if_t<std::is_convertible< class OtherValueType, std::ptrdiff_t OtherExtent,
typename basic_string_span<OtherValueType, OtherExtent>::impl_type, impl_type>::value>> class = std::enable_if_t<std::is_convertible<
constexpr basic_string_span(basic_string_span<OtherValueType, OtherExtent> other) typename basic_string_span<OtherValueType, OtherExtent>::impl_type, impl_type>::value>>
constexpr basic_string_span(basic_string_span<OtherValueType, OtherExtent> other)
: span_(other.data(), other.length()) : span_(other.data(), other.length())
{ {
} }
// first Count elements // first Count elements
template <index_type Count> template <index_type Count>
constexpr basic_string_span<element_type, Count> first() const constexpr basic_string_span<element_type, Count> first() const
{ {
return {span_.template first<Count>()}; return {span_.template first<Count>()};
} }
constexpr basic_string_span<index_type, dynamic_extent> first(index_type count) const constexpr basic_string_span<index_type, dynamic_extent> first(index_type count) const
{ {
return {span_.first(count)}; return {span_.first(count)};
} }
// last Count elements // last Count elements
template <index_type Count> template <index_type Count>
constexpr basic_string_span<index_type, Count> last() const constexpr basic_string_span<index_type, Count> last() const
{ {
return {span_.template last<Count>()}; return {span_.template last<Count>()};
} }
constexpr basic_string_span<element_type, dynamic_extent> last(index_type count) const constexpr basic_string_span<element_type, dynamic_extent> last(index_type count) const
{ {
return {span_.last(count)}; return {span_.last(count)};
} }
template <index_type Offset, index_type Count> template <index_type Offset, index_type Count>
constexpr basic_string_span<element_type, Count> subspan() const constexpr basic_string_span<element_type, Count> subspan() const
{ {
return {span_.template subspan<Offset, Count>()}; return {span_.template subspan<Offset, Count>()};
} }
constexpr basic_string_span<element_type, dynamic_extent> constexpr basic_string_span<element_type, dynamic_extent>
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)}; return {span_.subspan(offset, count)};
} }
@ -406,10 +411,10 @@ public:
constexpr iterator begin() const noexcept { return span_.begin(); } constexpr iterator begin() const noexcept { return span_.begin(); }
constexpr iterator end() const noexcept { return span_.end(); } constexpr iterator end() const noexcept { return span_.end(); }
constexpr const_iterator cbegin() const noexcept { return span_.cbegin(); } constexpr const_iterator cbegin() const noexcept { return span_.cbegin(); }
constexpr const_iterator cend() const noexcept { return span_.cend(); } constexpr const_iterator cend() const noexcept { return span_.cend(); }
constexpr reverse_iterator rbegin() const noexcept { return span_.rbegin(); } constexpr reverse_iterator rbegin() const noexcept { return span_.rbegin(); }
constexpr reverse_iterator rend() const noexcept { return span_.rend(); } constexpr reverse_iterator rend() const noexcept { return span_.rend(); }
@ -417,13 +422,13 @@ public:
constexpr const_reverse_iterator crend() const noexcept { return span_.crend(); } constexpr const_reverse_iterator crend() const noexcept { return span_.crend(); }
private: 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<element_type>()(sz, max)}; return {sz, details::length_func<element_type>()(sz, max)};
} }
template <size_t N> template <size_t N>
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<std::ptrdiff_t>(N)); return remove_z(&sz[0], narrow_cast<std::ptrdiff_t>(N));
} }
@ -556,8 +561,9 @@ using cwzstring_span = basic_zstring_span<const wchar_t, Max>;
// operator == // operator ==
template <class CharT, std::ptrdiff_t Extent, class T, template <class CharT, std::ptrdiff_t Extent, class T,
class = std::enable_if_t<details::is_basic_string_span<T>::value || std::is_convertible< class = std::enable_if_t<
T, gsl::basic_string_span<std::add_const_t<CharT>>>::value>> details::is_basic_string_span<T>::value ||
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>>>::value>>
bool operator==(const gsl::basic_string_span<CharT, Extent>& one, const T& other) noexcept bool operator==(const gsl::basic_string_span<CharT, Extent>& one, const T& other) noexcept
{ {
gsl::basic_string_span<std::add_const_t<CharT>> tmp(other); gsl::basic_string_span<std::add_const_t<CharT>> tmp(other);
@ -568,11 +574,10 @@ bool operator==(const gsl::basic_string_span<CharT, Extent>& one, const T& other
#endif #endif
} }
template < template <class CharT, std::ptrdiff_t Extent, class T,
class CharT, std::ptrdiff_t Extent, class T, class = std::enable_if_t<
class = std::enable_if_t<!details::is_basic_string_span<T>::value && !details::is_basic_string_span<T>::value &&
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>>>::value std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>>>::value>>
>>
bool operator==(const T& one, const gsl::basic_string_span<CharT, Extent>& other) noexcept bool operator==(const T& one, const gsl::basic_string_span<CharT, Extent>& other) noexcept
{ {
gsl::basic_string_span<std::add_const_t<CharT>> tmp(one); gsl::basic_string_span<std::add_const_t<CharT>> tmp(one);