Merge pull request #113 from neilmacintosh/master

Improved macros used for non-compliant compilers. Fixes #82.
This commit is contained in:
Neil MacIntosh 2015-09-30 22:05:27 -07:00
commit b51098a83d
2 changed files with 262 additions and 204 deletions

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,34 @@
#include "string_view.h" // zstring, string_view, zstring_builder... #include "string_view.h" // zstring, string_view, zstring_builder...
#include <memory> #include <memory>
#ifdef _MSC_VER
// No MSVC does constexpr fully yet
#pragma push_macro("constexpr")
#define constexpr /* nothing */
// MSVC 2013 workarounds
#if _MSC_VER <= 1800
// noexcept is not understood
#ifndef GSL_THROWS_FOR_TESTING
#define noexcept /* nothing */
#endif
// turn off some misguided warnings
#pragma warning(push)
#pragma warning(disable: 4351) // warns about newly introduced aggregate initializer behavior
#endif // _MSC_VER <= 1800
#endif // _MSC_VER
// In order to test the library, we need it to throw exceptions that we can catch
#ifdef GSL_THROWS_FOR_TESTING
#define noexcept /* nothing */
#endif // GSL_THROWS_FOR_TESTING
namespace gsl namespace gsl
{ {
@ -356,4 +384,24 @@ template<class T> using maybe_null = maybe_null_ret<T>;
} // namespace gsl } // namespace gsl
#ifdef _MSC_VER
#undef constexpr
#pragma pop_macro("constexpr")
#if _MSC_VER <= 1800
#pragma warning(pop)
#ifndef GSL_THROWS_FOR_TESTING
#pragma undef noexcept
#endif // GSL_THROWS_FOR_TESTING
#endif // _MSC_VER <= 1800
#endif // _MSC_VER
#if defined(GSL_THROWS_FOR_TESTING)
#undef noexcept
#endif // GSL_THROWS_FOR_TESTING
#endif // GSL_GSL_H #endif // GSL_GSL_H