Commit Graph

10 Commits

Author SHA1 Message Date
Anna Gringauze
5cbde3008a
make terminate_handler __cdecl (#673) 2018-05-02 16:19:37 -07:00
Stephan Dollberg
9c5e21045d Make gsl::details::throw_exception not copy exception object (#667)
This fixes the build with clang 7 which introduces a new warning
`-Wreturn-std-move` which warns about needless copies when a move
operation is available (see https://reviews.llvm.org/rL329914).

We take the exception object by uref so we should throw the forwarded
version.
2018-04-24 18:35:12 -07:00
Anna Gringauze
d846fe50a3
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
2018-03-15 16:00:08 -07:00
Casey Carter
95da2fd337 Don't use clang's __builtin_assume as an optimizer hint (#608)
Fixes #607.

Drive-by: use '?:' to contextually convert to bool in the fallback definition of `GSL_ASSUME`
2018-02-11 12:16:39 -08:00
Tiago
0d33bf6794 Applied iwyu --comment to the code base (#588) 2017-11-28 07:13:49 -08:00
bjude
7e529a47c2 Remove #pragma once (#545) (#570)
Core Guidelines SF.8 recommends using portable include guards instead.
2017-11-14 08:38:16 -08:00
Tiago
ebe7ebfd85 Reformat files to follow clang-format style (#492)
Project files were not following the clang-format style. For people
using IDEs were clang-format is always run after a save this would
cause unwanted changes.

This commit only applies "clang-format -i" to files.
2017-04-20 07:51:37 -07:00
Casey Carter
d65660760b fail_fast should derive from logic_error (#480)
Fixes #298.
2017-04-03 11:09:47 -07:00
Casey Carter
16a6a41690 gsl_assert changes: (#452)
* GSL_LIKELY/_UNLIKELY always contextually convert their argument to bool.

* Add macro GSL_ASSUME(cond) to inform the optimizer that the predicate cond must hold.

* Reimplement Expects & Ensures as expressions for flexibility and correctness. (Think about "if (cond1) Expects(cond2); else goto fail;")

* Expects and Ensures GSL_ASSUME their predicate when GSL_UNENFORCED_ON_CONTRACT_VIOLATION is defined.
2017-03-20 09:30:14 -07:00
Casey Carter
4e8f95b418 Cleanup include structure, constexpr and noexcept compiler workarounds.
* Nest "gsl" directory inside a new "include" directory.

* Cleanup the _MSC_VER conditionals a bit; use constexpr on VS2017+.

* Don't #define noexcept on non-Microsoft implementations.

* Workaround VS2017 bug in multi_span. (Also implement == and != for static_bounds_dynamic_range_t because I'm an EoP semantic soundness snob.)

Fixes #441.
2017-02-07 15:59:37 -08:00