diff --git a/include/gsl/gsl_algorithm b/include/gsl/gsl_algorithm index c2ba31f..6813b6c 100644 --- a/include/gsl/gsl_algorithm +++ b/include/gsl/gsl_algorithm @@ -37,8 +37,8 @@ namespace gsl { // Note: this will generate faster code than std::copy using span iterator in older msvc+stl // not necessary for msvc since VS2017 15.8 (_MSC_VER >= 1915) -template +template void copy(span src, span dest) { static_assert(std::is_assignable::value, diff --git a/include/gsl/span b/include/gsl/span index 1b06fb3..6e7e791 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -592,7 +592,7 @@ private: } else { - return idx >= 0 && idx < size; + return idx < size; } } diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index d94ed20..ac05af1 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -966,7 +966,7 @@ TEST(span_test, from_array_constructor) EXPECT_TRUE(av.subspan(5).size() == 0); EXPECT_DEATH(av.subspan(6).size(), deathstring); const auto av2 = av.subspan(1); - for (std::size_t i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); + for (std::size_t i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == static_cast(i) + 2); } { @@ -977,7 +977,7 @@ TEST(span_test, from_array_constructor) EXPECT_TRUE(av.subspan(5).size() == 0); EXPECT_DEATH(av.subspan(6).size(), deathstring); const auto av2 = av.subspan(1); - for (std::size_t i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == i + 2); + for (std::size_t i = 0; i < 4; ++i) EXPECT_TRUE(av2[i] == static_cast(i) + 2); } } diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp index e501bba..dd5a0de 100644 --- a/tests/string_span_tests.cpp +++ b/tests/string_span_tests.cpp @@ -84,7 +84,7 @@ czstring_span<> CreateTempName(string_span<> span) { Expects(span.size() > 1); - int last = 0; + std::size_t last = 0; if (span.size() > 4) { span[0] = 't'; span[1] = 'm'; @@ -101,7 +101,7 @@ cwzstring_span<> CreateTempNameW(wstring_span<> span) { Expects(span.size() > 1); - int last = 0; + std::size_t last = 0; if (span.size() > 4) { span[0] = L't'; span[1] = L'm'; @@ -118,7 +118,7 @@ cu16zstring_span<> CreateTempNameU16(u16string_span<> span) { Expects(span.size() > 1); - int last = 0; + std::size_t last = 0; if (span.size() > 4) { span[0] = u't'; span[1] = u'm'; @@ -135,7 +135,7 @@ cu32zstring_span<> CreateTempNameU32(u32string_span<> span) { Expects(span.size() > 1); - int last = 0; + std::size_t last = 0; if (span.size() > 4) { span[0] = U't'; span[1] = U'm';