more typed_span conversion fixes

This commit is contained in:
arvidn 2017-06-02 06:46:59 +02:00 committed by Arvid Norberg
parent b1b3f0e3e8
commit 5e384ccce3
1 changed files with 12 additions and 8 deletions

View File

@ -72,14 +72,15 @@ namespace libtorrent { namespace aux {
typed_span first(underlying_index n) const
{
TORRENT_ASSERT(n >= 0);
auto s = this->base::first(std::size_t(n));
auto const s = this->base::first(std::size_t(n));
return {s.data(), s.size()};
}
typed_span first(std::size_t n) const
{
TORRENT_ASSERT(n <= std::size_t((std::numeric_limits<underlying_index>::max)()));
return this->base::first(n);
auto const s = this->base::first(n);
return {s.data(), s.size()};
}
template <typename U = underlying_index, typename Cond
@ -87,14 +88,15 @@ namespace libtorrent { namespace aux {
typed_span last(underlying_index n) const
{
TORRENT_ASSERT(n >= 0);
auto s = this->base::last(std::size_t(n));
auto const s = this->base::last(std::size_t(n));
return {s.data(), s.size()};
}
typed_span last(std::size_t n) const
{
TORRENT_ASSERT(n <= std::size_t((std::numeric_limits<underlying_index>::max)()));
return this->base::last(n);
auto const s = this->base::last(n);
return {s.data(), s.size()};
}
template <typename U = underlying_index, typename Cond
@ -102,7 +104,7 @@ namespace libtorrent { namespace aux {
typed_span subspan(underlying_index offset) const
{
TORRENT_ASSERT(offset >= 0);
auto s = this->base::subspan(std::size_t(offset));
auto const s = this->base::subspan(std::size_t(offset));
return {s.data(), s.size()};
}
@ -112,21 +114,23 @@ namespace libtorrent { namespace aux {
{
TORRENT_ASSERT(offset >= 0);
TORRENT_ASSERT(count >= 0);
auto s = this->base::subspan(std::size_t(offset), std::size_t(count));
auto const s = this->base::subspan(std::size_t(offset), std::size_t(count));
return {s.data(), s.size()};
}
typed_span subspan(std::size_t offset) const
{
TORRENT_ASSERT(offset <= std::size_t((std::numeric_limits<underlying_index>::max)()));
return this->base::subspan(offset);
auto const s = this->base::subspan(offset);
return {s.data(), s.size()};
}
typed_span subspan(std::size_t offset, std::size_t count) const
{
TORRENT_ASSERT(offset <= std::size_t((std::numeric_limits<underlying_index>::max)()));
TORRENT_ASSERT(count <= std::size_t((std::numeric_limits<underlying_index>::max)()));
return this->base::subspan(offset, count);
auto const s = this->base::subspan(offset, count);
return {s.data(), s.size()};
}
};