diff --git a/src/sled/exec/detail/invoke_result.h b/src/sled/exec/detail/invoke_result.h index 32f7018..bede55d 100644 --- a/src/sled/exec/detail/invoke_result.h +++ b/src/sled/exec/detail/invoke_result.h @@ -18,162 +18,172 @@ namespace detail { #define EGGS_FWD(...) static_cast(__VA_ARGS__) /////////////////////////////////////////////////////////////////////////// -template::value> +template ::value> struct invoke_mem_ptr; // when `pm` is a pointer to member of a class `C` and // `is_base_of_v>` is `true`; -template -struct invoke_mem_ptr { - T C::*pm; +template +struct invoke_mem_ptr { + T C::*pm; #if !__cpp_aggregate_paren_init - constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} + constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} #endif - template - constexpr auto operator()(T1 &&t1) const noexcept(noexcept(EGGS_FWD(t1).*pm)) -> decltype(EGGS_FWD(t1).*pm) - { - return EGGS_FWD(t1).*pm; - } + template + constexpr auto operator()(T1 &&t1) const + noexcept(noexcept(EGGS_FWD(t1).*pm)) -> decltype(EGGS_FWD(t1).*pm) { + return EGGS_FWD(t1).*pm; + } }; -template -struct invoke_mem_ptr { - T C::*pm; +template +struct invoke_mem_ptr { + T C::*pm; #if !__cpp_aggregate_paren_init - constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} + constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} #endif - template - constexpr auto operator()(T1 &&t1, Tn &&...tn) const noexcept(noexcept((EGGS_FWD(t1).*pm)(EGGS_FWD(tn)...))) - -> decltype((EGGS_FWD(t1).*pm)(EGGS_FWD(tn)...)) - { - return (EGGS_FWD(t1).*pm)(EGGS_FWD(tn)...); - } + template + constexpr auto operator()(T1 &&t1, Tn &&...tn) const + noexcept(noexcept((EGGS_FWD(t1).*pm)(EGGS_FWD(tn)...))) + -> decltype((EGGS_FWD(t1).*pm)(EGGS_FWD(tn)...)) { + return (EGGS_FWD(t1).*pm)(EGGS_FWD(tn)...); + } }; // when `pm` is a pointer to member of a class `C` and // `remove_cvref_t` is a specialization of `reference_wrapper`; -template -struct invoke_mem_ptr { - T C::*pm; +template +struct invoke_mem_ptr { + T C::*pm; #if !__cpp_aggregate_paren_init - constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} + constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} #endif - template - constexpr auto operator()(T1 &&t1) const noexcept(noexcept(t1.get().*pm)) -> decltype(t1.get().*pm) - { - return t1.get().*pm; - } + template + constexpr auto operator()(T1 &&t1) const + noexcept(noexcept(t1.get().*pm)) -> decltype(t1.get().*pm) { + return t1.get().*pm; + } }; -template -struct invoke_mem_ptr { - T C::*pm; +template +struct invoke_mem_ptr { + T C::*pm; #if !__cpp_aggregate_paren_init - constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} + constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} #endif - template - constexpr auto operator()(T1 &&t1, Tn &&...tn) const noexcept(noexcept((t1.get().*pm)(EGGS_FWD(tn)...))) - -> decltype((t1.get().*pm)(EGGS_FWD(tn)...)) - { - return (t1.get().*pm)(EGGS_FWD(tn)...); - } + template + constexpr auto operator()(T1 &&t1, Tn &&...tn) const + noexcept(noexcept((t1.get().*pm)(EGGS_FWD(tn)...))) + -> decltype((t1.get().*pm)(EGGS_FWD(tn)...)) { + return (t1.get().*pm)(EGGS_FWD(tn)...); + } }; // when `pm` is a pointer to member of a class `C` and `T` does not // satisfy the previous two items; -template -struct invoke_mem_ptr { - T C::*pm; +template +struct invoke_mem_ptr { + T C::*pm; #if !__cpp_aggregate_paren_init - constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} + constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} #endif - template - constexpr auto operator()(T1 &&t1) const noexcept(noexcept((*EGGS_FWD(t1)).*pm)) -> decltype((*EGGS_FWD(t1)).*pm) - { - return (*EGGS_FWD(t1)).*pm; - } + template + constexpr auto operator()(T1 &&t1) const + noexcept(noexcept((*EGGS_FWD(t1)).*pm)) -> decltype((*EGGS_FWD(t1)).*pm) { + return (*EGGS_FWD(t1)).*pm; + } }; -template -struct invoke_mem_ptr { - T C::*pm; +template +struct invoke_mem_ptr { + T C::*pm; #if !__cpp_aggregate_paren_init - constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} + constexpr invoke_mem_ptr(T C::*pm) noexcept : pm(pm) {} #endif - template - constexpr auto operator()(T1 &&t1, Tn &&...tn) const noexcept(noexcept(((*EGGS_FWD(t1)).*pm)(EGGS_FWD(tn)...))) - -> decltype(((*EGGS_FWD(t1)).*pm)(EGGS_FWD(tn)...)) - { - return ((*EGGS_FWD(t1)).*pm)(EGGS_FWD(tn)...); - } + template + constexpr auto operator()(T1 &&t1, Tn &&...tn) const + noexcept(noexcept(((*EGGS_FWD(t1)).*pm)(EGGS_FWD(tn)...))) + -> decltype(((*EGGS_FWD(t1)).*pm)(EGGS_FWD(tn)...)) { + return ((*EGGS_FWD(t1)).*pm)(EGGS_FWD(tn)...); + } }; /////////////////////////////////////////////////////////////////////////// -template -auto invoke(F &&, ...) -> F &&; +template auto invoke(F &&, ...) -> F &&; -template -auto invoke(T C::*, T1 const &, ...) -> invoke_mem_ptr::value, - /*RefWrapper=*/false>; +template +auto invoke(T C::*, T1 const &, + ...) -> invoke_mem_ptr::value, + /*RefWrapper=*/false>; -template -auto invoke(T C::*, std::reference_wrapper, ...) -> invoke_mem_ptr; +template +auto invoke(T C::*, std::reference_wrapper, + ...) -> invoke_mem_ptr; //! EGGS_INVOKE(F, ...) //! //! - _Returns_: `INVOKE(F __VA_OPT__(,) __VA_ARGS__)`. -#if __cplusplus > 201703L// C++20: P0306 -#define EGGS_INVOKE(F, ...) \ - (static_cast(F)(__VA_ARGS__)) +#if __cplusplus > 201703L // C++20: P0306 +#define EGGS_INVOKE(F, ...) \ + (static_cast(F)(__VA_ARGS__)) #elif _MSVC_TRADITIONAL -#define EGGS_INVOKE(F, ...) (static_cast(F)(__VA_ARGS__)) +#define EGGS_INVOKE(F, ...) \ + (static_cast(F)( \ + __VA_ARGS__)) #else -#define EGGS_INVOKE(F, ...) (static_cast(F)(__VA_ARGS__)) +#define EGGS_INVOKE(F, ...) \ + (static_cast(F)( \ + __VA_ARGS__)) #endif /////////////////////////////////////////////////////////////////////////// // `INVOKE(f, t1, t2, ..., tN)` implicitly converted to `R`. -template::type> +template ::type> struct invoke_r { private: - static R conversion(R) noexcept; + static R conversion(R) noexcept; public: - template - static constexpr auto - call(F &&f, Args &&...args) noexcept(noexcept(conversion(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...)))) - -> decltype(conversion(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...))) - { - return EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...); - } + template + static constexpr auto call(F &&f, Args &&...args) noexcept( + noexcept(conversion(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...)))) + -> decltype(conversion(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...))) { + return EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...); + } }; // `static_cast(INVOKE(f, t1, t2, ..., tN))` if `R` is _cv_ `void`. -template -struct invoke_r { - template - static constexpr auto call(F &&f, Args &&...args) noexcept(noexcept(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...))) - -> decltype(static_cast(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...))) - { - return static_cast(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...)); - } +template struct invoke_r { + template + static constexpr auto call(F &&f, Args &&...args) noexcept( + noexcept(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...))) + -> decltype(static_cast(EGGS_INVOKE(EGGS_FWD(f), + EGGS_FWD(args)...))) { + return static_cast(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...)); + } }; //! EGGS_INVOKE(R, F, ...) @@ -181,20 +191,21 @@ struct invoke_r { //! - _Returns_: `INVOKE(F __VA_OPT__(,) __VA_ARGS__)`. #define EGGS_INVOKE_R(R, ...) (::eggs::detail::invoke_r::call(__VA_ARGS__)) -}// namespace detail -}// namespace eggs +} // namespace detail +} // namespace eggs namespace eggs { /////////////////////////////////////////////////////////////////////////// namespace detail { -template -struct invoke_result_impl {}; +template struct invoke_result_impl {}; -template -struct invoke_result_impl(), std::declval()...))> { - using type = decltype(EGGS_INVOKE(std::declval(), std::declval()...)); +template +struct invoke_result_impl(), + std::declval()...))> { + using type = decltype(EGGS_INVOKE(std::declval(), std::declval()...)); }; -}// namespace detail +} // namespace detail //! template struct invoke_result; //! @@ -209,23 +220,25 @@ struct invoke_result_impl( //! - _Preconditions_: `Fn` and all types in the template parameter pack //! `ArgTypes` are complete types, _cv_ `void`, or arrays of unknown //! bound. -template +template struct invoke_result : detail::invoke_result_impl {}; //! template //! using invoke_result_t = typename invoke_result::type; -template +template using invoke_result_t = typename invoke_result::type; /////////////////////////////////////////////////////////////////////////// namespace detail { -template +template struct is_invocable_impl : std::false_type {}; -template -struct is_invocable_impl(), std::declval()...))> +template +struct is_invocable_impl(), + std::declval()...))> : std::true_type {}; -}// namespace detail +} // namespace detail //! template struct is_invocable; //! @@ -236,14 +249,15 @@ struct is_invocable_impl() //! - _Comments_: `Fn` and all types in the template parameter pack //! `ArgTypes` shall be complete types, _cv_ `void`, or arrays of //! unknown bound. -template -struct is_invocable : detail::is_invocable_impl::type {}; +template +struct is_invocable : detail::is_invocable_impl::type { +}; #if __cpp_variable_templates //! template // (C++14) //! inline constexpr bool is_invocable_v = //! eggs::is_invocable::value; -template +template #if __cpp_inline_variables inline #endif @@ -252,13 +266,15 @@ inline /////////////////////////////////////////////////////////////////////////// namespace detail { -template +template struct is_invocable_r_impl : std::false_type {}; -template -struct is_invocable_r_impl(), std::declval()...))> +template +struct is_invocable_r_impl(), + std::declval()...))> : std::true_type {}; -}// namespace detail +} // namespace detail //! template struct is_invocable_r; //! @@ -269,14 +285,15 @@ struct is_invocable_r_impl -struct is_invocable_r : detail::is_invocable_r_impl::type {}; +template +struct is_invocable_r + : detail::is_invocable_r_impl::type {}; #if __cpp_variable_templates //! template // (C++14) //! inline constexpr bool is_invocable_r_v = //! eggs::is_invocable_r::value; -template +template #if __cpp_inline_variables inline #endif @@ -285,13 +302,17 @@ inline /////////////////////////////////////////////////////////////////////////// namespace detail { -template +template struct is_nothrow_invocable_impl : std::false_type {}; -template -struct is_nothrow_invocable_impl(), std::declval()...))> - : std::integral_constant(), std::declval()...))> {}; -}// namespace detail +template +struct is_nothrow_invocable_impl(), std::declval()...))> + : std::integral_constant(), + std::declval()...))> {}; +} // namespace detail //! template struct is_nothrow_invocable; //! @@ -302,53 +323,60 @@ struct is_nothrow_invocable_impl -struct is_nothrow_invocable : detail::is_nothrow_invocable_impl::type {}; +template +struct is_nothrow_invocable + : detail::is_nothrow_invocable_impl::type {}; #if __cpp_variable_templates //! template // (C++14) //! inline constexpr bool is_nothrow_invocable_v = //! eggs::is_nothrow_invocable::value; -template +template #if __cpp_inline_variables inline #endif - constexpr bool is_nothrow_invocable_v = is_nothrow_invocable::value; + constexpr bool is_nothrow_invocable_v = + is_nothrow_invocable::value; #endif /////////////////////////////////////////////////////////////////////////// namespace detail { -template +template struct is_nothrow_invocable_r_impl : std::false_type {}; -template -struct is_nothrow_invocable_r_impl(), std::declval()...))> - : std::integral_constant(), std::declval()...))> {}; -}// namespace detail +template +struct is_nothrow_invocable_r_impl< + F(Ts...), R, + decltype((void)EGGS_INVOKE_R(R, std::declval(), std::declval()...))> + : std::integral_constant(), + std::declval()...))> {}; +} // namespace detail -//! template struct is_nothrow_invocable_r; +//! template struct +//! is_nothrow_invocable_r; //! //! - _Condition_: `eggs::is_invocable_r_v` is `true` -//! and the expression `INVOKE(std::declval(), std::declval()...)` -//! is known not to throw any exceptions. +//! and the expression `INVOKE(std::declval(), +//! std::declval()...)` is known not to throw any exceptions. //! //! - _Comments_: `Fn`, `R`, and all types in the template parameter pack //! `ArgTypes` shall be complete types, _cv_ `void`, or arrays of //! unknown bound. -template -struct is_nothrow_invocable_r : detail::is_nothrow_invocable_r_impl::type {}; +template +struct is_nothrow_invocable_r + : detail::is_nothrow_invocable_r_impl::type {}; #if __cpp_variable_templates //! template // (C++14) //! inline constexpr bool is_nothrow_invocable_r_v = //! eggs::is_nothrow_invocable_r::value; -template +template #if __cpp_inline_variables inline #endif - constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r::value; + constexpr bool is_nothrow_invocable_r_v = + is_nothrow_invocable_r::value; #endif /////////////////////////////////////////////////////////////////////////// @@ -360,12 +388,11 @@ inline //! //! - _Remarks_: This function shall not participate in overload resolution //! unless `eggs::is_invocable_v` is `true`. -template -constexpr auto -invoke(Fn &&f, ArgTypes &&...args) noexcept(noexcept(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...))) - -> decltype(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...)) -{ - return EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...); +template +constexpr auto invoke(Fn &&f, ArgTypes &&...args) noexcept( + noexcept(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...))) + -> decltype(EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...)) { + return EGGS_INVOKE(EGGS_FWD(f), EGGS_FWD(args)...); } /////////////////////////////////////////////////////////////////////////// @@ -377,15 +404,17 @@ invoke(Fn &&f, ArgTypes &&...args) noexcept(noexcept(EGGS_INVOKE(EGGS_FWD(f), EG //! //! - _Remarks_: This function shall not participate in overload resolution //! unless `eggs::is_invocable_r_v` is `true`. -template -constexpr auto -invoke_r(Fn &&f, ArgTypes &&...args) noexcept(noexcept(EGGS_INVOKE_R(R, EGGS_FWD(f), EGGS_FWD(args)...))) - -> decltype(EGGS_INVOKE_R(R, EGGS_FWD(f), EGGS_FWD(args)...)) -{ - return EGGS_INVOKE_R(R, EGGS_FWD(f), EGGS_FWD(args)...); +template +constexpr auto invoke_r(Fn &&f, ArgTypes &&...args) noexcept( + noexcept(EGGS_INVOKE_R(R, EGGS_FWD(f), EGGS_FWD(args)...))) + -> decltype(EGGS_INVOKE_R(R, EGGS_FWD(f), EGGS_FWD(args)...)) { + return EGGS_INVOKE_R(R, EGGS_FWD(f), EGGS_FWD(args)...); } #undef EGGS_FWD -}// namespace eggs +} // namespace eggs +namespace tile { +using namespace eggs; +} #endif /*EGGS_INVOKE_HPP*/