diff --git a/.gitignore b/.gitignore index 5f5de3e..ea47eb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,14 @@ -tests/unittest-cpp \ No newline at end of file +tests/unittest-cpp +CMakeFiles +tests/CMakeFiles +tests/Debug +*.opensdf +*.sdf +tests/*tests.dir +*.vcxproj +*.vcxproj.filters +*.sln +*.tlog +Testing/Temporary/*.* +CMakeCache.txt +*.suo diff --git a/include/array_view.h b/include/array_view.h index 6d4fde2..efbaa92 100644 --- a/include/array_view.h +++ b/include/array_view.h @@ -508,7 +508,7 @@ namespace details template 1), typename Ret = std::enable_if_t>> constexpr Ret shift_left(const index& other) noexcept { - Ret ret; + Ret ret{}; for (size_t i = 0; i < Rank - 1; ++i) { ret[i] = other[i + 1]; @@ -865,7 +865,7 @@ public: constexpr bounds_iterator& operator+=(difference_type n) noexcept { auto linear_idx = linearize(curr) + n; - std::remove_const_t stride; + std::remove_const_t stride = 0; stride[rank - 1] = 1; for (size_t i = rank - 1; i-- > 0;) { diff --git a/include/string_view.h b/include/string_view.h index 04909f8..b7a1e8a 100644 --- a/include/string_view.h +++ b/include/string_view.h @@ -82,9 +82,9 @@ template array_view ensure_sentinel(const T* seq, SizeType max = std::numeric_limits::max()) { auto cur = seq; - while ((cur - seq) < max && *cur != Sentinel) ++cur; + while (SizeType(cur - seq) < max && *cur != Sentinel) ++cur; fail_fast_assert(*cur == Sentinel); - return{ seq, cur - seq }; + return{ seq, SizeType(cur - seq) }; } @@ -96,7 +96,7 @@ array_view ensure_sentinel(const T* seq, SizeType max = std::n template inline basic_string_view ensure_z(T* const & sz, std::ptrdiff_t max = PTRDIFF_MAX) { - return ensure_sentinel<0>(sz, max); + return ensure_sentinel(sz, max); } // TODO (neilmac) there is probably a better template-magic way to get the const and non-const overloads to share an implementation diff --git a/tests/string_view_tests.cpp b/tests/string_view_tests.cpp index fb57845..e553ccd 100644 --- a/tests/string_view_tests.cpp +++ b/tests/string_view_tests.cpp @@ -79,6 +79,14 @@ SUITE(string_view_tests) } } + TEST(TestConstructFromConstCharPointer) + { + const char* s = "Hello"; + cstring_view<> v = ensure_z(s); + CHECK(v.length() == 5); + CHECK(v.used_length() == v.length()); + } + TEST(TestConversionToConst) { char stack_string[] = "Hello";