32 #include <ableton/build_system/Warnings.hpp>
34 #include <boost/variant/apply_visitor.hpp>
44 struct is_boost_variant : std::is_base_of<
45 meta::unpack<boost::variant, variant_types_t<estd::decay_t<T> > >,
68 template <
typename VariantT,
typename ...FnTs>
69 auto match(VariantT& variant, FnTs&& ...fns)
71 detail::is_boost_variant<estd::decay_t<VariantT> >{},
73 detail::visitor_impl<FnTs...>,
74 variant_types_t<VariantT&> > >
76 auto visit = visitor_for<VariantT&>(std::forward<FnTs>(fns)...);
77 return boost::apply_visitor(visit, variant);
80 template <
typename VariantT,
typename ...FnTs>
81 auto match(
const VariantT& variant, FnTs&& ...fns)
83 detail::is_boost_variant<estd::decay_t<VariantT> >{},
85 detail::visitor_impl<FnTs...>,
86 variant_types_t<const VariantT&> > >
88 auto visit = visitor_for<const VariantT&>(std::forward<FnTs>(fns)...);
89 return boost::apply_visitor(visit, variant);
typename std::enable_if< X, T >::type enable_if_t
Similar to C++14 std::enable_if_t.
auto match(VariantT &variant, FnTs &&...fns) -> estd::enable_if_t< detail::is_boost_variant< estd::decay_t< VariantT > >
Destructure a boost::variant with a given set of functions.
C++ amazing templates and reusable implementations awesomeness.