aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkile0 <kile@microsoft.com>2018-11-28 11:52:11 -0800
committerAnna Gringauze <annagrin@microsoft.com>2018-11-28 11:52:11 -0800
commit5a7093f983aff4f000f804caf3ab0ab703660cfc (patch)
treed4fa9e12f428549c0c6befb02775571c260413ca
parentb67337571920363b7a7845de187f058e5dc3ba00 (diff)
downloadMicrosoft-GSL-5a7093f983aff4f000f804caf3ab0ab703660cfc.tar.gz
Use the c++17 constexpr if in CheckRange if possible (#753)
* change c++17 to use constexpr if in CheckRange * remove unnecessary macro * use the portable feature test macro rather than direct version check
-rw-r--r--include/gsl/span4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/gsl/span b/include/gsl/span
index b356ee9..54f5f6b 100644
--- a/include/gsl/span
+++ b/include/gsl/span
@@ -556,7 +556,11 @@ private:
// wrap around to a value always greater than size when casted.
// check if we have enough space to wrap around
+#if defined(__cpp_if_constexpr)
+ if constexpr (sizeof(index_type) <= sizeof(size_t))
+#else
if (sizeof(index_type) <= sizeof(size_t))
+#endif
{
return narrow_cast<size_t>(idx) < narrow_cast<size_t>(size);
}