mirror of
https://github.com/microsoft/GSL.git
synced 2025-05-13 01:15:18 -04:00
Cleanup additional GCC warnings
When turning on the following flags, several additional warnings were generated, which have been cleaned up in this patch. The flags included: -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wctor-dtor-privacy -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Woverloaded-virtual
This commit is contained in:
committed by
Neil MacIntosh
parent
38f453d608
commit
d641796b21
@ -1451,7 +1451,7 @@ public:
|
||||
constexpr size_type length() const noexcept { return this->size(); }
|
||||
|
||||
// length of the multi_span in bytes
|
||||
constexpr size_type size_bytes() const noexcept { return sizeof(value_type) * this->size(); }
|
||||
constexpr size_type size_bytes() const noexcept { return narrow_cast<size_type>(sizeof(value_type)) * this->size(); }
|
||||
|
||||
// length of the multi_span in bytes
|
||||
constexpr size_type length_bytes() const noexcept { return this->size_bytes(); }
|
||||
@ -1653,7 +1653,8 @@ constexpr auto as_multi_span(multi_span<const byte, Dimensions...> s) noexcept -
|
||||
ConstByteSpan::bounds_type::static_size % narrow_cast<std::ptrdiff_t>(sizeof(U)) == 0),
|
||||
"Target type must be a trivial type and its size must match the byte array size");
|
||||
|
||||
Expects((s.size_bytes() % sizeof(U)) == 0 && (s.size_bytes() / sizeof(U)) < PTRDIFF_MAX);
|
||||
Expects((s.size_bytes() % narrow_cast<std::ptrdiff_t>(sizeof(U))) == 0 &&
|
||||
(s.size_bytes() / narrow_cast<std::ptrdiff_t>(sizeof(U))) < PTRDIFF_MAX);
|
||||
return {reinterpret_cast<const U*>(s.data()),
|
||||
s.size_bytes() / narrow_cast<std::ptrdiff_t>(sizeof(U))};
|
||||
}
|
||||
|
2
gsl/span
2
gsl/span
@ -494,7 +494,7 @@ public:
|
||||
constexpr index_type length() const noexcept { return size(); }
|
||||
constexpr index_type size() const noexcept { return storage_.size(); }
|
||||
constexpr index_type length_bytes() const noexcept { return size_bytes(); }
|
||||
constexpr index_type size_bytes() const noexcept { return size() * sizeof(element_type); }
|
||||
constexpr index_type size_bytes() const noexcept { return size() * narrow_cast<index_type>(sizeof(element_type)); }
|
||||
constexpr bool empty() const noexcept { return size() == 0; }
|
||||
|
||||
// [span.elem], span element access
|
||||
|
@ -331,7 +331,7 @@ public:
|
||||
// Container signature should work for basic_string after C++17 version exists
|
||||
template <class Traits, class Allocator>
|
||||
constexpr basic_string_span(std::basic_string<element_type, Traits, Allocator>& str)
|
||||
: span_(&str[0], str.length())
|
||||
: span_(&str[0], narrow_cast<std::ptrdiff_t>(str.length()))
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user