From 068d3db664e173fac4cf91e9148b41dc5062b3c9 Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Mon, 3 Sep 2018 12:10:22 +0100 Subject: [PATCH] Workaround libcxx issue --- tl/optional.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tl/optional.hpp b/tl/optional.hpp index 53c5de0..a2b27bc 100644 --- a/tl/optional.hpp +++ b/tl/optional.hpp @@ -139,9 +139,35 @@ template struct conjunction : std::conditional, B>::type {}; +// In C++11 mode, there's an issue in libc++'s std::mem_fn +// which results in a hard-error when using it in a noexcept expression +// in some cases. This is a check to workaround the common failing case. +#ifdef TL_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND +template struct is_pointer_to_non_const_member_func : std::false_type{}; +template +struct is_pointer_to_non_const_member_func : std::true_type{}; +template +struct is_pointer_to_non_const_member_func : std::true_type{}; +template +struct is_pointer_to_non_const_member_func : std::true_type{}; +template +struct is_pointer_to_non_const_member_func : std::true_type{}; +template +struct is_pointer_to_non_const_member_func : std::true_type{}; +template +struct is_pointer_to_non_const_member_func : std::true_type{}; + +template struct is_ref_to_const : std::false_type{}; +template struct is_ref_to_const : std::true_type{}; +#endif + // std::invoke from C++17 // https://stackoverflow.com/questions/38288042/c11-14-invoke-workaround template ::value + && is_ref_to_const::value)>, +#endif typename = enable_if_t>{}>, int = 0> constexpr auto invoke(Fn &&f, Args &&... args) noexcept(