From 59cf62652a4bb6ee5809727f86ed7a5b218c3821 Mon Sep 17 00:00:00 2001 From: Matt Newport Date: Mon, 19 Oct 2015 18:55:46 -0700 Subject: [PATCH 1/4] Add .gitignore --- .gitignore | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5f5de3e..3fb78a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,13 @@ -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 From 9e9eddcddfef2fd6f80002f476cfb9f46b511c31 Mon Sep 17 00:00:00 2001 From: Matt Newport Date: Mon, 19 Oct 2015 18:58:26 -0700 Subject: [PATCH 2/4] Updated .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3fb78a5..ea47eb3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ tests/*tests.dir *.tlog Testing/Temporary/*.* CMakeCache.txt +*.suo From 0cbdc7036d2499967c59c50587242f0611c969b6 Mon Sep 17 00:00:00 2001 From: Matt Newport Date: Mon, 26 Oct 2015 18:23:14 -0700 Subject: [PATCH 3/4] Fixed string_view::ensure_z() for const char*. --- include/string_view.h | 6 +++--- tests/string_view_tests.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/string_view.h b/include/string_view.h index 4076d52..7080ce5 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, size_t max = std::numeric_limits::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"; From b39571781e4ce566de162cb187445b95b56cfd6f Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 2 Nov 2015 11:47:14 -0800 Subject: [PATCH 4/4] array_view: explicitly initialize constexpr function variables --- include/array_view.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/array_view.h b/include/array_view.h index 14d8888..69559f6 100644 --- a/include/array_view.h +++ b/include/array_view.h @@ -541,7 +541,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]; @@ -887,7 +887,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;) {