From 14d50a6f770c95c0e87f1fd77aeea051a61a6882 Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Tue, 3 Nov 2015 12:44:09 -0800 Subject: [PATCH] Minor compilation fixes and workarounds. --- include/array_view.h | 5 +++-- include/string_view.h | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/array_view.h b/include/array_view.h index efbaa92..83d9231 100644 --- a/include/array_view.h +++ b/include/array_view.h @@ -1408,8 +1408,9 @@ public: {} // reshape - template 0)>> - constexpr array_view as_array_view(Dimensions2... dims) + // DimCount here is a workaround for a bug in MSVC 2015 + template 0)>> + constexpr array_view as_array_view(Dimensions2... dims) { using BoundsType = typename array_view::bounds_type; auto tobounds = details::static_as_array_view_helper(dims..., details::Sep{}); diff --git a/include/string_view.h b/include/string_view.h index b7a1e8a..b5f73c5 100644 --- a/include/string_view.h +++ b/include/string_view.h @@ -78,13 +78,13 @@ using cwstring_view = basic_string_view; // // Will fail-fast if sentinel cannot be found before max elements are examined. // -template -array_view ensure_sentinel(const T* seq, SizeType max = std::numeric_limits::max()) +template +array_view ensure_sentinel(const T* seq, std::ptrdiff_t max = PTRDIFF_MAX) { auto cur = seq; - while (SizeType(cur - seq) < max && *cur != Sentinel) ++cur; + while ((cur - seq) < max && *cur != Sentinel) ++cur; fail_fast_assert(*cur == Sentinel); - return{ seq, SizeType(cur - seq) }; + return{ seq, 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(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