22 #ifndef NDN_CXX_UTIL_OVERLOAD_HPP
23 #define NDN_CXX_UTIL_OVERLOAD_HPP
25 #include <boost/predef/compiler/gcc.h>
26 #include <boost/version.hpp>
29 #if (BOOST_VERSION >= 106100) && (!BOOST_COMP_GNUC || (BOOST_COMP_GNUC >= BOOST_VERSION_NUMBER(6,0,0)))
31 #include <boost/hana/functional/overload.hpp>
34 constexpr boost::hana::make_overload_t
overload{};
39 #include <type_traits>
62 template <
typename F,
typename ...G>
65 , overload_t<G...>::type
67 using type = overload_t;
68 using overload_t<F>::type::operator();
69 using overload_t<G...>::type::operator();
71 template <
typename F_,
typename ...G_>
72 constexpr
explicit overload_t(F_&& f, G_&& ...g)
73 : overload_t<F>::type(static_cast<F_&&>(f))
74 , overload_t<G...>::type(static_cast<G_&&>(g)...)
79 struct overload_t<F> {
using type = F; };
81 template <
typename R,
typename ...Args>
82 struct overload_t<R(*)(Args...)> {
83 using type = overload_t;
86 explicit constexpr overload_t(R (*fp)(Args...))
90 constexpr R operator()(Args ...args)
const
91 {
return fptr_(
static_cast<Args&&
>(args)...); }
94 struct make_overload_t {
95 template <
typename ...F,
96 typename Overload =
typename overload_t<
97 typename std::decay<F>::type...
100 constexpr Overload operator()(F&& ...f)
const {
101 return Overload(
static_cast<F&&
>(f)...);
constexpr detail::make_overload_t overload