From 248a7cbdcef29f9b41ed569beb741cd292c76255 Mon Sep 17 00:00:00 2001 From: Herb Sutter Date: Fri, 18 Dec 2020 11:56:36 -0800 Subject: [PATCH] Add feature test for literal constructor in downlevel compilers --- include/gsl/assert | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/gsl/assert b/include/gsl/assert index 5488122..a57d55d 100644 --- a/include/gsl/assert +++ b/include/gsl/assert @@ -109,7 +109,11 @@ public: using handler = void (*)(); #endif +#if defined(__cpp_constexpr) && __cpp_constexpr >= 201806 constexpr contract_group (handler h) { set_handler(h); } +#else + constexpr contract_group (handler h) : chandler(h ? h : []()noexcept{}) { } +#endif constexpr auto set_handler(handler h) -> handler { return std::exchange(chandler, h ? h : []()noexcept{}); } constexpr auto get_handler() -> handler { return chandler; }