aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt21
-rw-r--r--include/gsl/gsl (renamed from gsl/gsl)62
-rw-r--r--include/gsl/gsl_algorithm (renamed from gsl/gsl_algorithm)20
-rw-r--r--include/gsl/gsl_assert (renamed from gsl/gsl_assert)2
-rw-r--r--include/gsl/gsl_byte (renamed from gsl/gsl_byte)46
-rw-r--r--include/gsl/gsl_util (renamed from gsl/gsl_util)74
-rw-r--r--include/gsl/multi_span (renamed from gsl/multi_span)529
-rw-r--r--include/gsl/span (renamed from gsl/span)246
-rw-r--r--include/gsl/string_span (renamed from gsl/string_span)220
-rw-r--r--tests/CMakeLists.txt5
-rw-r--r--tests/multi_span_tests.cpp4
-rw-r--r--tests/strided_span_tests.cpp62
-rw-r--r--tests/string_span_tests.cpp8
14 files changed, 604 insertions, 697 deletions
diff --git a/.gitignore b/.gitignore
index d452689..ee5ca3c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,5 @@ tests/*tests.dir
Testing/Temporary/*.*
CMakeCache.txt
*.suo
+.vs/
+.vscode/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9344ef4..4b96546 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,25 +2,10 @@ cmake_minimum_required(VERSION 2.8.7)
project(GSL CXX)
-set(GSL_HEADERS
- "gsl/gsl"
- "gsl/gsl_assert"
- "gsl/gsl_byte"
- "gsl/gsl_util"
- "gsl/multi_span"
- "gsl/span"
- "gsl/string_span"
- "gsl/gsl_algorithm"
-)
-
-include_directories(
- ${CMAKE_CURRENT_BINARY_DIR}
-)
-
-install(FILES ${GSL_HEADERS}
- DESTINATION include/gsl
+install(
+ DIRECTORY include/gsl
+ DESTINATION include
)
enable_testing()
-
add_subdirectory(tests)
diff --git a/gsl/gsl b/include/gsl/gsl
index 12a9676..76eb0be 100644
--- a/gsl/gsl
+++ b/include/gsl/gsl
@@ -19,32 +19,28 @@
#ifndef GSL_GSL_H
#define GSL_GSL_H
-#include "gsl_assert" // Ensures/Expects
-#include "gsl_util" // finally()/narrow()/narrow_cast()...
-#include "multi_span" // multi_span, strided_span...
-#include "span" // span
-#include "string_span" // zstring, string_span, zstring_builder...
+#include <gsl/gsl_assert> // Ensures/Expects
+#include <gsl/gsl_util> // finally()/narrow()/narrow_cast()...
+#include <gsl/multi_span> // multi_span, strided_span...
+#include <gsl/span> // span
+#include <gsl/string_span> // zstring, string_span, zstring_builder...
#include <memory>
-#ifdef _MSC_VER
-
-// No MSVC does constexpr fully yet
-#pragma push_macro("constexpr")
-#define constexpr /*constexpr*/
-
-// MSVC 2013 workarounds
-#if _MSC_VER <= 1800
-// noexcept is not understood
-#pragma push_macro("noexcept")
-#define noexcept /*noexcept*/
+#if defined(_MSC_VER) && _MSC_VER < 1910
+ #pragma push_macro("constexpr")
+ #define constexpr /*constexpr*/
-// turn off some misguided warnings
-#pragma warning(push)
-#pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior
+ // MSVC 2013 workarounds
+ #if _MSC_VER <= 1800
+ // noexcept is not understood
+ #pragma push_macro("noexcept")
+ #define noexcept /*noexcept*/
-#endif // _MSC_VER <= 1800
-
-#endif // _MSC_VER
+ // turn off some misguided warnings
+ #pragma warning(push)
+ #pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior
+ #endif // _MSC_VER <= 1800
+#endif // defined(_MSC_VER) && _MSC_VER < 1910
namespace gsl
{
@@ -153,20 +149,16 @@ struct hash<gsl::not_null<T>>
} // namespace std
-#ifdef _MSC_VER
-
-#undef constexpr
-#pragma pop_macro("constexpr")
-
-#if _MSC_VER <= 1800
-
-#undef noexcept
-#pragma pop_macro("noexcept")
-
-#pragma warning(pop)
+#if defined(_MSC_VER) && _MSC_VER < 1910
+ #undef constexpr
+ #pragma pop_macro("constexpr")
-#endif // _MSC_VER <= 1800
+ #if _MSC_VER <= 1800
+ #undef noexcept
+ #pragma pop_macro("noexcept")
-#endif // _MSC_VER
+ #pragma warning(pop)
+ #endif // _MSC_VER <= 1800
+#endif // defined(_MSC_VER) && _MSC_VER < 1910
#endif // GSL_GSL_H
diff --git a/gsl/gsl_algorithm b/include/gsl/gsl_algorithm
index 34c6c34..9a5c36b 100644
--- a/gsl/gsl_algorithm
+++ b/include/gsl/gsl_algorithm
@@ -19,21 +19,19 @@
#ifndef GSL_ALGORITHM_H
#define GSL_ALGORITHM_H
-#include "span"
+#include <gsl/span>
#include <algorithm>
#ifdef _MSC_VER
+ #pragma warning(push)
-#pragma warning(push)
-
-// turn off some warnings that are noisy about our Expects statements
-#pragma warning(disable : 4127) // conditional expression is constant
-
-// blanket turn off warnings from CppCoreCheck for now
-// so people aren't annoyed by them when running the tool.
-// more targeted suppressions will be added in a future update to the GSL
-#pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495)
+ // turn off some warnings that are noisy about our Expects statements
+ #pragma warning(disable : 4127) // conditional expression is constant
+ // blanket turn off warnings from CppCoreCheck for now
+ // so people aren't annoyed by them when running the tool.
+ // more targeted suppressions will be added in a future update to the GSL
+ #pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495)
#endif // _MSC_VER
namespace gsl
@@ -55,7 +53,7 @@ void copy(span<SrcElementType, SrcExtent> src, span<DestElementType, DestExtent>
} // namespace gsl
#ifdef _MSC_VER
-#pragma warning(pop)
+ #pragma warning(pop)
#endif // _MSC_VER
#endif // GSL_ALGORITHM_H
diff --git a/gsl/gsl_assert b/include/gsl/gsl_assert
index 6d8760d..04f34b3 100644
--- a/gsl/gsl_assert
+++ b/include/gsl/gsl_assert
@@ -30,7 +30,7 @@
// 2. GSL_THROW_ON_CONTRACT_VIOLATION: a gsl::fail_fast exception will be thrown
// 3. GSL_UNENFORCED_ON_CONTRACT_VIOLATION: nothing happens
//
-#if !(defined(GSL_THROW_ON_CONTRACT_VIOLATION) ^ defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) ^ \
+#if !(defined(GSL_THROW_ON_CONTRACT_VIOLATION) || defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) || \
defined(GSL_UNENFORCED_ON_CONTRACT_VIOLATION))
#define GSL_TERMINATE_ON_CONTRACT_VIOLATION
#endif
diff --git a/gsl/gsl_byte b/include/gsl/gsl_byte
index cc49444..d854e40 100644
--- a/gsl/gsl_byte
+++ b/include/gsl/gsl_byte
@@ -22,25 +22,21 @@
#include <type_traits>
#ifdef _MSC_VER
+ #pragma warning(push)
-#pragma warning(push)
+ // don't warn about function style casts in byte related operators
+ #pragma warning(disable : 26493)
-// don't warn about function style casts in byte related operators
-#pragma warning(disable : 26493)
-
-// MSVC 2013 workarounds
-#if _MSC_VER <= 1800
-
-// constexpr is not understood
-#pragma push_macro("constexpr")
-#define constexpr /*constexpr*/
-
-// noexcept is not understood
-#pragma push_macro("noexcept")
-#define noexcept /*noexcept*/
-
-#endif // _MSC_VER <= 1800
+ // MSVC 2013 workarounds
+ #if _MSC_VER <= 1800
+ // constexpr is not understood
+ #pragma push_macro("constexpr")
+ #define constexpr inline
+ // noexcept is not understood
+ #pragma push_macro("noexcept")
+ #define noexcept /*noexcept*/
+ #endif // _MSC_VER <= 1800
#endif // _MSC_VER
namespace gsl
@@ -145,19 +141,15 @@ inline constexpr byte to_byte() noexcept
} // namespace gsl
#ifdef _MSC_VER
+ #if _MSC_VER <= 1800
+ #undef constexpr
+ #pragma pop_macro("constexpr")
-#if _MSC_VER <= 1800
-
-#undef constexpr
-#pragma pop_macro("constexpr")
-
-#undef noexcept
-#pragma pop_macro("noexcept")
-
-#endif // _MSC_VER <= 1800
-
-#pragma warning(pop)
+ #undef noexcept
+ #pragma pop_macro("noexcept")
+ #endif // _MSC_VER <= 1800
+ #pragma warning(pop)
#endif // _MSC_VER
#endif // GSL_BYTE_H
diff --git a/gsl/gsl_util b/include/gsl/gsl_util
index 88681e8..164bf58 100644
--- a/gsl/gsl_util
+++ b/include/gsl/gsl_util
@@ -19,33 +19,28 @@
#ifndef GSL_UTIL_H
#define GSL_UTIL_H
-#include "gsl_assert" // Ensures/Expects
+#include <gsl/gsl_assert> // Ensures/Expects
#include <array>
#include <exception>
#include <type_traits>
#include <utility>
-#ifdef _MSC_VER
-
-// No MSVC does constexpr fully yet
-#pragma push_macro("constexpr")
-#define constexpr /*constexpr*/
-
-#pragma warning(push)
-#pragma warning(disable : 4127) // conditional expression is constant
-
-// MSVC 2013 workarounds
-#if _MSC_VER <= 1800
-// noexcept is not understood
-#pragma push_macro("noexcept")
-#define noexcept /*noexcept*/
-
-// turn off some misguided warnings
-#pragma warning(push)
-#pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior
-
-#endif // _MSC_VER <= 1800
-
+#if defined(_MSC_VER)
+ #pragma warning(push)
+ #pragma warning(disable : 4127) // conditional expression is constant
+
+ #if _MSC_VER < 1910
+ #pragma push_macro("constexpr")
+ #define constexpr /*constexpr*/
+ // MSVC 2013 workarounds
+ #if _MSC_VER <= 1800
+ // noexcept is not understood
+ #pragma push_macro("noexcept")
+ #define noexcept /*noexcept*/
+ // turn off some misguided warnings
+ #pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior
+ #endif // _MSC_VER <= 1800
+ #endif // _MSC_VER < 1910
#endif // _MSC_VER
namespace gsl
@@ -135,28 +130,28 @@ inline T narrow(U u)
// at() - Bounds-checked way of accessing static arrays, std::array, std::vector
//
template <class T, size_t N>
-constexpr T& at(T (&arr)[N], std::ptrdiff_t index)
+inline constexpr T& at(T (&arr)[N], std::ptrdiff_t index)
{
Expects(index >= 0 && index < narrow_cast<std::ptrdiff_t>(N));
return arr[static_cast<size_t>(index)];
}
template <class T, size_t N>
-constexpr T& at(std::array<T, N>& arr, std::ptrdiff_t index)
+inline constexpr T& at(std::array<T, N>& arr, std::ptrdiff_t index)
{
Expects(index >= 0 && index < narrow_cast<std::ptrdiff_t>(N));
return arr[static_cast<size_t>(index)];
}
template <class Cont>
-constexpr typename Cont::value_type& at(Cont& cont, std::ptrdiff_t index)
+inline constexpr typename Cont::value_type& at(Cont& cont, std::ptrdiff_t index)
{
Expects(index >= 0 && index < narrow_cast<std::ptrdiff_t>(cont.size()));
return cont[static_cast<typename Cont::size_type>(index)];
}
template <class T>
-constexpr const T& at(std::initializer_list<T> cont, std::ptrdiff_t index)
+inline constexpr const T& at(std::initializer_list<T> cont, std::ptrdiff_t index)
{
Expects(index >= 0 && index < narrow_cast<std::ptrdiff_t>(cont.size()));
return *(cont.begin() + index);
@@ -164,22 +159,17 @@ constexpr const T& at(std::initializer_list<T> cont, std::ptrdiff_t index)
} // namespace gsl
-#ifdef _MSC_VER
-
-#pragma warning(pop)
-
-#undef constexpr
-#pragma pop_macro("constexpr")
-
-#if _MSC_VER <= 1800
-
-#undef noexcept
-#pragma pop_macro("noexcept")
-
-#pragma warning(pop)
-
-#endif // _MSC_VER <= 1800
-
+#if defined(_MSC_VER)
+ #if _MSC_VER < 1910
+ #undef constexpr
+ #pragma pop_macro("constexpr")
+
+ #if _MSC_VER <= 1800
+ #undef noexcept
+ #pragma pop_macro("noexcept")
+ #endif // _MSC_VER <= 1800
+ #endif // _MSC_VER < 1910
+ #pragma warning(pop)
#endif // _MSC_VER
#endif // GSL_UTIL_H
diff --git a/gsl/multi_span b/include/gsl/multi_span
index 7bee7a3..dc5de4a 100644
--- a/gsl/multi_span
+++ b/include/gsl/multi_span
@@ -19,9 +19,9 @@
#ifndef GSL_MULTI_SPAN_H
#define GSL_MULTI_SPAN_H
-#include "gsl_assert"
-#include "gsl_byte"
-#include "gsl_util"
+#include <gsl/gsl_assert>
+#include <gsl/gsl_byte>
+#include <gsl/gsl_util>
#include <algorithm>
#include <array>
#include <cassert>
@@ -37,43 +37,34 @@
#include <utility>
#ifdef _MSC_VER
-
-// turn off some warnings that are noisy about our Expects statements
-#pragma warning(push)
-#pragma warning(disable : 4127) // conditional expression is constant
-
-// No MSVC does constexpr fully yet
-#pragma push_macro("constexpr")
-#define constexpr /*constexpr*/
-
-// VS 2013 workarounds
-#if _MSC_VER <= 1800
-
-#define GSL_MSVC_HAS_VARIADIC_CTOR_BUG
-#define GSL_MSVC_NO_SUPPORT_FOR_MOVE_CTOR_DEFAULT
-
-// noexcept is not understood
-#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
-#pragma push_macro("noexcept")
-#define noexcept /*noexcept*/
-#endif
-
-// turn off some misguided warnings
-#pragma warning(push)
-#pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior
-#pragma warning(disable : 4512) // warns that assignment op could not be generated
-
-#endif // _MSC_VER <= 1800
-
+ // turn off some warnings that are noisy about our Expects statements
+ #pragma warning(push)
+ #pragma warning(disable : 4127) // conditional expression is constant
+
+ #if _MSC_VER < 1910
+ #pragma push_macro("constexpr")
+ #define constexpr /*constexpr*/
+
+ // VS 2013 workarounds
+ #if _MSC_VER <= 1800
+ #define GSL_MSVC_HAS_VARIADIC_CTOR_BUG
+ #define GSL_MSVC_NO_SUPPORT_FOR_MOVE_CTOR_DEFAULT
+
+ // noexcept is not understood
+ #pragma push_macro("noexcept")
+ #define noexcept /*noexcept*/
+
+ // turn off some misguided warnings
+ #pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior
+ #pragma warning(disable : 4512) // warns that assignment op could not be generated
+ #endif // _MSC_VER <= 1800
+ #endif // _MSC_VER < 1910
#endif // _MSC_VER
#ifdef GSL_THROW_ON_CONTRACT_VIOLATION
-
-#ifdef _MSC_VER
-#pragma push_macro("noexcept")
-#endif
-
-#define noexcept /*noexcept*/
+ #define GSL_NOEXCEPT /*noexcept*/
+#else
+ #define GSL_NOEXCEPT noexcept
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
namespace gsl
@@ -118,9 +109,9 @@ public:
using reference = std::add_lvalue_reference_t<value_type>;
using const_reference = std::add_lvalue_reference_t<std::add_const_t<value_type>>;
- constexpr index() noexcept {}
+ constexpr index() GSL_NOEXCEPT {}
- constexpr index(const value_type (&values)[Rank]) noexcept
+ constexpr index(const value_type (&values)[Rank]) GSL_NOEXCEPT
{
std::copy(values, values + Rank, elems);
}
@@ -137,14 +128,14 @@ public:
#else
template <typename... Ts, typename = std::enable_if_t<(sizeof...(Ts) == Rank) &&
details::are_integral<Ts...>::value>>
- constexpr index(Ts... ds) noexcept : elems{narrow_cast<value_type>(ds)...}
+ constexpr index(Ts... ds) GSL_NOEXCEPT : elems{narrow_cast<value_type>(ds)...}
{
}
#endif
- constexpr index(const index& other) noexcept = default;
+ constexpr index(const index& other) GSL_NOEXCEPT = default;
- constexpr index& operator=(const index& rhs) noexcept = default;
+ constexpr index& operator=(const index& rhs) GSL_NOEXCEPT = default;
// Preconditions: component_idx < rank
constexpr reference operator[](size_t component_idx)
@@ -154,78 +145,78 @@ public:
}
// Preconditions: component_idx < rank
- constexpr const_reference operator[](size_t component_idx) const noexcept
+ constexpr const_reference operator[](size_t component_idx) const GSL_NOEXCEPT
{
Expects(component_idx < Rank); // Component index must be less than rank
return elems[component_idx];
}
- constexpr bool operator==(const index& rhs) const noexcept
+ constexpr bool operator==(const index& rhs) const GSL_NOEXCEPT
{
return std::equal(elems, elems + rank, rhs.elems);
}
- constexpr bool operator!=(const index& rhs) const noexcept { return !(this == rhs); }
+ constexpr bool operator!=(const index& rhs) const GSL_NOEXCEPT { return !(this == rhs); }
- constexpr index operator+() const noexcept { return *this; }
+ constexpr index operator+() const GSL_NOEXCEPT { return *this; }
- constexpr index operator-() const noexcept
+ constexpr index operator-() const GSL_NOEXCEPT
{
index ret = *this;
std::transform(ret, ret + rank, ret, std::negate<value_type>{});
return ret;
}
- constexpr index operator+(const index& rhs) const noexcept
+ constexpr index operator+(const index& rhs) const GSL_NOEXCEPT
{
index ret = *this;
ret += rhs;
return ret;
}
- constexpr index operator-(const index& rhs) const noexcept
+ constexpr index operator-(const index& rhs) const GSL_NOEXCEPT
{
index ret = *this;
ret -= rhs;
return ret;
}
- constexpr index& operator+=(const index& rhs) noexcept
+ constexpr index& operator+=(const index& rhs) GSL_NOEXCEPT
{
std::transform(elems, elems + rank, rhs.elems, elems, std::plus<value_type>{});
return *this;
}
- constexpr index& operator-=(const index& rhs) noexcept
+ constexpr index& operator-=(const index& rhs) GSL_NOEXCEPT
{
std::transform(elems, elems + rank, rhs.elems, elems, std::minus<value_type>{});
return *this;
}
- constexpr index operator*(value_type v) const noexcept
+ constexpr index operator*(value_type v) const GSL_NOEXCEPT
{
index ret = *this;
ret *= v;
return ret;
}
- constexpr index operator/(value_type v) const noexcept
+ constexpr index operator/(value_type v) const GSL_NOEXCEPT
{
index ret = *this;
ret /= v;
return ret;
}
- friend constexpr index operator*(value_type v, const index& rhs) noexcept { return rhs * v; }
+ friend constexpr index operator*(value_type v, const index& rhs) GSL_NOEXCEPT { return rhs * v; }
- constexpr index& operator*=(value_type v) noexcept
+ constexpr index& operator*=(value_type v) GSL_NOEXCEPT
{
std::transform(elems, elems + rank, elems,
[v](value_type x) { return std::multiplies<value_type>{}(x, v); });
return *this;
}
- constexpr index& operator/=(value_type v) noexcept
+ constexpr index& operator/=(value_type v) GSL_NOEXCEPT
{
std::transform(elems, elems + rank, elems,
[v](value_type x) { return std::divides<value_type>{}(x, v); });
@@ -236,37 +227,47 @@ private:
value_type elems[Rank] = {};
};
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) || _MSC_VER >= 1910
struct static_bounds_dynamic_range_t
{
template <typename T, typename Dummy = std::enable_if_t<std::is_integral<T>::value>>
- constexpr operator T() const noexcept
+ constexpr operator T() const GSL_NOEXCEPT
{
return narrow_cast<T>(-1);
}
+};
- template <typename T, typename Dummy = std::enable_if_t<std::is_integral<T>::value>>
- constexpr bool operator==(T other) const noexcept
- {
- return narrow_cast<T>(-1) == other;
- }
+constexpr bool operator==(static_bounds_dynamic_range_t, static_bounds_dynamic_range_t) GSL_NOEXCEPT
+{
+ return true;
+}
- template <typename T, typename Dummy = std::enable_if_t<std::is_integral<T>::value>>
- constexpr bool operator!=(T other) const noexcept
- {
- return narrow_cast<T>(-1) != other;
- }
-};
+constexpr bool operator!=(static_bounds_dynamic_range_t, static_bounds_dynamic_range_t) GSL_NOEXCEPT
+{
+ return false;
+}
template <typename T, typename Dummy = std::enable_if_t<std::is_integral<T>::value>>
-constexpr bool operator==(T left, static_bounds_dynamic_range_t right) noexcept
+constexpr bool operator==(static_bounds_dynamic_range_t, T other) GSL_NOEXCEPT
+{
+ return narrow_cast<T>(-1) == other;
+}
+
+template <typename T, typename Dummy = std::enable_if_t<std::is_integral<T>::value>>
+constexpr bool operator==(T left, static_bounds_dynamic_range_t right) GSL_NOEXCEPT
{
return right == left;
}
template <typename T, typename Dummy = std::enable_if_t<std::is_integral<T>::value>>
-constexpr bool operator!=(T left, static_bounds_dynamic_range_t right) noexcept
+constexpr bool operator!=(static_bounds_dynamic_range_t, T other) GSL_NOEXCEPT
+{
+ return narrow_cast<T>(-1) != other;
+}
+
+template <typename T, typename Dummy = std::enable_if_t<std::is_integral<T>::value>>
+constexpr bool operator!=(T left, static_bounds_dynamic_range_t right) GSL_NOEXCEPT
{
return right != left;
}
@@ -327,11 +328,11 @@ namespace details
return -1;
}
- size_type elementNum(size_t) const noexcept { return 0; }
+ size_type elementNum(size_t) const GSL_NOEXCEPT { return 0; }
- size_type totalSize() const noexcept { return TotalSize; }
+ size_type totalSize() const GSL_NOEXCEPT { return TotalSize; }
- bool operator==(const BoundsRanges&) const noexcept { return true; }
+ bool operator==(const BoundsRanges&) const GSL_NOEXCEPT { return true; }
};
template <std::ptrdiff_t... RestRanges>
@@ -387,11 +388,11 @@ namespace details
return cur < m_bound ? cur + last : -1;
}
- size_type totalSize() const noexcept { return m_bound; }
+ size_type totalSize() const GSL_NOEXCEPT { return m_bound; }
- size_type elementNum() const noexcept { return totalSize() / this->Base::totalSize(); }
+ size_type elementNum() const GSL_NOEXCEPT { return totalSize() / this->Base::totalSize(); }
- size_type elementNum(size_t dim) const noexcept
+ size_type elementNum(size_t dim) const GSL_NOEXCEPT
{
if (dim > 0)
return this->Base::elementNum(dim - 1);
@@ -399,7 +400,7 @@ namespace details
return elementNum();
}
- bool operator==(const BoundsRanges& rhs) const noexcept
+ bool operator==(const BoundsRanges& rhs) const GSL_NOEXCEPT
{
return m_bound == rhs.m_bound &&
static_cast<const Base&>(*this) == static_cast<const Base&>(rhs);
@@ -452,11 +453,11 @@ namespace details
return this->Base::totalSize() * arr[Dim] + last;
}
- size_type totalSize() const noexcept { return CurrentRange * this->Base::totalSize(); }
+ size_type totalSize() const GSL_NOEXCEPT { return CurrentRange * this->Base::totalSize(); }
- size_type elementNum() const noexcept { return CurrentRange; }
+ size_type elementNum() const GSL_NOEXCEPT { return CurrentRange; }
- size_type elementNum(size_t dim) const noexcept
+ size_type elementNum(size_t dim) const GSL_NOEXCEPT
{
if (dim > 0)
return this->Base::elementNum(dim - 1);
@@ -464,7 +465,7 @@ namespace details
return elementNum();
}
- bool operator==(const BoundsRanges& rhs) const noexcept
+ bool operator==(const BoundsRanges& rhs) const GSL_NOEXCEPT
{
return static_cast<const Base&>(*this) == static_cast<const Base&>(rhs);
}
@@ -513,7 +514,7 @@ namespace details
template <size_t Rank, bool Enabled = (Rank > 1),
typename Ret = std::enable_if_t<Enabled, index<Rank - 1>>>
- constexpr Ret shift_left(const index<Rank>& other) noexcept
+ inline constexpr Ret shift_left(const index<Rank>& other) GSL_NOEXCEPT
{
Ret ret{};
for (size_t i = 0; i < Rank - 1; ++i) {
@@ -628,31 +629,31 @@ public:
constexpr static_bounds() = default;
- constexpr sliced_type slice() const noexcept
+ constexpr sliced_type slice() const GSL_NOEXCEPT
{
return sliced_type{static_cast<const details::BoundsRanges<RestRanges...>&>(m_ranges)};
}
- constexpr size_type stride() const noexcept { return rank > 1 ? slice().size() : 1; }
+ constexpr size_type stride() const GSL_NOEXCEPT { return rank > 1 ? slice().size() : 1; }
- constexpr size_type size() const noexcept { return m_ranges.totalSize(); }
+ constexpr size_type size() const GSL_NOEXCEPT { return m_ranges.totalSize(); }
- constexpr size_type total_size() const noexcept { return m_ranges.totalSize(); }
+ constexpr size_type total_size() const GSL_NOEXCEPT { return m_ranges.totalSize(); }
constexpr size_type linearize(const index_type& idx) const { return m_ranges.linearize(idx); }
- constexpr bool contains(const index_type& idx) const noexcept
+ constexpr bool contains(const index_type& idx) const GSL_NOEXCEPT
{
return m_ranges.contains(idx) != -1;
}
- constexpr size_type operator[](size_t index) const noexcept
+ constexpr size_type operator[](size_t index) const GSL_NOEXCEPT
{
return m_ranges.elementNum(index);
}
template <size_t Dim = 0>
- constexpr size_type extent() const noexcept
+ constexpr size_type extent() const GSL_NOEXCEPT
{
static_assert(Dim < rank,
"dimension should be less than rank (dimension count starts from 0)");
@@ -660,7 +661,7 @@ public:
}
template <typename IntType>
- constexpr size_type extent(IntType dim) const noexcept
+ constexpr size_type extent(IntType dim) const GSL_NOEXCEPT
{
static_assert(std::is_integral<IntType>::value,
"Dimension parameter must be supplied as an integral type.");
@@ -670,7 +671,7 @@ public:
return m_ranges.elementNum(real_dim);
}
- constexpr index_type index_bounds() const noexcept
+ constexpr index_type index_bounds() const GSL_NOEXCEPT
{
size_type extents[rank] = {};
m_ranges.serialize(extents);
@@ -678,20 +679,20 @@ public:
}
template <std::ptrdiff_t... Ranges>
- constexpr bool operator==(const static_bounds<Ranges...>& rhs) const noexcept
+ constexpr bool operator==(const static_bounds<Ranges...>& rhs) const GSL_NOEXCEPT
{
return this->size() == rhs.size();
}
template <std::ptrdiff_t... Ranges>
- constexpr bool operator!=(const static_bounds<Ranges...>& rhs) const noexcept
+ constexpr bool operator!=(const static_bounds<Ranges...>& rhs) const GSL_NOEXCEPT
{
return !(*this == rhs);
}
- constexpr const_iterator begin() const noexcept { return const_iterator(*this, index_type{}); }
+ constexpr const_iterator begin() const GSL_NOEXCEPT { return const_iterator(*this, index_type{}); }
- constexpr const_iterator end() const noexcept
+ constexpr const_iterator end() const GSL_NOEXCEPT
{
return const_iterator(*this, this->index_bounds());
}
@@ -719,24 +720,24 @@ public:
using sliced_type = std::conditional_t<rank != 0, strided_bounds<rank - 1>, void>;
using mapping_type = generalized_mapping_tag;
- constexpr strided_bounds(const strided_bounds&) noexcept = default;
+ constexpr strided_bounds(const strided_bounds&) GSL_NOEXCEPT = default;
- constexpr strided_bounds& operator=(const strided_bounds&) noexcept = default;
+ constexpr strided_bounds& operator=(const strided_bounds&) GSL_NOEXCEPT = default;
constexpr strided_bounds(const value_type (&values)[rank], index_type strides)
: m_extents(values), m_strides(std::move(strides))
{
}
- constexpr strided_bounds(const index_type& extents, const index_type& strides) noexcept
+ constexpr strided_bounds(const index_type& extents, const index_type& strides) GSL_NOEXCEPT
: m_extents(extents),
m_strides(strides)
{
}
- constexpr index_type strides() const noexcept { return m_strides; }
+ constexpr index_type strides() const GSL_NOEXCEPT { return m_strides; }
- constexpr size_type total_size() const noexcept
+ constexpr size_type total_size() const GSL_NOEXCEPT
{
size_type ret = 0;
for (size_t i = 0; i < rank; ++i) {
@@ -745,7 +746,7 @@ public:
return ret + 1;
}
- constexpr size_type size() const noexcept
+ constexpr size_type size() const GSL_NOEXCEPT
{
size_type ret = 1;
for (size_t i = 0; i < rank; ++i) {
@@ -754,7 +755,7 @@ public:
return ret;
}
- constexpr bool contains(const index_type& idx) const noexcept
+ constexpr bool contains(const index_type& idx) const GSL_NOEXCEPT
{
for (size_t i = 0; i < rank; ++i) {
if (idx[i] < 0 || idx[i] >= m_extents[i]) return false;
@@ -762,7 +763,7 @@ public:
return true;
}
- constexpr size_type linearize(const index_type& idx) const noexcept
+ constexpr size_type linearize(const index_type& idx) const GSL_NOEXCEPT
{
size_type ret = 0;
for (size_t i = 0; i < rank; i++) {
@@ -772,7 +773,7 @@ public:
return ret;
}
- constexpr size_type stride() const noexcept { return m_strides[0]; }
+ constexpr size_type stride() const GSL_NOEXCEPT { return m_strides[0]; }
template <bool Enabled = (rank > 1), typename Ret = std::enable_if_t<Enabled, sliced_type>>
constexpr sliced_type slice() const
@@ -781,17 +782,17 @@ public:
}
template <size_t Dim = 0>
- constexpr size_type extent() const noexcept
+ constexpr size_type extent() const GSL_NOEXCEPT
{
static_assert(Dim < Rank,
"dimension should be less than rank (dimension count starts from 0)");
return m_extents[Dim];
}
- constexpr index_type index_bounds() const noexcept { return m_extents; }
- constexpr const_iterator begin() const noexcept { return const_iterator{*this, index_type{}}; }
+ constexpr index_type index_bounds() const GSL_NOEXCEPT { return m_extents; }
+ constexpr const_iterator begin() const GSL_NOEXCEPT { return const_iterator{*this, index_type{}}; }
- constexpr const_iterator end() const noexcept { return const_iterator{*this, index_bounds()}; }
+ constexpr const_iterator end() const GSL_NOEXCEPT { return const_iterator{*this, index_bounds()}; }
private:
index_type m_extents;
@@ -826,18 +827,18 @@ public:
using index_type = value_type;
using index_size_type = typename IndexType::value_type;
template <typename Bounds>
- explicit bounds_iterator(const Bounds& bnd, value_type curr) noexcept
+ explicit bounds_iterator(const Bounds& bnd, value_type curr) GSL_NOEXCEPT
: boundary_(bnd.index_bounds()),
curr_(std::move(curr))
{
static_assert(is_bounds<Bounds>::value, "Bounds type must be provided");
}
- constexpr reference operator*() const noexcept { return curr_; }
+ constexpr reference operator*() const GSL_NOEXCEPT { return curr_; }
- constexpr pointer operator->() const noexcept { return &curr_; }
+ constexpr pointer operator->() const GSL_NOEXCEPT { return &curr_; }
- constexpr bounds_iterator& operator++() noexcept
+ constexpr bounds_iterator& operator++() GSL_NOEXCEPT
{
for (size_t i = rank; i-- > 0;) {
if (curr_[i] < boundary_[i] - 1) {
@@ -851,14 +852,14 @@ public:
return *this;
}
- constexpr bounds_iterator operator++(int) noexcept
+ constexpr bounds_iterator operator++(int) GSL_NOEXCEPT
{
auto ret = *this;
++(*this);
return ret;
}
- constexpr bounds_iterator& operator--() noexcept
+ constexpr bounds_iterator& operator--() GSL_NOEXCEPT
{
if (!less(curr_, boundary_)) {
// if at the past-the-end, set to last element
@@ -880,20 +881,20 @@ public:
return *this;
}
- constexpr bounds_iterator operator--(int) noexcept
+ constexpr bounds_iterator operator--(int) GSL_NOEXCEPT
{
auto ret = *this;
--(*this);
return ret;
}
- constexpr bounds_iterator operator+(difference_type n) const noexcept
+ constexpr bounds_iterator operator+(difference_type n) const GSL_NOEXCEPT
{
bounds_iterator ret{*this};
return ret += n;
}
- constexpr bounds_iterator& operator+=(difference_type n) noexcept
+ constexpr bounds_iterator& operator+=(difference_type n) GSL_NOEXCEPT
{
auto linear_idx = linearize(curr_) + n;
std::remove_const_t<value_type> stride = 0;
@@ -910,47 +911,47 @@ public:
return *this;
}
- constexpr bounds_iterator operator-(difference_type n) const noexcept
+ constexpr bounds_iterator operator-(difference_type n) const GSL_NOEXCEPT
{
bounds_iterator ret{*this};
return ret -= n;
}
- constexpr bounds_iterator& operator-=(difference_type n) noexcept { return *this += -n; }
+ constexpr bounds_iterator& operator-=(difference_type n) GSL_NOEXCEPT { return *this += -n; }
- constexpr difference_type operator-(const bounds_iterator& rhs) const noexcept
+ constexpr difference_type operator-(const bounds_iterator& rhs) const GSL_NOEXCEPT
{
return linearize(curr_) - linearize(rhs.curr_);
}
- constexpr value_type operator[](difference_type n) const noexcept { return *(*this + n); }
+ constexpr value_type operator[](difference_type n) const GSL_NOEXCEPT { return *(*this + n); }
- constexpr bool operator==(const bounds_iterator& rhs) const noexcept
+ constexpr bool operator==(const bounds_iterator& rhs) const GSL_NOEXCEPT
{
return curr_ == rhs.curr_;
}
- constexpr bool operator!=(const bounds_iterator& rhs) const noexcept { return !(*this == rhs); }
+ constexpr bool operator!=(const bounds_iterator& rhs) const GSL_NOEXCEPT { return !(*this == rhs); }
- constexpr bool operator<(const bounds_iterator& rhs) const noexcept
+ constexpr bool operator<(const bounds_iterator& rhs) const GSL_NOEXCEPT
{
return less(curr_, rhs.curr_);
}
- constexpr bool operator<=(const bounds_iterator& rhs) const noexcept { return !(rhs < *this); }
+ constexpr bool operator<=(const bounds_iterator& rhs) const GSL_NOEXCEPT { return !(rhs < *this); }
- constexpr bool operator>(const bounds_iterator& rhs) const noexcept { return rhs < *this; }
+ constexpr bool operator>(const bounds_iterator& rhs) const GSL_NOEXCEPT { return rhs < *this; }
- constexpr bool operator>=(const bounds_iterator& rhs) const noexcept { return !(rhs > *this); }
+ constexpr bool operator>=(const bounds_iterator& rhs) const GSL_NOEXCEPT { return !(rhs > *this); }
- void swap(bounds_iterator& rhs) noexcept
+ void swap(bounds_iterator& rhs) GSL_NOEXCEPT
{
std::swap(boundary_, rhs.boundary_);
std::swap(curr_, rhs.curr_);
}
private:
- constexpr bool less(index_type& one, index_type& other) const noexcept
+ constexpr bool less(index_type& one, index_type& other) const GSL_NOEXCEPT
{
for (size_t i = 0; i < rank; ++i) {
if (one[i] < other[i]) return true;
@@ -958,7 +959,7 @@ private:
return false;
}
- constexpr index_size_type linearize(const value_type& idx) const noexcept
+ constexpr index_size_type linearize(const value_type& idx) const GSL_NOEXCEPT
{
// TODO: Smarter impl.
// Check if past-the-end
@@ -987,7 +988,7 @@ private:
template <typename IndexType>
bounds_iterator<IndexType> operator+(typename bounds_iterator<IndexType>::difference_type n,
- const bounds_iterator<IndexType>& rhs) noexcept
+ const bounds_iterator<IndexType>& rhs) GSL_NOEXCEPT
{
return rhs + n;
}
@@ -995,20 +996,20 @@ bounds_iterator<IndexType> operator+(typename bounds_iterator<IndexType>::differ
namespace details
{
template <typename Bounds>
- constexpr std::enable_if_t<
+ inline constexpr std::enable_if_t<
std::is_same<typename Bounds::mapping_type, generalized_mapping_tag>::value,
typename Bounds::index_type>
- make_stride(const Bounds& bnd) noexcept
+ make_stride(const Bounds& bnd) GSL_NOEXCEPT
{
return bnd.strides();
}
// Make a stride vector from bounds, assuming contiguous memory.
template <typename Bounds>
- constexpr std::enable_if_t<
+ inline constexpr std::enable_if_t<
std::is_same<typename Bounds::mapping_type, contiguous_mapping_tag>::value,
typename Bounds::index_type>
- make_stride(const Bounds& bnd) noexcept
+ make_stride(const Bounds& bnd) GSL_NOEXCEPT
{
auto extents = bnd.index_bounds();
typename Bounds::size_type stride[Bounds::rank] = {};
@@ -1054,14 +1055,14 @@ struct dim_t<dynamic_range>
dim_t(std::ptrdiff_t size) : dvalue(size) {}
};
-template <std::ptrdiff_t N>
-constexpr std::enable_if_t<(N >= 0), dim_t<N>> dim() noexcept
+template <std::ptrdiff_t N, class = std::enable_if_t<(N >= 0)>>
+inline constexpr dim_t<N> dim() GSL_NOEXCEPT
{
return dim_t<N>();
}
-template <std::ptrdiff_t N = dynamic_range>
-constexpr std::enable_if_t<N == dynamic_range, dim_t<N>> dim(std::ptrdiff_t n) noexcept
+template <std::ptrdiff_t N = dynamic_range, class = std::enable_if_t<N == dynamic_range>>
+inline constexpr dim_t<N> dim(std::ptrdiff_t n) GSL_NOEXCEPT
{
return dim_t<>(n);
}
@@ -1207,7 +1208,7 @@ private:
public:
// default constructor - same as constructing from nullptr_t
- constexpr multi_span() noexcept : multi_span(nullptr, bounds_type{})
+ constexpr multi_span() GSL_NOEXCEPT : multi_span(nullptr, bounds_type{})
{
static_assert(bounds_type::dynamic_rank != 0 ||
(bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0),
@@ -1216,7 +1217,7 @@ public:
}
// construct from nullptr - get an empty multi_span
- constexpr multi_span(std::nullptr_t) noexcept : multi_span(nullptr, bounds_type{})
+ constexpr multi_span(std::nullptr_t) GSL_NOEXCEPT : multi_span(nullptr, bounds_type{})
{
static_assert(bounds_type::dynamic_rank != 0 ||
(bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0),
@@ -1226,7 +1227,7 @@ public:
// construct from nullptr with size of 0 (helps with template function calls)
template <class IntType, typename = std::enable_if_t<std::is_integral<IntType>::value>>
- constexpr multi_span(std::nullptr_t, IntType size) noexcept : multi_span(nullptr, bounds_type{})
+ constexpr multi_span(std::nullptr_t, IntType size) GSL_NOEXCEPT : multi_span(nullptr, bounds_type{})
{
static_assert(bounds_type::dynamic_rank != 0 ||
(bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0),
@@ -1236,7 +1237,7 @@ public:
}
// construct from a single element
- constexpr multi_span(reference data) noexcept : multi_span(&data, bounds_type{1})
+ constexpr multi_span(reference data) GSL_NOEXCEPT : multi_span(&data, bounds_type{1})
{
static_assert(bounds_type::dynamic_rank > 0 || bounds_type::static_size == 0 ||
bounds_type::static_size == 1,
@@ -1248,12 +1249,12 @@ public:
constexpr multi_span(value_type&&) = delete;
// construct from pointer + length
- constexpr multi_span(pointer ptr, size_type size) noexcept : multi_span(ptr, bounds_type{size})
+ constexpr multi_span(pointer ptr, size_type size) GSL_NOEXCEPT : multi_span(ptr, bounds_type{size})
{
}
// construct from pointer + length - multidimensional
- constexpr multi_span(pointer data, bounds_type bounds) noexcept : data_(data),
+ constexpr multi_span(pointer data, bounds_type bounds) GSL_NOEXCEPT : data_(data),
bounds_(std::move(bounds))
{
Expects((bounds_.size() > 0 && data != nullptr) || bounds_.size() == 0);
@@ -1349,7 +1350,7 @@ public:
typename OtherBounds = static_bounds<OtherDimensions...>,
typename = std::enable_if_t<std::is_convertible<OtherValueType, ValueType>::value &&
std::is_convertible<OtherBounds, bounds_type>::value>>
- constexpr multi_span(multi_span<OtherValueType, OtherDimensions...> other) noexcept
+ constexpr multi_span(multi_span<OtherValueType, OtherDimensions...> other) GSL_NOEXCEPT
: data_(other.data_),
bounds_(other.bounds_)
{
@@ -1369,7 +1370,7 @@ public:
// first() - extract the first Count elements into a new multi_span
template <std::ptrdiff_t Count>
- constexpr multi_span<ValueType, Count> first() const noexcept
+ constexpr multi_span<ValueType, Count> first() const GSL_NOEXCEPT
{
static_assert(Count >= 0, "Count must be >= 0.");
static_assert(bounds_type::static_size == dynamic_range ||
@@ -1381,7 +1382,7 @@ public:
}
// first() - extract the first count elements into a new multi_span
- constexpr multi_span<ValueType, dynamic_range> first(size_type count) const noexcept
+ constexpr multi_span<ValueType, dynamic_range> first(size_type count) const GSL_NOEXCEPT
{
Expects(count >= 0 && count <= this->size());
return {this->data(), count};
@@ -1389,7 +1390,7 @@ public:
// last() - extract the last Count elements into a new multi_span
template <std::ptrdiff_t Count>
- constexpr multi_span<ValueType, Count> last() const noexcept
+ constexpr multi_span<ValueType, Count> last() const GSL_NOEXCEPT
{
static_assert(Count >= 0, "Count must be >= 0.");
static_assert(bounds_type::static_size == dynamic_range ||
@@ -1401,7 +1402,7 @@ public:
}
// last() - extract the last count elements into a new multi_span
- constexpr multi_span<ValueType, dynamic_range> last(size_type count) const noexcept
+ constexpr multi_span<ValueType, dynamic_range> last(size_type count) const GSL_NOEXCEPT
{
Expects(count >= 0 && count <= this->size());
return {this->data() + this->size() - count, count};
@@ -1409,7 +1410,7 @@ public:
// subspan() - create a subview of Count elements starting at Offset
template <std::ptrdiff_t Offset, std::ptrdiff_t Count>
- constexpr multi_span<ValueType, Count> subspan() const noexcept
+ constexpr multi_span<ValueType, Count> subspan() const GSL_NOEXCEPT
{
static_assert(Count >= 0, "Count must be >= 0.");
static_assert(Offset >= 0, "Offset must be >= 0.");
@@ -1427,7 +1428,7 @@ public:
// supplying dynamic_range for count will consume all available elements from offset
constexpr multi_span<ValueType, dynamic_range> subspan(size_type offset,
size_type count = dynamic_range) const
- noexcept
+ GSL_NOEXCEPT
{
Expects((offset >= 0 && offset <= this->size()) &&
(count == dynamic_range || (count <= this->size() - offset)));
@@ -1436,7 +1437,7 @@ public:
// section - creates a non-contiguous, strided multi_span from a contiguous one
constexpr strided_span<ValueType, Rank> section(index_type origin, index_type extents) const
- noexcept
+ GSL_NOEXCEPT
{
size_type size = this->bounds().total_size() - this->bounds().linearize(origin);
return {&this->operator[](origin), size,
@@ -1444,23 +1445,23 @@ public:
}
// length of the multi_span in elements
- constexpr size_type size() const noexcept { return bounds_.size(); }
+ constexpr size_type size() const GSL_NOEXCEPT { return bounds_.size(); }
// length of the multi_span in elements
- constexpr size_type length() const noexcept { return this->size(); }
+ constexpr size_type length() const GSL_NOEXCEPT { return this->size(); }
// length of the multi_span in bytes
- constexpr size_type size_bytes() const noexcept { return narrow_cast<size_type>(sizeof(value_type)) * this->size(); }
+ constexpr size_type size_bytes() const GSL_NOEXCEPT { return narrow_cast<size_type>(sizeof(value_type)) * this->size(); }
// length of the multi_span in bytes
- constexpr size_type length_bytes() const noexcept { return this->size_bytes(); }
+ constexpr size_type length_bytes() const GSL_NOEXCEPT { return this->size_bytes(); }
- constexpr bool empty() const noexcept { return this->size() == 0; }
+ constexpr bool empty() const GSL_NOEXCEPT { return this->size() == 0; }
static constexpr std::size_t rank() { return Rank; }
template <size_t Dim = 0>
- constexpr size_type extent() const noexcept
+ constexpr size_type extent() const GSL_NOEXCEPT
{
static_assert(Dim < Rank,
"Dimension should be less than rank (dimension count starts from 0).");
@@ -1468,14 +1469,14 @@ public:
}
template <typename IntType>
- constexpr size_type extent(IntType dim) const noexcept
+ constexpr size_type extent(IntType dim) const GSL_NOEXCEPT
{
return bounds_.extent(dim);
}
- constexpr bounds_type bounds() const noexcept { return bounds_; }
+ constexpr bounds_type bounds() const GSL_NOEXCEPT { return bounds_; }
- constexpr pointer data() const noexcept { return data_; }
+ constexpr pointer data() const GSL_NOEXCEPT { return data_; }
template <typename FirstIndex>
constexpr reference operator()(FirstIndex index)
@@ -1491,13 +1492,13 @@ public:
return this->operator[](idx);
}
- constexpr reference operator[](const index_type& idx) const noexcept
+ constexpr reference operator[](const index_type& idx) const GSL_NOEXCEPT
{
return data_[bounds_.linearize(idx)];
}
template <bool Enabled = (Rank > 1), typename Ret = std::enable_if_t<Enabled, sliced_type>>
- constexpr Ret operator[](size_type idx) const noexcept
+ constexpr Ret operator[](size_type idx) const GSL_NOEXCEPT
{
Expects(idx >= 0 && idx < bounds_.size()); // index is out of bounds of the array
const size_type ridx = idx * bounds_.stride();
@@ -1507,30 +1508,30 @@ public:
return Ret{data_ + ridx, bounds_.slice()};
}
- constexpr iterator begin() const noexcept { return iterator{this, true}; }
+ constexpr iterator begin() const GSL_NOEXCEPT { return iterator{this, true}; }
- constexpr iterator end() const noexcept { return iterator{this, false}; }
+ constexpr iterator end() const GSL_NOEXCEPT { return iterator{this, false}; }
- constexpr const_iterator cbegin() const noexcept
+ constexpr const_iterator cbegin() const GSL_NOEXCEPT
{
return const_iterator{reinterpret_cast<const const_span*>(this), true};
}
- constexpr const_iterator cend() const noexcept
+ constexpr const_iterator cend() const GSL_NOEXCEPT
{
return const_iterator{reinterpret_cast<const const_span*>(this), false};
}
- constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator{end()}; }
+ constexpr reverse_iterator rbegin() const GSL_NOEXCEPT { return reverse_iterator{end()}; }
- constexpr reverse_iterator rend() const noexcept { return reverse_iterator{begin()}; }
+ constexpr reverse_iterator rend() const GSL_NOEXCEPT { return reverse_iterator{begin()}; }
- constexpr const_reverse_iterator crbegin() const noexcept
+ constexpr const_reverse_iterator crbegin() const GSL_NOEXCEPT
{
return const_reverse_iterator{cend()};
}
- constexpr const_reverse_iterator crend() const noexcept
+ constexpr const_reverse_iterator crend() const GSL_NOEXCEPT
{
return const_reverse_iterator{cbegin()};
}
@@ -1539,7 +1540,7 @@ public:
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
constexpr bool operator==(const multi_span<OtherValueType, OtherDimensions...>& other) const
- noexcept
+ GSL_NOEXCEPT
{
return bounds_.size() == other.bounds_.size() &&
(data_ == other.data_ || std::equal(this->begin(), this->end(), other.begin()));
@@ -1549,7 +1550,7 @@ public:
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
constexpr bool operator!=(const multi_span<OtherValueType, OtherDimensions...>& other) const
- noexcept
+ GSL_NOEXCEPT
{
return !(*this == other);
}
@@ -1558,7 +1559,7 @@ public:
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
constexpr bool operator<(const multi_span<OtherValueType, OtherDimensions...>& other) const
- noexcept
+ GSL_NOEXCEPT
{
return std::lexicographical_compare(this->begin(), this->end(), other.begin(), other.end());
}
@@ -1567,7 +1568,7 @@ public:
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
constexpr bool operator<=(const multi_span<OtherValueType, OtherDimensions...>& other) const
- noexcept
+ GSL_NOEXCEPT
{
return !(other < *this);
}
@@ -1576,7 +1577,7 @@ public:
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
constexpr bool operator>(const multi_span<OtherValueType, OtherDimensions...>& other) const
- noexcept
+ GSL_NOEXCEPT
{
return (other < *this);
}
@@ -1585,7 +1586,7 @@ public:
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
constexpr bool operator>=(const multi_span<OtherValueType, OtherDimensions...>& other) const
- noexcept
+ GSL_NOEXCEPT
{
return !(*this < other);
}
@@ -1599,7 +1600,7 @@ public:
// DimCount and Enabled here are workarounds for a bug in MSVC 2015
template <typename SpanType, typename... Dimensions2, size_t DimCount = sizeof...(Dimensions2),
bool Enabled = (DimCount > 0), typename = std::enable_if_t<Enabled>>
-constexpr auto as_multi_span(SpanType s, Dimensions2... dims)
+inline constexpr auto as_multi_span(SpanType s, Dimensions2... dims)
-> multi_span<typename SpanType::value_type, Dimensions2::value...>
{
static_assert(details::is_multi_span<SpanType>::value,
@@ -1613,7 +1614,7 @@ constexpr auto as_multi_span(SpanType s, Dimensions2... dims)
// convert a multi_span<T> to a multi_span<const byte>
template <typename U, std::ptrdiff_t... Dimensions>
-multi_span<const byte, dynamic_range> as_bytes(multi_span<U, Dimensions...> s) noexcept
+multi_span<const byte, dynamic_range> as_bytes(multi_span<U, Dimensions...> s) GSL_NOEXCEPT
{
static_assert(std::is_trivial<std::decay_t<U>>::value,
"The value_type of multi_span must be a trivial type.");
@@ -1625,7 +1626,7 @@ multi_span<const byte, dynamic_range> as_bytes(multi_span<U, Dimensions...> s) n
// on all implementations. It should be considered an experimental extension
// to the standard GSL interface.
template <typename U, std::ptrdiff_t... Dimensions>
-multi_span<byte> as_writeable_bytes(multi_span<U, Dimensions...> s) noexcept
+multi_span<byte> as_writeable_bytes(multi_span<U, Dimensions...> s) GSL_NOEXCEPT
{
static_assert(std::is_trivial<std::decay_t<U>>::value,
"The value_type of multi_span must be a trivial type.");
@@ -1637,7 +1638,7 @@ multi_span<byte> as_writeable_bytes(multi_span<U, Dimensions...> s) noexcept
// on all implementations. It should be considered an experimental extension
// to the standard GSL interface.
template <typename U, std::ptrdiff_t... Dimensions>
-constexpr auto as_multi_span(multi_span<const byte, Dimensions...> s) noexcept -> multi_span<
+inline constexpr auto as_multi_span(multi_span<const byte, Dimensions...> s) GSL_NOEXCEPT -> multi_span<
const U, static_cast<std::ptrdiff_t>(
multi_span<const byte, Dimensions...>::bounds_type::static_size != dynamic_range
? (static_cast<size_t>(
@@ -1652,7 +1653,7 @@ constexpr auto as_multi_span(multi_span<const byte, Dimensions...> s) noexcept -
ConstByteSpan::bounds_type::static_size % narrow_cast<std::ptrdiff_t>(sizeof(U)) == 0),
"Target type must be a trivial type and its size must match the byte array size");
- Expects((s.size_bytes() % narrow_cast<std::ptrdiff_t>(sizeof(U))) == 0 &&
+ Expects((s.size_bytes() % narrow_cast<std::ptrdiff_t>(sizeof(U))) == 0 &&
(s.size_bytes() / narrow_cast<std::ptrdiff_t>(sizeof(U))) < PTRDIFF_MAX);
return {reinterpret_cast<const U*>(s.data()),
s.size_bytes() / narrow_cast<std::ptrdiff_t>(sizeof(U))};
@@ -1663,7 +1664,7 @@ constexpr auto as_multi_span(multi_span<const byte, Dimensions...> s) noexcept -
// on all implementations. It should be considered an experimental extension
// to the standard GSL interface.
template <typename U, std::ptrdiff_t... Dimensions>
-constexpr auto as_multi_span(multi_span<byte, Dimensions...> s) noexcept
+inline constexpr auto as_multi_span(multi_span<byte, Dimensions...> s) GSL_NOEXCEPT
-> multi_span<U, narrow_cast<std::ptrdiff_t>(
multi_span<byte, Dimensions...>::bounds_type::static_size != dynamic_range
? static_cast<std::size_t>(
@@ -1684,7 +1685,7 @@ constexpr auto as_multi_span(multi_span<byte, Dimensions...> s) noexcept
}
template <typename T, std::ptrdiff_t... Dimensions>
-constexpr auto as_multi_span(T* const& ptr, dim_t<Dimensions>... args)
+inline constexpr auto as_multi_span(T* const& ptr, dim_t<Dimensions>... args)
-> multi_span<std::remove_all_extents_t<T>, Dimensions...>
{
return {reinterpret_cast<std::remove_all_extents_t<T>*>(ptr),
@@ -1693,41 +1694,41 @@ constexpr auto as_multi_span(T* const& ptr, dim_t<Dimensions>... args)
}
template <typename T>
-constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) ->
+inline constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) ->
typename details::SpanArrayTraits<T, dynamic_range>::type
{
return {reinterpret_cast<std::remove_all_extents_t<T>*>(arr), len};
}
template <typename T, size_t N>
-constexpr auto as_multi_span(T (&arr)[N]) -> typename details::SpanArrayTraits<T, N>::type
+inline constexpr auto as_multi_span(T (&arr)[N]) -> typename details::SpanArrayTraits<T, N>::type
{
return {arr};
}
template <typename T, size_t N>
-constexpr multi_span<const T, N> as_multi_span(const std::array<T, N>& arr)
+inline constexpr multi_span<const T, N> as_multi_span(const std::array<T, N>& arr)
{
return {arr};
}
template <typename T, size_t N>
-constexpr multi_span<const T, N> as_multi_span(const std::array<T, N>&&) = delete;
+inline constexpr multi_span<const T, N> as_multi_span(const std::array<T, N>&&) = delete;
template <typename T, size_t N>
-constexpr multi_span<T, N> as_multi_span(std::array<T, N>& arr)
+inline constexpr multi_span<T, N> as_multi_span(std::array<T, N>& arr)
{
return {arr};
}
template <typename T>
-constexpr multi_span<T, dynamic_range> as_multi_span(T* begin, T* end)
+inline constexpr multi_span<T, dynamic_range> as_multi_span(T* begin, T* end)
{
return {begin, end};
}
template <typename Cont>
-constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t<
+inline constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t<
!details::is_multi_span<std::decay_t<Cont>>::value,
multi_span<std::remove_reference_t<decltype(arr.size(), *arr.data())>, dynamic_range>>
{
@@ -1736,13 +1737,13 @@ constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t<
}
template <typename Cont>
-constexpr auto as_multi_span(Cont&& arr) -> std::enable_if_t<
+inline constexpr auto as_multi_span(Cont&& arr) -> std::enable_if_t<
!details::is_multi_span<std::decay_t<Cont>>::value,
multi_span<std::remove_reference_t<decltype(arr.size(), *arr.data())>, dynamic_range>> = delete;
// from basic_string which doesn't have nonconst .data() member like other contiguous containers
template <typename CharT, typename Traits, typename Allocator>
-constexpr auto as_multi_span(std::basic_string<CharT, Traits, Allocator>& str)
+inline constexpr auto as_multi_span(std::basic_string<CharT, Traits, Allocator>& str)
-> multi_span<CharT, dynamic_range>
{
Expects(str.size() < PTRDIFF_MAX);
@@ -1856,21 +1857,21 @@ public:
return {data_ + ridx, bounds_.slice().total_size(), bounds_.slice()};
}
- constexpr bounds_type bounds() const noexcept { return bounds_; }
+ constexpr bounds_type bounds() const GSL_NOEXCEPT { return bounds_; }
template <size_t Dim = 0>
- constexpr size_type extent() const noexcept
+ constexpr size_type extent() const GSL_NOEXCEPT
{
static_assert(Dim < Rank,
"dimension should be less than Rank (dimension count starts from 0)");
return bounds_.template extent<Dim>();
}
- constexpr size_type size() const noexcept { return bounds_.size(); }
+ constexpr size_type size() const GSL_NOEXCEPT { return bounds_.size(); }
- constexpr pointer data() const noexcept { return data_; }
+ constexpr pointer data() const GSL_NOEXCEPT { return data_; }
- constexpr explicit operator bool() const noexcept { return data_ != nullptr; }
+ constexpr explicit operator bool() const GSL_NOEXCEPT { return data_ != nullptr; }
constexpr iterator begin() const { return iterator{this, true}; }
@@ -1897,7 +1898,7 @@ public:
template <typename OtherValueType, std::ptrdiff_t OtherRank,
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
- constexpr bool operator==(const strided_span<OtherValueType, OtherRank>& other) const noexcept
+ constexpr bool operator==(const strided_span<OtherValueType, OtherRank>& other) const GSL_NOEXCEPT
{
return bounds_.size() == other.bounds_.size() &&
(data_ == other.data_ || std::equal(this->begin(), this->end(), other.begin()));
@@ -1906,7 +1907,7 @@ public:
template <typename OtherValueType, std::ptrdiff_t OtherRank,
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
- constexpr bool operator!=(const strided_span<OtherValueType, OtherRank>& other) const noexcept
+ constexpr bool operator!=(const strided_span<OtherValueType, OtherRank>& other) const GSL_NOEXCEPT
{
return !(*this == other);
}
@@ -1914,7 +1915,7 @@ public:
template <typename OtherValueType, std::ptrdiff_t OtherRank,
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
- constexpr bool operator<(const strided_span<OtherValueType, OtherRank>& other) const noexcept
+ constexpr bool operator<(const strided_span<OtherValueType, OtherRank>& other) const GSL_NOEXCEPT
{
return std::lexicographical_compare(this->begin(), this->end(), other.begin(), other.end());
}
@@ -1922,7 +1923,7 @@ public:
template <typename OtherValueType, std::ptrdiff_t OtherRank,
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
- constexpr bool operator<=(const strided_span<OtherValueType, OtherRank>& other) const noexcept
+ constexpr bool operator<=(const strided_span<OtherValueType, OtherRank>& other) const GSL_NOEXCEPT
{
return !(other < *this);
}
@@ -1930,7 +1931,7 @@ public:
template <typename OtherValueType, std::ptrdiff_t OtherRank,
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
- constexpr bool operator>(const strided_span<OtherValueType, OtherRank>& other) const noexcept
+ constexpr bool operator>(const strided_span<OtherValueType, OtherRank>& other) const GSL_NOEXCEPT
{
return (other < *this);
}
@@ -1938,7 +1939,7 @@ public:
template <typename OtherValueType, std::ptrdiff_t OtherRank,
typename Dummy = std::enable_if_t<std::is_same<
std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
- constexpr bool operator>=(const strided_span<OtherValueType, OtherRank>& other) const noexcept
+ constexpr bool operator>=(const strided_span<OtherValueType, OtherRank>& other) const GSL_NOEXCEPT
{
return !(*this < other);
}
@@ -2014,75 +2015,75 @@ private:
}
public:
- reference operator*() const noexcept
+ reference operator*() const GSL_NOEXCEPT
{
validateThis();
return *data_;
}
- pointer operator->() const noexcept
+ pointer operator->() const GSL_NOEXCEPT
{
validateThis();
return data_;
}
- contiguous_span_iterator& operator++() noexcept
+ contiguous_span_iterator& operator++() GSL_NOEXCEPT
{
++data_;
return *this;
}
- contiguous_span_iterator operator++(int) noexcept
+ contiguous_span_iterator operator++(int) GSL_NOEXCEPT
{
auto ret = *this;
++(*this);
return ret;
}
- contiguous_span_iterator& operator--() noexcept
+ contiguous_span_iterator& operator--() GSL_NOEXCEPT
{
--data_;
return *this;
}
- contiguous_span_iterator operator--(int) noexcept
+ contiguous_span_iterator operator--(int) GSL_NOEXCEPT
{
auto ret = *this;
--(*this);
return ret;
}
- contiguous_span_iterator operator+(difference_type n) const noexcept
+ contiguous_span_iterator operator+(difference_type n) const GSL_NOEXCEPT
{
contiguous_span_iterator ret{*this};
return ret += n;
}
- contiguous_span_iterator& operator+=(difference_type n) noexcept
+ contiguous_span_iterator& operator+=(difference_type n) GSL_NOEXCEPT
{
data_ += n;
return *this;
}
- contiguous_span_iterator operator-(difference_type n) const noexcept
+ contiguous_span_iterator operator-(difference_type n) const GSL_NOEXCEPT
{
contiguous_span_iterator ret{*this};
return ret -= n;
}
- contiguous_span_iterator& operator-=(difference_type n) noexcept { return *this += -n; }
- difference_type operator-(const contiguous_span_iterator& rhs) const noexcept
+ contiguous_span_iterator& operator-=(difference_type n) GSL_NOEXCEPT { return *this += -n; }
+ difference_type operator-(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT
{
Expects(m_validator == rhs.m_validator);
return data_ - rhs.data_;
}
- reference operator[](difference_type n) const noexcept { return *(*this + n); }
- bool operator==(const contiguous_span_iterator& rhs) const noexcept
+ reference operator[](difference_type n) const GSL_NOEXCEPT { return *(*this + n); }
+ bool operator==(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT
{
Expects(m_validator == rhs.m_validator);
return data_ == rhs.data_;
}
- bool operator!=(const contiguous_span_iterator& rhs) const noexcept { return !(*this == rhs); }
- bool operator<(const contiguous_span_iterator& rhs) const noexcept
+ bool operator!=(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT { return !(*this == rhs); }
+ bool operator<(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT
{
Expects(m_validator == rhs.m_validator);
return data_ < rhs.data_;
}
- bool operator<=(const contiguous_span_iterator& rhs) const noexcept { return !(rhs < *this); }
- bool operator>(const contiguous_span_iterator& rhs) const noexcept { return rhs < *this; }
- bool operator>=(const contiguous_span_iterator& rhs) const noexcept { return !(rhs > *this); }
- void swap(contiguous_span_iterator& rhs) noexcept
+ bool operator<=(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT { return !(rhs < *this); }
+ bool operator>(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT { return rhs < *this; }
+ bool operator>=(const contiguous_span_iterator& rhs) const GSL_NOEXCEPT { return !(rhs > *this); }
+ void swap(contiguous_span_iterator& rhs) GSL_NOEXCEPT
{
std::swap(data_, rhs.data_);
std::swap(m_validator, rhs.m_validator);
@@ -2091,7 +2092,7 @@ public:
template <typename Span>
contiguous_span_iterator<Span> operator+(typename contiguous_span_iterator<Span>::difference_type n,
- const contiguous_span_iterator<Span>& rhs) noexcept
+ const contiguous_span_iterator<Span>& rhs) GSL_NOEXCEPT
{
return rhs + n;
}
@@ -2121,68 +2122,68 @@ private:
}
public:
- reference operator*() noexcept { return (*m_container)[*m_itr]; }
- pointer operator->() noexcept { return &(*m_container)[*m_itr]; }
- general_span_iterator& operator++() noexcept
+ reference operator*() GSL_NOEXCEPT { return (*m_container)[*m_itr]; }
+ pointer operator->() GSL_NOEXCEPT { return &(*m_container)[*m_itr]; }
+ general_span_iterator& operator++() GSL_NOEXCEPT
{
++m_itr;
return *this;
}
- general_span_iterator operator++(int) noexcept
+ general_span_iterator operator++(int) GSL_NOEXCEPT
{
auto ret = *this;
++(*this);
return ret;
}
- general_span_iterator& operator--() noexcept
+ general_span_iterator& operator--() GSL_NOEXCEPT
{
--m_itr;
return *this;
}
- general_span_iterator operator--(int) noexcept
+ general_span_iterator operator--(int) GSL_NOEXCEPT
{
auto ret = *this;
--(*this);
return ret;
}
- general_span_iterator operator+(difference_type n) const noexcept
+ general_span_iterator operator+(difference_type n) const GSL_NOEXCEPT
{
general_span_iterator ret{*this};
return ret += n;
}
- general_span_iterator& operator+=(difference_type n) noexcept
+ general_span_iterator& operator+=(difference_type n) GSL_NOEXCEPT
{
m_itr += n;
return *this;
}
- general_span_iterator operator-(difference_type n) const noexcept
+ general_span_iterator operator-(difference_type n) const GSL_NOEXCEPT
{
general_span_iterator ret{*this};
return ret -= n;
}
- general_span_iterator& operator-=(difference_type n) noexcept { return *this += -n; }
- difference_type operator-(const general_span_iterator& rhs) const noexcept
+ general_span_iterator& operator-=(difference_type n) GSL_NOEXCEPT { return *this += -n; }
+ difference_type operator-(const general_span_iterator& rhs) const GSL_NOEXCEPT
{
Expects(m_container == rhs.m_container);
return m_itr - rhs.m_itr;
}
- value_type operator[](difference_type n) const noexcept { return (*m_container)[m_itr[n]]; }
+ value_type operator[](difference_type n) const GSL_NOEXCEPT { return (*m_container)[m_itr[n]]; }
- bool operator==(const general_span_iterator& rhs) const noexcept
+ bool operator==(const general_span_iterator& rhs) const GSL_NOEXCEPT
{
Expects(m_container == rhs.m_container);
return m_itr == rhs.m_itr;
}
- bool operator!=(const general_span_iterator& rhs) const noexcept { return !(*this == rhs); }
- bool operator<(const general_span_iterator& rhs) const noexcept
+ bool operator!=(const general_span_iterator& rhs) const GSL_NOEXCEPT { return !(*this == rhs); }
+ bool operator<(const general_span_iterator& rhs) const GSL_NOEXCEPT
{
Expects(m_container == rhs.m_container);
return m_itr < rhs.m_itr;
}
- bool operator<=(const general_span_iterator& rhs) const noexcept { return !(rhs < *this); }
- bool operator>(const general_span_iterator& rhs) const noexcept { return rhs < *this; }
- bool operator>=(const general_span_iterator& rhs) const noexcept { return !(rhs > *this); }
- void swap(general_span_iterator& rhs) noexcept
+ bool operator<=(const general_span_iterator& rhs) const GSL_NOEXCEPT { return !(rhs < *this); }
+ bool operator>(const general_span_iterator& rhs) const GSL_NOEXCEPT { return rhs < *this; }
+ bool operator>=(const general_span_iterator& rhs) const GSL_NOEXCEPT { return !(rhs > *this); }
+ void swap(general_span_iterator& rhs) GSL_NOEXCEPT
{
std::swap(m_itr, rhs.m_itr);
std::swap(m_container, rhs.m_container);
@@ -2191,42 +2192,30 @@ public:
template <typename Span>
general_span_iterator<Span> operator+(typename general_span_iterator<Span>::difference_type n,
- const general_span_iterator<Span>& rhs) noexcept
+ const general_span_iterator<Span>& rhs) GSL_NOEXCEPT
{
return rhs + n;
}
} // namespace gsl
-#ifdef GSL_THROW_ON_CONTRACT_VIOLATION
-
-#undef noexcept
+#undef GSL_NOEXCEPT
#ifdef _MSC_VER
-#pragma pop_macro("noexcept")
-#endif
-
-#endif // GSL_THROW_ON_CONTRACT_VIOLATION
-
-#ifdef _MSC_VER
-
-#if _MSC_VER <= 1800
-
-#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
-#undef noexcept
-#pragma pop_macro("noexcept")
-#endif
+ #if _MSC_VER < 1910
+ #if _MSC_VER <= 1800
+ #undef noexcept
+ #pragma pop_macro("noexcept")
-#undef GSL_MSVC_HAS_VARIADIC_CTOR_BUG
-#undef GSL_MSVC_NO_SUPPORT_FOR_MOVE_CTOR_DEFAULT
-#pragma warning(pop)
-
-#endif // _MSC_VER <= 1800
+ #undef GSL_MSVC_HAS_VARIADIC_CTOR_BUG
+ #undef GSL_MSVC_NO_SUPPORT_FOR_MOVE_CTOR_DEFAULT
+ #endif // _MSC_VER <= 1800
-#undef constexpr
-#pragma pop_macro("constexpr")
-#pragma warning(pop)
+ #undef constexpr
+ #pragma pop_macro("constexpr")
+ #endif // _MSC_VER < 1910
+ #pragma warning(pop)
#endif // _MSC_VER
#endif // GSL_MULTI_SPAN_H
diff --git a/gsl/span b/include/gsl/span
index c354e8f..79169f9 100644
--- a/gsl/span
+++ b/include/gsl/span
@@ -20,9 +20,9 @@
#ifndef GSL_SPAN_H
#define GSL_SPAN_H
-#include "gsl_assert"
-#include "gsl_byte"
-#include "gsl_util"
+#include <gsl/gsl_assert>
+#include <gsl/gsl_byte>
+#include <gsl/gsl_util>
#include <array>
#include <iterator>
#include <limits>
@@ -32,54 +32,44 @@
#include <memory>
#ifdef _MSC_VER
-
-#pragma warning(push)
-
-// turn off some warnings that are noisy about our Expects statements
-#pragma warning(disable : 4127) // conditional expression is constant
-
-// blanket turn off warnings from CppCoreCheck for now
-// so people aren't annoyed by them when running the tool.
-// more targeted suppressions will be added in a future update to the GSL
-#pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495)
-
-// No MSVC does constexpr fully yet
-#pragma push_macro("constexpr")
-#define constexpr /*constexpr*/
-
-// VS 2013 workarounds
-#if _MSC_VER <= 1800
-
-#define GSL_MSVC_HAS_VARIADIC_CTOR_BUG
-#define GSL_MSVC_NO_DEFAULT_MOVE_CTOR
-#define GSL_MSVC_NO_CPP14_STD_EQUAL
-
-// noexcept is not understood
-#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
-#pragma push_macro("noexcept")
-#define noexcept /*noexcept*/
-#endif
-
-#pragma push_macro("alignof")
-#define alignof __alignof
-
-// turn off some misguided warnings
-#pragma warning(push)
-#pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior
-#pragma warning(disable : 4512) // warns that assignment op could not be generated
-
-#endif // _MSC_VER <= 1800
-
+ #pragma warning(push)
+
+ // turn off some warnings that are noisy about our Expects statements
+ #pragma warning(disable : 4127) // conditional expression is constant
+
+ // blanket turn off warnings from CppCoreCheck for now
+ // so people aren't annoyed by them when running the tool.
+ // more targeted suppressions will be added in a future update to the GSL
+ #pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495)
+
+ #if _MSC_VER < 1910
+ #pragma push_macro("constexpr")
+ #define constexpr /*constexpr*/
+
+ // VS 2013 workarounds
+ #if _MSC_VER <= 1800
+ #define GSL_MSVC_HAS_VARIADIC_CTOR_BUG
+ #define GSL_MSVC_NO_DEFAULT_MOVE_CTOR
+ #define GSL_MSVC_NO_CPP14_STD_EQUAL
+
+ // noexcept is not understood
+ #pragma push_macro("noexcept")
+ #define noexcept /*noexcept*/
+
+ #pragma push_macro("alignof")
+ #define alignof __alignof
+
+ // turn off some misguided warnings
+ #pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior
+ #pragma warning(disable : 4512) // warns that assignment op could not be generated
+ #endif // _MSC_VER <= 1800
+ #endif // _MSC_VER < 1910
#endif // _MSC_VER
#ifdef GSL_THROW_ON_CONTRACT_VIOLATION
-
-#ifdef _MSC_VER
-#pragma push_macro("noexcept")
-#endif
-
-#define noexcept /*noexcept*/
-
+ #define GSL_NOEXCEPT /*noexcept*/
+#else
+ #define GSL_NOEXCEPT noexcept
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
namespace gsl
@@ -150,7 +140,7 @@ namespace details
std::conditional_t<IsConst, const element_type_, element_type_> &;
using pointer = std::add_pointer_t<reference>;
- constexpr span_iterator() noexcept : span_iterator(nullptr, 0) {}
+ constexpr span_iterator() GSL_NOEXCEPT : span_iterator(nullptr, 0) {}
constexpr span_iterator(const Span* span, typename Span::index_type index)
: span_(span), index_(index)
@@ -159,12 +149,12 @@ namespace details
}
friend class span_iterator<Span, true>;
- constexpr span_iterator(const span_iterator<Span, false>& other) noexcept
+ constexpr span_iterator(const span_iterator<Span, false>& other) GSL_NOEXCEPT
: span_iterator(other.span_, other.index_)
{
}
- constexpr span_iterator<Span, IsConst>& operator=(const span_iterator<Span, IsConst>&) noexcept = default;
+ constexpr span_iterator<Span, IsConst>& operator=(const span_iterator<Span, IsConst>&) GSL_NOEXCEPT = default;
constexpr reference operator*() const
{
@@ -185,7 +175,7 @@ namespace details
return *this;
}
- constexpr span_iterator operator++(int) noexcept
+ constexpr span_iterator operator++(int) GSL_NOEXCEPT
{
auto ret = *this;
++(*this);
@@ -199,14 +189,14 @@ namespace details
return *this;
}
- constexpr span_iterator operator--(int) noexcept
+ constexpr span_iterator operator--(int) GSL_NOEXCEPT
{
auto ret = *this;
--(*this);
return ret;
}
- constexpr span_iterator operator+(difference_type n) const noexcept
+ constexpr span_iterator operator+(difference_type n) const GSL_NOEXCEPT
{
auto ret = *this;
return ret += n;
@@ -219,13 +209,13 @@ namespace details
return *this;
}
- constexpr span_iterator operator-(difference_type n) const noexcept
+ constexpr span_iterator operator-(difference_type n) const GSL_NOEXCEPT
{
auto ret = *this;
return ret -= n;
}
- constexpr span_iterator& operator-=(difference_type n) noexcept { return *this += -n; }
+ constexpr span_iterator& operator-=(difference_type n) GSL_NOEXCEPT { return *this += -n; }
constexpr difference_type operator-(const span_iterator& rhs) const
{
@@ -233,16 +223,16 @@ namespace details
return index_ - rhs.index_;
}
- constexpr reference operator[](difference_type n) const noexcept { return *(*this + n); }
+ constexpr reference operator[](difference_type n) const GSL_NOEXCEPT { return *(*this + n); }
constexpr friend bool operator==(const span_iterator& lhs,
- const span_iterator& rhs) noexcept
+ const span_iterator& rhs) GSL_NOEXCEPT
{
return lhs.span_ == rhs.span_ && lhs.index_ == rhs.index_;
}
constexpr friend bool operator!=(const span_iterator& lhs,
- const span_iterator& rhs) noexcept
+ const span_iterator& rhs) GSL_NOEXCEPT
{
return !(lhs == rhs);
}
@@ -254,23 +244,23 @@ namespace details
}
constexpr friend bool operator<=(const span_iterator& lhs,
- const span_iterator& rhs) noexcept
+ const span_iterator& rhs) GSL_NOEXCEPT
{
return !(rhs < lhs);
}
- constexpr friend bool operator>(const span_iterator& lhs, const span_iterator& rhs) noexcept
+ constexpr friend bool operator>(const span_iterator& lhs, const span_iterator& rhs) GSL_NOEXCEPT
{
return rhs < lhs;
}
constexpr friend bool operator>=(const span_iterator& lhs,
- const span_iterator& rhs) noexcept
+ const span_iterator& rhs) GSL_NOEXCEPT
{
return !(rhs > lhs);
}
- void swap(span_iterator& rhs) noexcept
+ void swap(span_iterator& rhs) GSL_NOEXCEPT
{
std::swap(index_, rhs.index_);
std::swap(span_, rhs.span_);
@@ -282,17 +272,17 @@ namespace details
};
template <class Span, bool IsConst>
- constexpr span_iterator<Span, IsConst>
+ inline constexpr span_iterator<Span, IsConst>
operator+(typename span_iterator<Span, IsConst>::difference_type n,
- const span_iterator<Span, IsConst>& rhs) noexcept
+ const span_iterator<Span, IsConst>& rhs) GSL_NOEXCEPT
{
return rhs + n;
}
template <class Span, bool IsConst>
- constexpr span_iterator<Span, IsConst>
+ inline constexpr span_iterator<Span, IsConst>
operator-(typename span_iterator<Span, IsConst>::difference_type n,
- const span_iterator<Span, IsConst>& rhs) noexcept
+ const span_iterator<Span, IsConst>& rhs) GSL_NOEXCEPT
{
return rhs - n;
}
@@ -305,7 +295,7 @@ namespace details
static_assert(Ext >= 0, "A fixed-size span must be >= 0 in size.");
- constexpr extent_type() noexcept {}
+ constexpr extent_type() GSL_NOEXCEPT {}
template <index_type Other>
constexpr extent_type(extent_type<Other> ext)
@@ -317,7 +307,7 @@ namespace details
constexpr extent_type(index_type size) { Expects(size == Ext); }
- constexpr inline index_type size() const noexcept { return Ext; }
+ constexpr index_type size() const GSL_NOEXCEPT { return Ext; }
};
template <>
@@ -333,7 +323,7 @@ namespace details
explicit constexpr extent_type(index_type size) : size_(size) { Expects(size >= 0); }
- constexpr inline index_type size() const noexcept { return size_; }
+ constexpr index_type size() const GSL_NOEXCEPT { return size_; }
private:
index_type size_;
@@ -363,9 +353,9 @@ public:
// "Dependent" is needed to make "std::enable_if_t<Dependent || Extent <= 0>" SFINAE,
// since "std::enable_if_t<Extent <= 0>" is ill-formed when Extent is greater than 0.
class = std::enable_if_t<(Dependent || Extent <= 0)>>
- constexpr span() noexcept : storage_(nullptr, details::extent_type<0>()) {}
+ constexpr span() GSL_NOEXCEPT : storage_(nullptr, details::extent_type<0>()) {}
- constexpr span(std::nullptr_t) noexcept : span() {}
+ constexpr span(std::nullptr_t) GSL_NOEXCEPT : span() {}
constexpr span(pointer ptr, index_type count) : storage_(ptr, count) {}
@@ -375,18 +365,18 @@ public:
}
template <size_t N>
- constexpr span(element_type (&arr)[N]) noexcept : storage_(&arr[0], details::extent_type<N>())
+ constexpr span(element_type (&arr)[N]) GSL_NOEXCEPT : storage_(&arr[0], details::extent_type<N>())
{
}
template <size_t N, class ArrayElementType = std::remove_const_t<element_type>>
- constexpr span(std::array<ArrayElementType, N>& arr) noexcept
+ constexpr span(std::array<ArrayElementType, N>& arr) GSL_NOEXCEPT
: storage_(&arr[0], details::extent_type<N>())
{
}
template <size_t N>
- constexpr span(const std::array<std::remove_const_t<element_type>, N>& arr) noexcept
+ constexpr span(const std::array<std::remove_const_t<element_type>, N>& arr) GSL_NOEXCEPT
: storage_(&arr[0], details::extent_type<N>())
{
}
@@ -419,11 +409,11 @@ public:
{
}
- constexpr span(const span& other) noexcept = default;
+ constexpr span(const span& other) GSL_NOEXCEPT = default;
#ifndef GSL_MSVC_NO_DEFAULT_MOVE_CTOR
- constexpr span(span&& other) noexcept = default;
+ constexpr span(span&& other) GSL_NOEXCEPT = default;
#else
- constexpr span(span&& other) noexcept : storage_(std::move(other.storage_)) {}
+ constexpr span(span&& other) GSL_NOEXCEPT : storage_(std::move(other.storage_)) {}
#endif
template <
@@ -446,13 +436,13 @@ public:
{
}
- ~span() noexcept = default;
- constexpr span& operator=(const span& other) noexcept = default;
+ ~span() GSL_NOEXCEPT = default;
+ constexpr span& operator=(const span& other) GSL_NOEXCEPT = default;
#ifndef GSL_MSVC_NO_DEFAULT_MOVE_CTOR
- constexpr span& operator=(span&& other) noexcept = default;
+ constexpr span& operator=(span&& other) GSL_NOEXCEPT = default;
#else
- constexpr span& operator=(span&& other) noexcept
+ constexpr span& operator=(span&& other) GSL_NOEXCEPT
{
storage_ = std::move(other.storage_);
return *this;
@@ -502,11 +492,11 @@ public:
}
// [span.obs], span observers
- constexpr index_type length() const noexcept { return size(); }
- constexpr index_type size() const noexcept { return storage_.size(); }
- constexpr index_type length_bytes() const noexcept { return size_bytes(); }
- constexpr index_type size_bytes() const noexcept { return size() * narrow_cast<index_type>(sizeof(element_type)); }
- constexpr bool empty() const noexcept { return size() == 0; }
+ constexpr index_type length() const GSL_NOEXCEPT { return size(); }
+ constexpr index_type size() const GSL_NOEXCEPT { return storage_.size(); }
+ constexpr index_type length_bytes() const GSL_NOEXCEPT { return size_bytes(); }
+ constexpr index_type size_bytes() const GSL_NOEXCEPT { return size() * narrow_cast<index_type>(sizeof(element_type)); }
+ constexpr bool empty() const GSL_NOEXCEPT { return size() == 0; }
// [span.elem], span element access
constexpr reference operator[](index_type idx) const
@@ -517,20 +507,20 @@ public:
constexpr reference at(index_type idx) const { return this->operator[](idx); }
constexpr reference operator()(index_type idx) const { return this->operator[](idx); }
- constexpr pointer data() const noexcept { return storage_.data(); }
+ constexpr pointer data() const GSL_NOEXCEPT { return storage_.data(); }
// [span.iter], span iterator support
- iterator begin() const noexcept { return {this, 0}; }
- iterator end() const noexcept { return {this, length()}; }
+ iterator begin() const GSL_NOEXCEPT { return {this, 0}; }
+ iterator end() const GSL_NOEXCEPT { return {this, length()}; }
- const_iterator cbegin() const noexcept { return {this, 0}; }
- const_iterator cend() const noexcept { return {this, length()}; }
+ const_iterator cbegin() const GSL_NOEXCEPT { return {this, 0}; }
+ const_iterator cend() const GSL_NOEXCEPT { return {this, length()}; }
- reverse_iterator rbegin() const noexcept { return reverse_iterator{end()}; }
- reverse_iterator rend() const noexcept { return reverse_iterator{begin()}; }
+ reverse_iterator rbegin() const GSL_NOEXCEPT { return reverse_iterator{end()}; }
+ reverse_iterator rend() const GSL_NOEXCEPT { return reverse_iterator{begin()}; }
- const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator{cend()}; }
- const_reverse_iterator crend() const noexcept { return const_reverse_iterator{cbegin()}; }
+ const_reverse_iterator crbegin() const GSL_NOEXCEPT { return const_reverse_iterator{cend()}; }
+ const_reverse_iterator crend() const GSL_NOEXCEPT { return const_reverse_iterator{cbegin()}; }
private:
// this implementation detail class lets us take advantage of the
@@ -546,7 +536,7 @@ private:
Expects((!data && ExtentType::size() == 0) || (data && ExtentType::size() >= 0));
}
- constexpr inline pointer data() const noexcept { return data_; }
+ constexpr pointer data() const GSL_NOEXCEPT { return data_; }
private:
pointer data_;
@@ -557,7 +547,7 @@ private:
// [span.comparison], span comparison operators
template <class ElementType, std::ptrdiff_t FirstExtent, std::ptrdiff_t SecondExtent>
-constexpr bool operator==(const span<ElementType, FirstExtent>& l,
+inline constexpr bool operator==(const span<ElementType, FirstExtent>& l,
const span<ElementType, SecondExtent>& r)
{
#ifdef GSL_MSVC_NO_CPP14_STD_EQUAL
@@ -568,31 +558,31 @@ constexpr bool operator==(const span<ElementType, FirstExtent>& l,
}
template <class ElementType, std::ptrdiff_t Extent>
-constexpr bool operator!=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
+inline constexpr bool operator!=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
{
return !(l == r);
}
template <class ElementType, std::ptrdiff_t Extent>
-constexpr bool operator<(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
+inline constexpr bool operator<(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
{
return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end());
}
template <class ElementType, std::ptrdiff_t Extent>
-constexpr bool operator<=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
+inline constexpr bool operator<=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
{
return !(l > r);
}
template <class ElementType, std::ptrdiff_t Extent>
-constexpr bool operator>(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
+inline constexpr bool operator>(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
{
return r < l;
}
template <class ElementType, std::ptrdiff_t Extent>
-constexpr bool operator>=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
+inline constexpr bool operator>=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r)
{
return !(l < r);
}
@@ -623,7 +613,7 @@ namespace details
// [span.objectrep], views of object representation
template <class ElementType, std::ptrdiff_t Extent>
span<const byte, details::calculate_byte_size<ElementType, Extent>::value>
-as_bytes(span<ElementType, Extent> s) noexcept
+as_bytes(span<ElementType, Extent> s) GSL_NOEXCEPT
{
return {reinterpret_cast<const byte*>(s.data()), s.size_bytes()};
}
@@ -631,7 +621,7 @@ as_bytes(span<ElementType, Extent> s) noexcept
template <class ElementType, std::ptrdiff_t Extent,
class = std::enable_if_t<!std::is_const<ElementType>::value>>
span<byte, details::calculate_byte_size<ElementType, Extent>::value>
-as_writeable_bytes(span<ElementType, Extent> s) noexcept
+as_writeable_bytes(span<ElementType, Extent> s) GSL_NOEXCEPT
{
return {reinterpret_cast<byte*>(s.data()), s.size_bytes()};
}
@@ -677,7 +667,7 @@ make_span(Ptr& cont)
// Specialization of gsl::at for span
template <class ElementType, std::ptrdiff_t Extent>
-constexpr ElementType& at(const span<ElementType, Extent>& s, std::ptrdiff_t index)
+inline constexpr ElementType& at(const span<ElementType, Extent>& s, std::ptrdiff_t index)
{
// No bounds checking here because it is done in span::operator[] called below
return s[index];
@@ -685,39 +675,27 @@ constexpr ElementType& at(const span<ElementType, Extent>& s, std::ptrdiff_t ind
} // namespace gsl
-#ifdef _MSC_VER
-
-#undef constexpr
-#pragma pop_macro("constexpr")
-
-#if _MSC_VER <= 1800
-#pragma warning(pop)
+#undef GSL_NOEXCEPT
-#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
-#undef noexcept
-#pragma pop_macro("noexcept")
-#endif // GSL_THROW_ON_CONTRACT_VIOLATION
+#ifdef _MSC_VER
+ #if _MSC_VER < 1910
+ #undef constexpr
+ #pragma pop_macro("constexpr")
-#pragma pop_macro("alignof")
+ #if _MSC_VER <= 1800
+ #undef noexcept
+ #pragma pop_macro("noexcept")
-#undef GSL_MSVC_HAS_VARIADIC_CTOR_BUG
+ #undef alignof
+ #pragma pop_macro("alignof")
-#endif // _MSC_VER <= 1800
+ #undef GSL_MSVC_HAS_VARIADIC_CTOR_BUG
+ #undef GSL_MSVC_NO_DEFAULT_MOVE_CTOR
+ #undef GSL_MSVC_NO_CPP14_STD_EQUAL
+ #endif // _MSC_VER <= 1800
+ #endif // _MSC_VER < 1910
+ #pragma warning(pop)
#endif // _MSC_VER
-#if defined(GSL_THROW_ON_CONTRACT_VIOLATION)
-
-#undef noexcept
-
-#ifdef _MSC_VER
-#pragma pop_macro("noexcept")
-#endif
-
-#endif // GSL_THROW_ON_CONTRACT_VIOLATION
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
#endif // GSL_SPAN_H
diff --git a/gsl/string_span b/include/gsl/string_span
index b5512a2..093cf9c 100644
--- a/gsl/string_span
+++ b/include/gsl/string_span
@@ -19,52 +19,44 @@
#ifndef GSL_STRING_SPAN_H
#define GSL_STRING_SPAN_H
-#include "gsl_assert"
-#include "gsl_util"
-#include "span"
+#include <gsl/gsl_assert>
+#include <gsl/gsl_util>
+#include <gsl/span>
#include <cstdint>
#include <cstring>
#include <string>
#ifdef _MSC_VER
-
-// No MSVC does constexpr fully yet
-#pragma push_macro("constexpr")
-#define constexpr /*constexpr*/
-
-#pragma warning(push)
-
-// blanket turn off warnings from CppCoreCheck for now
-// so people aren't annoyed by them when running the tool.
-// more targeted suppressions will be added in a future update to the GSL
-#pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495)
-
-// VS 2013 workarounds
-#if _MSC_VER <= 1800
-
-#define GSL_MSVC_HAS_TYPE_DEDUCTION_BUG
-#define GSL_MSVC_HAS_SFINAE_SUBSTITUTION_ICE
-#define GSL_MSVC_NO_CPP14_STD_EQUAL
-#define GSL_MSVC_NO_DEFAULT_MOVE_CTOR
-
-// noexcept is not understood
-#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
-#pragma push_macro("noexcept")
-#define noexcept /*noexcept*/
-#endif
-
-#endif // _MSC_VER <= 1800
+ #pragma warning(push)
+
+ // blanket turn off warnings from CppCoreCheck for now
+ // so people aren't annoyed by them when running the tool.
+ // more targeted suppressions will be added in a future update to the GSL
+ #pragma warning(disable : 26481 26482 26483 26485 26490 26491 26492 26493 26495)
+
+ #if _MSC_VER < 1910
+ #pragma push_macro("constexpr")
+ #define constexpr /*constexpr*/
+
+ // VS 2013 workarounds
+ #if _MSC_VER <= 1800
+ #define GSL_MSVC_HAS_TYPE_DEDUCTION_BUG
+ #define GSL_MSVC_HAS_SFINAE_SUBSTITUTION_ICE
+ #define GSL_MSVC_NO_CPP14_STD_EQUAL
+ #define GSL_MSVC_NO_DEFAULT_MOVE_CTOR
+
+ // noexcept is not understood
+ #pragma push_macro("noexcept")
+ #define noexcept /*noexcept*/
+ #endif // _MSC_VER <= 1800
+ #endif // _MSC_VER < 1910
#endif // _MSC_VER
// In order to test the library, we need it to throw exceptions that we can catch
#ifdef GSL_THROW_ON_CONTRACT_VIOLATION
-
-#ifdef _MSC_VER
-#pragma push_macro("noexcept")
-#endif
-
-#define noexcept /*noexcept*/
-
+ #define GSL_NOEXCEPT /*noexcept*/
+#else
+ #define GSL_NOEXCEPT noexcept
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
namespace gsl
@@ -72,7 +64,7 @@ namespace gsl
//
// czstring and wzstring
//
-// These are "tag" typedef's for C-style strings (i.e. null-terminated character arrays)
+// These are "tag" typedefs for C-style strings (i.e. null-terminated character arrays)
// that allow static analysis to help find bugs.
//
// There are no additional features/semantics that we can find a way to add inside the
@@ -225,7 +217,7 @@ namespace details
template <>
struct length_func<char>
{
- std::ptrdiff_t operator()(char* const ptr, std::ptrdiff_t length) noexcept
+ std::ptrdiff_t operator()(char* const ptr, std::ptrdiff_t length) GSL_NOEXCEPT
{
return details::string_length(ptr, length);
}
@@ -234,7 +226,7 @@ namespace details
template <>
struct length_func<wchar_t>
{
- std::ptrdiff_t operator()(wchar_t* const ptr, std::ptrdiff_t length) noexcept
+ std::ptrdiff_t operator()(wchar_t* const ptr, std::ptrdiff_t length) GSL_NOEXCEPT
{
return details::wstring_length(ptr, length);
}
@@ -243,7 +235,7 @@ namespace details
template <>
struct length_func<const char>
{
- std::ptrdiff_t operator()(const char* const ptr, std::ptrdiff_t length) noexcept
+ std::ptrdiff_t operator()(const char* const ptr, std::ptrdiff_t length) GSL_NOEXCEPT
{
return details::string_length(ptr, length);
}
@@ -252,7 +244,7 @@ namespace details
template <>
struct length_func<const wchar_t>
{
- std::ptrdiff_t operator()(const wchar_t* const ptr, std::ptrdiff_t length) noexcept
+ std::ptrdiff_t operator()(const wchar_t* const ptr, std::ptrdiff_t length) GSL_NOEXCEPT
{
return details::wstring_length(ptr, length);
}
@@ -279,26 +271,26 @@ public:
using const_reverse_iterator = typename impl_type::const_reverse_iterator;
// default (empty)
- constexpr basic_string_span() noexcept = default;
+ constexpr basic_string_span() GSL_NOEXCEPT = default;
// copy
- constexpr basic_string_span(const basic_string_span& other) noexcept = default;
+ constexpr basic_string_span(const basic_string_span& other) GSL_NOEXCEPT = default;
// move
#ifndef GSL_MSVC_NO_DEFAULT_MOVE_CTOR
- constexpr basic_string_span(basic_string_span&& other) noexcept = default;
+ constexpr basic_string_span(basic_string_span&& other) GSL_NOEXCEPT = default;
#else
constexpr basic_string_span(basic_string_span&& other) : span_(std::move(other.span_)) {}
#endif
// assign
- constexpr basic_string_span& operator=(const basic_string_span& other) noexcept = default;
+ constexpr basic_string_span& operator=(const basic_string_span& other) GSL_NOEXCEPT = default;
// move assign
#ifndef GSL_MSVC_NO_DEFAULT_MOVE_CTOR
- constexpr basic_string_span& operator=(basic_string_span&& other) noexcept = default;
+ constexpr basic_string_span& operator=(basic_string_span&& other) GSL_NOEXCEPT = default;
#else
- constexpr basic_string_span& operator=(basic_string_span&& other) noexcept
+ constexpr basic_string_span& operator=(basic_string_span&& other) GSL_NOEXCEPT
{
span_ = std::move(other.span_);
return *this;
@@ -306,7 +298,7 @@ public:
#endif
// from nullptr
- constexpr basic_string_span(std::nullptr_t ptr) noexcept : span_(ptr) {}
+ constexpr basic_string_span(std::nullptr_t ptr) GSL_NOEXCEPT : span_(ptr) {}
constexpr basic_string_span(pointer ptr, index_type length) : span_(ptr, length) {}
constexpr basic_string_span(pointer firstElem, pointer lastElem) : span_(firstElem, lastElem) {}
@@ -319,12 +311,12 @@ public:
}
template <size_t N, class ArrayElementType = std::remove_const_t<element_type>>
- constexpr basic_string_span(std::array<ArrayElementType, N>& arr) noexcept : span_(arr)
+ constexpr basic_string_span(std::array<ArrayElementType, N>& arr) GSL_NOEXCEPT : span_(arr)
{
}
template <size_t N, class ArrayElementType = std::remove_const_t<element_type>>
- constexpr basic_string_span(const std::array<ArrayElementType, N>& arr) noexcept : span_(arr)
+ constexpr basic_string_span(const std::array<ArrayElementType, N>& arr) GSL_NOEXCEPT : span_(arr)
{
}
@@ -411,23 +403,23 @@ public:
constexpr pointer data() const { return span_.data(); }
- constexpr index_type length() const noexcept { return span_.size(); }
- constexpr index_type size() const noexcept { return span_.size(); }
- constexpr index_type size_bytes() const noexcept { return span_.size_bytes(); }
- constexpr index_type length_bytes() const noexcept { return span_.length_bytes(); }
- constexpr bool empty() const noexcept { return size() == 0; }
+ constexpr index_type length() const GSL_NOEXCEPT { return span_.size(); }
+ constexpr index_type size() const GSL_NOEXCEPT { return span_.size(); }
+ constexpr index_type size_bytes() const GSL_NOEXCEPT { return span_.size_bytes(); }
+ constexpr index_type length_bytes() const GSL_NOEXCEPT { return span_.length_bytes(); }
+ constexpr bool empty() const GSL_NOEXCEPT { return size() == 0; }
- constexpr iterator begin() const noexcept { return span_.begin(); }
- constexpr iterator end() const noexcept { return span_.end(); }
+ constexpr iterator begin() const GSL_NOEXCEPT { return span_.begin(); }
+ constexpr iterator end() const GSL_NOEXCEPT { return span_.end(); }
- constexpr const_iterator cbegin() const noexcept { return span_.cbegin(); }
- constexpr const_iterator cend() const noexcept { return span_.cend(); }
+ constexpr const_iterator cbegin() const GSL_NOEXCEPT { return span_.cbegin(); }
+ constexpr const_iterator cend() const GSL_NOEXCEPT { return span_.cend(); }
- constexpr reverse_iterator rbegin() const noexcept { return span_.rbegin(); }
- constexpr reverse_iterator rend() const noexcept { return span_.rend(); }
+ constexpr reverse_iterator rbegin() const GSL_NOEXCEPT { return span_.rbegin(); }
+ constexpr reverse_iterator rend() const GSL_NOEXCEPT { return span_.rend(); }
- constexpr const_reverse_iterator crbegin() const noexcept { return span_.crbegin(); }
- constexpr const_reverse_iterator crend() const noexcept { return span_.crend(); }
+ constexpr const_reverse_iterator crbegin() const GSL_NOEXCEPT { return span_.crbegin(); }
+ constexpr const_reverse_iterator crend() const GSL_NOEXCEPT { return span_.crend(); }
private:
static impl_type remove_z(pointer const& sz, std::ptrdiff_t max)
@@ -501,7 +493,7 @@ std::basic_string<CharT, Traits, Allocator> to_basic_string(basic_string_span<gC
{
return {view.data(), static_cast<size_t>(view.length())};
}
-
+
// zero-terminated string span, used to convert
// zero-terminated spans to legacy strings
template <typename CharT, std::ptrdiff_t Extent = dynamic_extent>
@@ -520,7 +512,7 @@ public:
using impl_type = span<value_type, Extent>;
using string_span_type = basic_string_span<value_type, Extent>;
- constexpr basic_zstring_span(impl_type s) noexcept : span_(s)
+ constexpr basic_zstring_span(impl_type s) GSL_NOEXCEPT : span_(s)
{
// expects a zero-terminated span
Expects(s[s.size() - 1] == '\0');
@@ -550,17 +542,17 @@ public:
}
#endif
- constexpr bool empty() const noexcept { return span_.size() == 0; }
+ constexpr bool empty() const GSL_NOEXCEPT { return span_.size() == 0; }
- constexpr string_span_type as_string_span() const noexcept
+ constexpr string_span_type as_string_span() const GSL_NOEXCEPT
{
auto sz = span_.size();
return span_.first(sz <= 0 ? 0 : sz - 1);
}
- constexpr string_span_type ensure_z() const noexcept { return gsl::ensure_z(span_); }
+ constexpr string_span_type ensure_z() const GSL_NOEXCEPT { return gsl::ensure_z(span_); }
- constexpr const_zstring_type assume_z() const noexcept { return span_.data(); }
+ constexpr const_zstring_type assume_z() const GSL_NOEXCEPT { return span_.data(); }
private:
impl_type span_;
@@ -583,7 +575,7 @@ template <class CharT, std::ptrdiff_t Extent, class T,
class = std::enable_if_t<
details::is_basic_string_span<T>::value ||
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>>>::value>>
-bool operator==(const gsl::basic_string_span<CharT, Extent>& one, const T& other) noexcept
+bool operator==(const gsl::basic_string_span<CharT, Extent>& one, const T& other) GSL_NOEXCEPT
{
gsl::basic_string_span<std::add_const_t<CharT>> tmp(other);
#ifdef GSL_MSVC_NO_CPP14_STD_EQUAL
@@ -597,7 +589,7 @@ template <class CharT, std::ptrdiff_t Extent, class T,
class = std::enable_if_t<
!details::is_basic_string_span<T>::value &&
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>>>::value>>
-bool operator==(const T& one, const gsl::basic_string_span<CharT, Extent>& other) noexcept
+bool operator==(const T& one, const gsl::basic_string_span<CharT, Extent>& other) GSL_NOEXCEPT
{
gsl::basic_string_span<std::add_const_t<CharT>> tmp(one);
#ifdef GSL_MSVC_NO_CPP14_STD_EQUAL
@@ -611,7 +603,7 @@ bool operator==(const T& one, const gsl::basic_string_span<CharT, Extent>& other
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T,
typename = std::enable_if_t<std::is_convertible<
T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value>>
-bool operator!=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
+bool operator!=(gsl::basic_string_span<CharT, Extent> one, const T& other) GSL_NOEXCEPT
{
return !(one == other);
}
@@ -621,7 +613,7 @@ template <
typename Dummy = std::enable_if_t<
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value &&
!gsl::details::is_basic_string_span<T>::value>>
-bool operator!=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
+bool operator!=(const T& one, gsl::basic_string_span<CharT, Extent> other) GSL_NOEXCEPT
{
return !(one == other);
}
@@ -630,7 +622,7 @@ bool operator!=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexc
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T,
typename = std::enable_if_t<std::is_convertible<
T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value>>
-bool operator<(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
+bool operator<(gsl::basic_string_span<CharT, Extent> one, const T& other) GSL_NOEXCEPT
{
gsl::basic_string_span<std::add_const_t<CharT>, Extent> tmp(other);
return std::lexicographical_compare(one.begin(), one.end(), tmp.begin(), tmp.end());
@@ -641,7 +633,7 @@ template <
typename Dummy = std::enable_if_t<
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value &&
!gsl::details::is_basic_string_span<T>::value>>
-bool operator<(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
+bool operator<(const T& one, gsl::basic_string_span<CharT, Extent> other) GSL_NOEXCEPT
{
gsl::basic_string_span<std::add_const_t<CharT>, Extent> tmp(one);
return std::lexicographical_compare(tmp.begin(), tmp.end(), other.begin(), other.end());
@@ -660,7 +652,7 @@ template <
std::is_convertible<DataType*, CharT*>::value &&
std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>,
DataType>::value>>
-bool operator<(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
+bool operator<(gsl::basic_string_span<CharT, Extent> one, const T& other) GSL_NOEXCEPT
{
gsl::basic_string_span<std::add_const_t<CharT>, Extent> tmp(other);
return std::lexicographical_compare(one.begin(), one.end(), tmp.begin(), tmp.end());
@@ -674,7 +666,7 @@ template <
std::is_convertible<DataType*, CharT*>::value &&
std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>,
DataType>::value>>
-bool operator<(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
+bool operator<(const T& one, gsl::basic_string_span<CharT, Extent> other) GSL_NOEXCEPT
{
gsl::basic_string_span<std::add_const_t<CharT>, Extent> tmp(one);
return std::lexicographical_compare(tmp.begin(), tmp.end(), other.begin(), other.end());
@@ -685,7 +677,7 @@ bool operator<(const T& one, gsl::basic_string_span<CharT, Extent> other) noexce
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T,
typename = std::enable_if_t<std::is_convertible<
T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value>>
-bool operator<=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
+bool operator<=(gsl::basic_string_span<CharT, Extent> one, const T& other) GSL_NOEXCEPT
{
return !(other < one);
}
@@ -695,7 +687,7 @@ template <
typename Dummy = std::enable_if_t<
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value &&
!gsl::details::is_basic_string_span<T>::value>>
-bool operator<=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
+bool operator<=(const T& one, gsl::basic_string_span<CharT, Extent> other) GSL_NOEXCEPT
{
return !(other < one);
}
@@ -713,7 +705,7 @@ template <
std::is_convertible<DataType*, CharT*>::value &&
std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>,
DataType>::value>>
-bool operator<=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
+bool operator<=(gsl::basic_string_span<CharT, Extent> one, const T& other) GSL_NOEXCEPT
{
return !(other < one);
}
@@ -726,7 +718,7 @@ template <
std::is_convertible<DataType*, CharT*>::value &&
std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>,
DataType>::value>>
-bool operator<=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
+bool operator<=(const T& one, gsl::basic_string_span<CharT, Extent> other) GSL_NOEXCEPT
{
return !(other < one);
}
@@ -736,7 +728,7 @@ bool operator<=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexc
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T,
typename = std::enable_if_t<std::is_convertible<
T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value>>
-bool operator>(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
+bool operator>(gsl::basic_string_span<CharT, Extent> one, const T& other) GSL_NOEXCEPT
{
return other < one;
}
@@ -746,7 +738,7 @@ template <
typename Dummy = std::enable_if_t<
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value &&
!gsl::details::is_basic_string_span<T>::value>>
-bool operator>(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
+bool operator>(const T& one, gsl::basic_string_span<CharT, Extent> other) GSL_NOEXCEPT
{
return other < one;
}
@@ -764,7 +756,7 @@ template <
std::is_convertible<DataType*, CharT*>::value &&
std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>,
DataType>::value>>
-bool operator>(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
+bool operator>(gsl::basic_string_span<CharT, Extent> one, const T& other) GSL_NOEXCEPT
{
return other < one;
}
@@ -777,7 +769,7 @@ template <
std::is_convertible<DataType*, CharT*>::value &&
std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>,
DataType>::value>>
-bool operator>(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
+bool operator>(const T& one, gsl::basic_string_span<CharT, Extent> other) GSL_NOEXCEPT
{
return other < one;
}
@@ -787,7 +779,7 @@ bool operator>(const T& one, gsl::basic_string_span<CharT, Extent> other) noexce
template <typename CharT, std::ptrdiff_t Extent = gsl::dynamic_extent, typename T,
typename = std::enable_if_t<std::is_convertible<
T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value>>
-bool operator>=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
+bool operator>=(gsl::basic_string_span<CharT, Extent> one, const T& other) GSL_NOEXCEPT
{
return !(one < other);
}
@@ -797,7 +789,7 @@ template <
typename Dummy = std::enable_if_t<
std::is_convertible<T, gsl::basic_string_span<std::add_const_t<CharT>, Extent>>::value &&
!gsl::details::is_basic_string_span<T>::value>>
-bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
+bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> other) GSL_NOEXCEPT
{
return !(one < other);
}
@@ -815,7 +807,7 @@ template <
std::is_convertible<DataType*, CharT*>::value &&
std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>,
DataType>::value>>
-bool operator>=(gsl::basic_string_span<CharT, Extent> one, const T& other) noexcept
+bool operator>=(gsl::basic_string_span<CharT, Extent> one, const T& other) GSL_NOEXCEPT
{
return !(one < other);
}
@@ -828,43 +820,33 @@ template <
std::is_convertible<DataType*, CharT*>::value &&
std::is_same<std::decay_t<decltype(std::declval<T>().size(), *std::declval<T>().data())>,
DataType>::value>>
-bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexcept
+bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> other) GSL_NOEXCEPT
{
return !(one < other);
}
#endif
} // namespace GSL
-#ifdef _MSC_VER
-
-#pragma warning(pop)
-
-#undef constexpr
-#pragma pop_macro("constexpr")
-
-// VS 2013 workarounds
-#if _MSC_VER <= 1800
-
-#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
-#undef noexcept
-#pragma pop_macro("noexcept")
-#endif // GSL_THROW_ON_CONTRACT_VIOLATION
-
-#undef GSL_MSVC_HAS_TYPE_DEDUCTION_BUG
-#undef GSL_MSVC_HAS_SFINAE_SUBSTITUTION_ICE
-#undef GSL_MSVC_NO_CPP14_STD_EQUAL
-#undef GSL_MSVC_NO_DEFAULT_MOVE_CTOR
-
-#endif // _MSC_VER <= 1800
-#endif // _MSC_VER
-
-#if defined(GSL_THROW_ON_CONTRACT_VIOLATION)
-
-#undef noexcept
+#undef GSL_NOEXCEPT
#ifdef _MSC_VER
-#pragma pop_macro("noexcept")
-#endif
+ #pragma warning(pop)
+
+ #if _MSC_VER < 1910
+ #undef constexpr
+ #pragma pop_macro("constexpr")
+
+ // VS 2013 workarounds
+ #if _MSC_VER <= 1800
+ #undef noexcept
+ #pragma pop_macro("noexcept")
+
+ #undef GSL_MSVC_HAS_TYPE_DEDUCTION_BUG
+ #undef GSL_MSVC_HAS_SFINAE_SUBSTITUTION_ICE
+ #undef GSL_MSVC_NO_CPP14_STD_EQUAL
+ #undef GSL_MSVC_NO_DEFAULT_MOVE_CTOR
+ #endif // _MSC_VER <= 1800
+ #endif // _MSC_VER < 1910
+#endif // _MSC_VER
-#endif // GSL_THROW_ON_CONTRACT_VIOLATION
#endif // GSL_STRING_SPAN_H
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index bdc3f61..40c46d5 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -9,7 +9,7 @@ endif()
add_subdirectory(unittest-cpp)
include_directories(
- ..
+ ../include
./unittest-cpp
)
@@ -33,7 +33,7 @@ else()
endif()
function(add_gsl_test name)
- add_executable(${name} ${name}.cpp ../gsl/gsl ../gsl/gsl_assert ../gsl/gsl_util ../gsl/multi_span ../gsl/span ../gsl/string_span)
+ add_executable(${name} ${name}.cpp)
target_link_libraries(${name} UnitTest++)
add_test(
${name}
@@ -53,4 +53,3 @@ add_gsl_test(utils_tests)
add_gsl_test(owner_tests)
add_gsl_test(byte_tests)
add_gsl_test(algorithm_tests)
-
diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp
index cab9db1..2d23f85 100644
--- a/tests/multi_span_tests.cpp
+++ b/tests/multi_span_tests.cpp
@@ -1148,7 +1148,7 @@ SUITE(multi_span_tests)
auto width = 5, height = 20;
auto imgSize = width * height;
- auto image_ptr = new int[imgSize][3];
+ auto image_ptr = new int[static_cast<std::size_t>(imgSize)][3];
// size check will be done
auto image_view =
@@ -1496,7 +1496,7 @@ SUITE(multi_span_tests)
auto height = 4, width = 2;
auto size = height * width;
- auto arr = new int[size];
+ auto arr = new int[static_cast<std::size_t>(size)];
for (auto i = 0; i < size; ++i) {
arr[i] = i;
}
diff --git a/tests/strided_span_tests.cpp b/tests/strided_span_tests.cpp
index de10910..471f839 100644
--- a/tests/strided_span_tests.cpp
+++ b/tests/strided_span_tests.cpp
@@ -1,20 +1,20 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
-//
-// This code is licensed under the MIT License (MIT).
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
+//
+// This code is licensed under the MIT License (MIT).
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
///////////////////////////////////////////////////////////////////////////////
-#include <UnitTest++/UnitTest++.h>
+#include <UnitTest++/UnitTest++.h>
#include <gsl/multi_span>
#include <string>
@@ -27,7 +27,7 @@
using namespace std;
using namespace gsl;
-namespace
+namespace
{
struct BaseClass {};
struct DerivedClass : BaseClass {};
@@ -38,7 +38,7 @@ SUITE(strided_span_tests)
TEST (span_section_test)
{
int a[30][4][5];
-
+
auto av = as_multi_span(a);
auto sub = av.section({15, 0, 0}, gsl::index<3>{2, 2, 2});
auto subsub = sub.section({1, 0, 0}, gsl::index<3>{1, 1, 1});
@@ -143,7 +143,7 @@ SUITE(strided_span_tests)
#else
strided_span<const volatile int, 1> sav_cv{ multi_span<const volatile int>{src}, strided_bounds<1>{2, 1} };
#endif
-
+
CHECK(sav_cv.bounds().index_bounds() == index<1>{ 2 });
CHECK(sav_cv.bounds().strides() == index<1>{ 1 });
CHECK(sav_cv[1] == 2);
@@ -188,13 +188,13 @@ SUITE(strided_span_tests)
CHECK(av2[1] == 5);
static_assert(std::is_convertible<const multi_span<int, 2>, multi_span<const int, 2>>::value, "ctor is not implicit!");
-
+
const strided_span<int, 1> src{ arr, {2, 1} };
strided_span<const int, 1> sav{ src };
CHECK(sav.bounds().index_bounds() == index<1>{ 2 });
CHECK(sav.bounds().stride() == 1);
CHECK(sav[1] == 5);
-
+
static_assert(std::is_convertible<const strided_span<int, 1>, strided_span<const int, 1>>::value, "ctor is not implicit!");
}
@@ -203,7 +203,7 @@ SUITE(strided_span_tests)
int arr1[2] = { 3, 4 };
const strided_span<int, 1> src1{ arr1, {2, 1} };
strided_span<int, 1> sav1{ src1 };
-
+
CHECK(sav1.bounds().index_bounds() == index<1>{ 2 });
CHECK(sav1.bounds().stride() == 1);
CHECK(sav1[0] == 3);
@@ -229,7 +229,7 @@ SUITE(strided_span_tests)
CHECK(sav[0] == 1);
CHECK(&sav_ref == &sav);
}
-
+
// Check copy assignment operator
{
int arr1[2] = { 3, 4 };
@@ -304,7 +304,7 @@ SUITE(strided_span_tests)
CHECK(cm_sl[1] == 11);
CHECK(cm_sl[2] == 12);
- // Section
+ // Section
strided_span<int, 2> cm_sec = cm_sav.section( { 2, 1 }, { 3, 2 });
CHECK((cm_sec.bounds().index_bounds() == index<2>{3, 2}));
@@ -321,11 +321,11 @@ SUITE(strided_span_tests)
{
// incorrect sections
-
+
CHECK_THROW(av.section(0, 0)[0], fail_fast);
CHECK_THROW(av.section(1, 0)[0], fail_fast);
CHECK_THROW(av.section(1, 1)[1], fail_fast);
-
+
CHECK_THROW(av.section(2, 5), fail_fast);
CHECK_THROW(av.section(5, 2), fail_fast);
CHECK_THROW(av.section(5, 0), fail_fast);
@@ -354,7 +354,7 @@ SUITE(strided_span_tests)
}
{
- // strided array ctor with matching strided bounds
+ // strided array ctor with matching strided bounds
strided_span<int, 1> sav{ arr,{ 4, 1 } };
CHECK(sav.bounds().index_bounds() == index<1>{ 4 });
CHECK(sav[3] == 3);
@@ -362,7 +362,7 @@ SUITE(strided_span_tests)
}
{
- // strided array ctor with smaller strided bounds
+ // strided array ctor with smaller strided bounds
strided_span<int, 1> sav{ arr,{ 2, 1 } };
CHECK(sav.bounds().index_bounds() == index<1>{ 2 });
CHECK(sav[1] == 1);
@@ -370,7 +370,7 @@ SUITE(strided_span_tests)
}
{
- // strided array ctor with fitting irregular bounds
+ // strided array ctor with fitting irregular bounds
strided_span<int, 1> sav{ arr,{ 2, 3 } };
CHECK(sav.bounds().index_bounds() == index<1>{ 2 });
CHECK(sav[0] == 0);
@@ -663,7 +663,7 @@ SUITE(strided_span_tests)
auto height = 12, width = 2;
auto size = height * width;
- auto arr = new int[size];
+ auto arr = new int[static_cast<std::size_t>(size)];
for (auto i = 0; i < size; ++i)
{
arr[i] = i;
@@ -713,12 +713,12 @@ SUITE(strided_span_tests)
auto section = av.section({0, 2 * s}, {4, s}); // { { arr[0].c[0], arr[0].c[1], arr[0].c[2], arr[0].c[3] } , { arr[1].c[0], ... } , ... }
// convert to array 4x1 array of integers
- auto cs = section.as_strided_span<int>(); // { { arr[0].c }, {arr[1].c } , ... }
+ auto cs = section.as_strided_span<int>(); // { { arr[0].c }, {arr[1].c } , ... }
CHECK(cs.bounds().index_bounds()[0] == 4);
CHECK(cs.bounds().index_bounds()[1] == 1);
- // transpose to 1x4 array
+ // transpose to 1x4 array
strided_bounds<2> reverse_bounds{
{cs.bounds().index_bounds()[1] , cs.bounds().index_bounds()[0]},
{cs.bounds().strides()[1], cs.bounds().strides()[0]}
diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp
index a1cfe79..471d5de 100644
--- a/tests/string_span_tests.cpp
+++ b/tests/string_span_tests.cpp
@@ -125,7 +125,7 @@ SUITE(string_span_tests)
CHECK(static_cast<cstring_span<>::index_type>(s2.length()) == v.length());
CHECK(s2.length() == 5);
}
-
+
TEST(EqualityAndImplicitConstructors)
{
{
@@ -134,7 +134,7 @@ SUITE(string_span_tests)
// comparison to empty span
CHECK(span1 != span);
- CHECK(span != span1);
+ CHECK(span != span1);
}
{
@@ -291,7 +291,7 @@ SUITE(string_span_tests)
string_span<> _span{ _ptr, 5 };
// non-const span, non-const other type
-
+
CHECK(_span == _ar);
CHECK(_span == _ar1);
CHECK(_span == _ar2);
@@ -759,7 +759,7 @@ SUITE(string_span_tests)
T create() { return T{}; }
template <class T>
- void use(basic_string_span<T, gsl::dynamic_extent> s) {}
+ void use(basic_string_span<T, gsl::dynamic_extent>) {}
TEST(MoveConstructors)
{