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>
diff --git a/http/routing/dynamicrule.hpp b/http/routing/dynamicrule.hpp
index 03452d8..699fb2a 100644
--- a/http/routing/dynamicrule.hpp
+++ b/http/routing/dynamicrule.hpp
@@ -14,17 +14,15 @@
{
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 @@
}
}
};
-} // namespace routing_handler_call_helper
} // namespace detail
class DynamicRule : public BaseRule, public RuleParameterTraits<DynamicRule>
@@ -86,28 +83,7 @@
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 d64b995..b35811a 100644
--- a/http/utility.hpp
+++ b/http/utility.hpp
@@ -102,13 +102,6 @@
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;