Enable usage of gsl::narrow with exceptions disabled (#640)v1.0.0
commitd846fe50a3f0bb7767c7e087a05f4be95f4da0ec
authorAnna Gringauze <annagrin@microsoft.com>
Thu, 15 Mar 2018 23:00:08 +0000 (15 16:00 -0700)
committerGitHub <noreply@github.com>
Thu, 15 Mar 2018 23:00:08 +0000 (15 16:00 -0700)
tree53a695dda67c9a5b034ad64c814baa8b3e2d434c
parentc6bf25a5f6463047a59df3cc5b6fd18c8766c6a8
Enable usage of gsl::narrow with exceptions disabled (#640)

* Enable usage of gsl::narrow with exceptions disabled

This solution uses the approach of boost::asio to enabling usage of the
library in environments where exception usage is either prohibited
or not feasible (due to code size constraints). A function template
gsl::throw_exception has been added, which in a normal environment just
throws the exception. However, when GSL_TERMINATE_ON_CONTRACT_VIOLATION
is defined the function is only declared by gsl and the definition of
this function template must be supplied by the library's user.

Closes: #468

Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
Addition:
- understand STL no exception macro
- use function static variable to set termination handler in kernel mode
- add compile-only tests for no-exception mode

* added termination tests and fixed bugs

* disabled warning C4577 for msvc 2015
include/gsl/gsl_assert
include/gsl/gsl_util
tests/CMakeLists.txt
tests/no_exception_ensure_tests.cpp [new file with mode: 0644]
tests/no_exception_throw_tests.cpp [new file with mode: 0644]