From 972138794e8b50fcf9df81735dcfed67187723e5 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Thu, 10 Dec 2020 02:04:01 +0700 Subject: [PATCH] remove unnecessary macros from core --- headers/kari.hpp/kari.hpp | 166 ++++++++++++++------------------------ 1 file changed, 62 insertions(+), 104 deletions(-) diff --git a/headers/kari.hpp/kari.hpp b/headers/kari.hpp/kari.hpp index d93c3b4..eaaf5c4 100644 --- a/headers/kari.hpp/kari.hpp +++ b/headers/kari.hpp/kari.hpp @@ -12,12 +12,6 @@ #include #include -#define KARI_HPP_NOEXCEPT_RETURN(...) \ - noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; } - -#define KARI_HPP_NOEXCEPT_DECLTYPE_RETURN(...) \ - noexcept(noexcept(__VA_ARGS__)) -> decltype (__VA_ARGS__) { return __VA_ARGS__; } - namespace kari_hpp { template < std::size_t N, typename F, typename... Args > @@ -25,38 +19,26 @@ namespace kari_hpp namespace detail { - template - < - std::size_t N, typename F, typename... Args, - typename std::enable_if_t< - (N == 0) && - std::is_invocable_v, Args...> - , int> = 0 - > - constexpr auto make_curry(F&& f, std::tuple&& args) - KARI_HPP_NOEXCEPT_RETURN( - std::apply(std::forward(f), std::move(args))) + template < std::size_t N, typename F, typename... Args + , std::enable_if_t< + (N == 0) && + std::is_invocable_v, Args...>, int> = 0 > + constexpr auto make_curry(F&& f, std::tuple&& args) { + return std::apply(std::forward(f), std::move(args)); + } - template - < - std::size_t N, typename F, typename... Args, - typename std::enable_if_t< - (N > 0) || - !std::is_invocable_v, Args...> - , int> = 0 - > - constexpr auto make_curry(F&& f, std::tuple&& args) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - curry_t< - N, - std::decay_t, - Args... - >(std::forward(f), std::move(args))) + template < std::size_t N, typename F, typename... Args + , std::enable_if_t< + (N > 0) || + !std::is_invocable_v, Args...>, int> = 0 > + constexpr auto make_curry(F&& f, std::tuple&& args) { + return curry_t, Args...>(std::forward(f), std::move(args)); + } template < std::size_t N, typename F > - constexpr auto make_curry(F&& f) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - make_curry(std::forward(f), std::make_tuple())) + constexpr auto make_curry(F&& f) { + return make_curry(std::forward(f), std::make_tuple()); + } } template < std::size_t N, typename F, typename... Args > @@ -166,91 +148,67 @@ namespace kari_hpp // curry // - template - < - typename F, - typename std::enable_if_t>, int> = 0 - > - constexpr auto curry(F&& f) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - std::forward(f)) + template < typename F + , std::enable_if_t>, int> = 0 > + constexpr auto curry(F&& f) { + return std::forward(f); + } - template - < - typename F, - typename std::enable_if_t>, int> = 0 - > - constexpr auto curry(F&& f) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - detail::make_curry<0>(std::forward(f))) + template < typename F + , std::enable_if_t>, int> = 0 > + constexpr auto curry(F&& f) { + return detail::make_curry<0>(std::forward(f)); + } template < typename F, typename A, typename... As > - constexpr auto curry(F&& f, A&& a, As&&... as) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - curry(std::forward(f))(std::forward(a), std::forward(as)...)) + constexpr auto curry(F&& f, A&& a, As&&... as) { + return curry(std::forward(f))(std::forward(a), std::forward(as)...); + } // // curryV // - template - < - typename F, - std::size_t MaxN = std::numeric_limits::max(), - typename std::enable_if_t>, int> = 0 - > - constexpr auto curryV(F&& f) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - std::forward(f).template recurry()) + template < typename F + , std::size_t MaxN = std::numeric_limits::max() + , std::enable_if_t>, int> = 0 > + constexpr auto curryV(F&& f) { + return std::forward(f).template recurry(); + } - template - < - typename F, - std::size_t MaxN = std::numeric_limits::max(), - typename std::enable_if_t>, int> = 0 - > - constexpr auto curryV(F&& f) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - detail::make_curry(std::forward(f))) + template < typename F + , std::size_t MaxN = std::numeric_limits::max() + , std::enable_if_t>, int> = 0 > + constexpr auto curryV(F&& f) { + return detail::make_curry(std::forward(f)); + } template < typename F, typename A, typename... As > - constexpr auto curryV(F&& f, A&& a, As&&... as) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - curryV(std::forward(f))(std::forward(a), std::forward(as)...)) + constexpr auto curryV(F&& f, A&& a, As&&... as) { + return curryV(std::forward(f))(std::forward(a), std::forward(as)...); + } // // curryN // - template - < - std::size_t N, typename F, - typename std::enable_if_t>, int> = 0 - > - constexpr auto curryN(F&& f) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - std::forward(f).template recurry()) + template < std::size_t N, typename F + , std::enable_if_t>, int> = 0 > + constexpr auto curryN(F&& f) { + return std::forward(f).template recurry(); + } - template - < - std::size_t N, typename F, - typename std::enable_if_t>, int> = 0 - > - constexpr auto curryN(F&& f) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - detail::make_curry(std::forward(f))) + template < std::size_t N, typename F + , std::enable_if_t>, int> = 0 > + constexpr auto curryN(F&& f) { + return detail::make_curry(std::forward(f)); + } - template - < - std::size_t N, typename F, typename A, typename... As, - std::size_t Args = sizeof...(As) + 1, - std::size_t MaxN = std::numeric_limits::max(), - typename std::enable_if_t<(MaxN - Args >= N), int> = 0 - > - constexpr auto curryN(F&& f, A&& a, As&&... as) - KARI_HPP_NOEXCEPT_DECLTYPE_RETURN( - curryN(std::forward(f))(std::forward(a), std::forward(as)...)) + template < std::size_t N, typename F, typename A, typename... As + , std::size_t Args = sizeof...(As) + 1 + , std::size_t MaxN = std::numeric_limits::max() + , std::enable_if_t<(MaxN - Args >= N), int> = 0 > + constexpr auto curryN(F&& f, A&& a, As&&... as) { + return curryN(std::forward(f))(std::forward(a), std::forward(as)...); + } } - -#undef KARI_HPP_NOEXCEPT_RETURN -#undef KARI_HPP_NOEXCEPT_DECLTYPE_RETURN