From 966c4498d4e8024f821cb35ceba934dba10a1922 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 23 Oct 2020 19:53:07 -0700 Subject: Don't use a template parameter as a variable And try to silence an MSVC warning about a constant overflow. --- common/alspan.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/alspan.h b/common/alspan.h index c1ad6f9e..f2c42b16 100644 --- a/common/alspan.h +++ b/common/alspan.h @@ -158,12 +158,19 @@ public: return span{mData+(E-C), C}; } - template - constexpr span subspan() const + template + constexpr auto subspan() const -> std::enable_if_t> { static_assert(E >= O, "Offset exceeds extent"); - static_assert(E-O >= RealC, "New size exceeds original capacity"); - return span{mData+O, RealC}; + static_assert(E-O >= C, "New size exceeds original capacity"); + return span{mData+O, C}; + } + + template + constexpr auto subspan() const -> std::enable_if_t> + { + static_assert(E >= O, "Offset exceeds extent"); + return span{mData+O, E-O}; } /* NOTE: Can't declare objects of a specialized template class prior to @@ -257,9 +264,13 @@ public: constexpr span last(size_t count) const { return (count >= size()) ? *this : span{mDataEnd-count, mDataEnd}; } + template + constexpr auto subspan() const -> std::enable_if_t> + { return span{mData+O, C}; } + template - constexpr span subspan() const - { return span{mData+O, (C!=dynamic_extent) ? mData+O+C : mDataEnd}; } + constexpr auto subspan() const -> std::enable_if_t> + { return span{mData+O, mDataEnd}; } constexpr span subspan(size_t offset, size_t count=dynamic_extent) const { -- cgit v1.2.3