mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Make constructor more constinit
-friendly
This commit is contained in:
parent
c78ad8661c
commit
71fd73fa04
@ -109,12 +109,7 @@ public:
|
|||||||
using handler = void (*)();
|
using handler = void (*)();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201806
|
|
||||||
constexpr contract_group (handler h) { set_handler(h); }
|
|
||||||
#else // VESTIGIAL, remove when no longer needed for downlevel compilers
|
|
||||||
constexpr contract_group (handler h) : chandler(h ? h : []()noexcept{}) { }
|
constexpr contract_group (handler h) : chandler(h ? h : []()noexcept{}) { }
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 202002L
|
#if __cplusplus >= 202002L
|
||||||
constexpr auto set_handler(handler h) -> handler { return std::exchange(chandler, h ? h : []()noexcept{}); }
|
constexpr auto set_handler(handler h) -> handler { return std::exchange(chandler, h ? h : []()noexcept{}); }
|
||||||
#else // VESTIGIAL, remove when no longer needed for downlevel compilers
|
#else // VESTIGIAL, remove when no longer needed for downlevel compilers
|
||||||
|
Loading…
Reference in New Issue
Block a user