forked from microsoft/GSL
Merge branch 'master' into dev/neilmac/spec
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#define GSL_CONTRACTS_H
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
||||
//
|
||||
// There are three configuration options for this GSL implementation's behavior
|
||||
@@ -42,10 +43,6 @@
|
||||
// GSL.assert: assertions
|
||||
//
|
||||
|
||||
#if defined(GSL_THROW_ON_CONTRACT_VIOLATION)
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace gsl
|
||||
{
|
||||
struct fail_fast : public std::runtime_error
|
||||
@@ -54,6 +51,8 @@ struct fail_fast : public std::runtime_error
|
||||
};
|
||||
}
|
||||
|
||||
#if defined(GSL_THROW_ON_CONTRACT_VIOLATION)
|
||||
|
||||
#define Expects(cond) if (!(cond)) \
|
||||
throw gsl::fail_fast("GSL: Precondition failure at " __FILE__ ": " GSL_STRINGIFY(__LINE__));
|
||||
#define Ensures(cond) if (!(cond)) \
|
||||
|
||||
+5
-1
@@ -31,6 +31,9 @@
|
||||
#pragma push_macro("constexpr")
|
||||
#define constexpr
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4127) // conditional expression is constant
|
||||
|
||||
// MSVC 2013 workarounds
|
||||
#if _MSC_VER <= 1800
|
||||
// noexcept is not understood
|
||||
@@ -40,7 +43,6 @@
|
||||
// turn off some misguided warnings
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4351) // warns about newly introduced aggregate initializer behavior
|
||||
#pragma warning(disable: 4127) // conditional expression is constant
|
||||
|
||||
#endif // _MSC_VER <= 1800
|
||||
|
||||
@@ -132,6 +134,8 @@ constexpr typename Cont::value_type& at(Cont& cont, size_t index)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
#undef constexpr
|
||||
#pragma pop_macro("constexpr")
|
||||
|
||||
|
||||
+7
-1
@@ -31,10 +31,16 @@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
// turn off some warnings that are noisy about our Expects statements
|
||||
#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
|
||||
|
||||
+11
-1
@@ -31,6 +31,14 @@
|
||||
#pragma push_macro("constexpr")
|
||||
#define constexpr /* nothing */
|
||||
|
||||
#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
|
||||
|
||||
@@ -927,12 +935,14 @@ bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexc
|
||||
}
|
||||
#endif
|
||||
|
||||
// VS 2013 workarounds
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user