Roberto Hinz wrote:
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.
It performs better across the board (for repeated finds). Would you be willing to submit a pull request that replaces the current mp_find_impl with this one, so that your authorship is preserved in the commit history?
template
struct mp_find_impl_helper; template <> struct mp_find_impl_helper<> { struct tag {}; static mp_size_t<0> get(const tag&, ...); };
template
struct mp_find_impl_helper : mp_find_impl_helper { using mp_find_impl_helper ::get; using parent_tag = typename mp_find_impl_helper
::tag; struct tag : parent_tag {};
static mp_size_t<1 + sizeof...(Rest)> get(const tag&, mp_identity<T>); };
template
struct mp_find_impl; template class L, class ... T, class V> struct mp_find_impl
, V> { using helper = mp_find_impl_helper ; using tag = typename helper::tag;
using R = decltype(helper::get(tag(), mp_identity<V>()));
using type = mp_size_t
; };