diff options
author | Ed Tanous <edtanous@google.com> | 2023-06-27 19:52:58 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2023-06-30 18:37:38 +0300 |
commit | 1017ef80f690e1d4c0a7c9799a9a3e26551308df (patch) | |
tree | 37379d4f38cb914ad63b816b088ab1daa27a6eb4 /http | |
parent | f706551d13f2e01b7e81fc7113c91efd253f315e (diff) | |
download | bmcweb-1017ef80f690e1d4c0a7c9799a9a3e26551308df.tar.xz |
Remove FunctionTraits
This class is no longer really used or needed, and previously was
largely replaced with boost::callable_traits. This moves the last usage
of arg_t over to callable_traits.
Tested: Redfish service validator passes
This series of commits drops ~5 seconds from the bmcweb compile times in
my testing.
Change-Id: I2d0ac728d282e876232f5379f3bd6ff1ddede2ba
Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'http')
-rw-r--r-- | http/routing/dynamicrule.hpp | 36 | ||||
-rw-r--r-- | http/utility.hpp | 7 |
2 files changed, 6 insertions, 37 deletions
diff --git a/http/routing/dynamicrule.hpp b/http/routing/dynamicrule.hpp index 03452d8bb9..699fb2a08f 100644 --- a/http/routing/dynamicrule.hpp +++ b/http/routing/dynamicrule.hpp @@ -14,17 +14,15 @@ namespace crow { namespace detail { -namespace routing_handler_call_helper -{ template <typename Func, typename... ArgsWrapped> struct Wrapped +{}; + +template <typename Func, typename... ArgsWrapped> +struct Wrapped<Func, std::tuple<ArgsWrapped...>> { - template <typename... Args> - void set(Func f) - { - handler = std::move(f); - } + explicit Wrapped(Func f) : handler(std::move(f)) {} std::function<void(ArgsWrapped...)> handler; @@ -59,7 +57,6 @@ struct Wrapped } } }; -} // namespace routing_handler_call_helper } // namespace detail class DynamicRule : public BaseRule, public RuleParameterTraits<DynamicRule> @@ -86,28 +83,7 @@ class DynamicRule : public BaseRule, public RuleParameterTraits<DynamicRule> void operator()(Func f) { using boost::callable_traits::args_t; - constexpr size_t arity = std::tuple_size<args_t<Func>>::value; - constexpr auto is = std::make_integer_sequence<unsigned, arity>{}; - erasedHandler = wrap(std::move(f), is); - } - - // enable_if Arg1 == request && Arg2 == Response - // enable_if Arg1 == request && Arg2 != response - // enable_if Arg1 != request - - template <typename Func, unsigned... Indices> - std::function<void(const Request&, - const std::shared_ptr<bmcweb::AsyncResp>&, - const std::vector<std::string>&)> - wrap(Func f, std::integer_sequence<unsigned, Indices...> /*is*/) - { - using function_t = crow::utility::FunctionTraits<Func>; - - auto ret = detail::routing_handler_call_helper::Wrapped< - Func, typename function_t::template arg<Indices>...>(); - ret.template set<typename function_t::template arg<Indices>...>( - std::move(f)); - return ret; + erasedHandler = detail::Wrapped<Func, args_t<Func>>(std::move(f)); } private: diff --git a/http/utility.hpp b/http/utility.hpp index d64b9957bc..b35811a9c7 100644 --- a/http/utility.hpp +++ b/http/utility.hpp @@ -102,13 +102,6 @@ constexpr inline uint64_t getParameterTag(std::string_view url) return tagValue; } -template <typename T> -struct FunctionTraits -{ - template <size_t i> - using arg = std::tuple_element_t<i, boost::callable_traits::args_t<T>>; -}; - constexpr size_t numArgsFromTag(int tag) { size_t ret = 0; |