|
Boost : |
Subject: Re: [boost] [review][mp11] Reminder of ongoing formal review
From: Roberto Hinz (robhz786_at_[hidden])
Date: 2017-07-23 02:39:20
Hi,
not a review yet.
I´m just wondering: would the implementation below perfom better than the
recursive version of mp_find_impl ?
I think it should perform better when one uses mp_find several times in the
same list.
It also compiles in vs2013.
template <class ... T> struct mp_find_impl_helper;
template <> struct mp_find_impl_helper<>
{
struct tag {};
static mp_size_t<0> get(const tag&, ...);
};
template <class T, class ... Rest>
struct mp_find_impl_helper<T, Rest...> : mp_find_impl_helper<Rest...>
{
using mp_find_impl_helper<Rest...>::get;
using parent_tag = typename mp_find_impl_helper<Rest...>::tag;
struct tag : parent_tag {};
static mp_size_t<1 + sizeof...(Rest)> get(const tag&, mp_identity<T>);
};
template<class L, class V> struct mp_find_impl;
template <template <class ...> class L, class ... T, class V>
struct mp_find_impl<L<T...>, V>
{
using helper = mp_find_impl_helper<T...>;
using tag = typename helper::tag;
using R = decltype(helper::get(tag(), mp_identity<V>()));
using type = mp_size_t<sizeof...(T) - R::value>;
};
// Regargs
// robhz
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk