Boost logo

Boost :

Subject: Re: [boost] [metal] Feature Complete - Request for Feedback
From: Bruno Dutra (brunocodutra_at_[hidden])
Date: 2017-02-21 13:11:17


> Personally, I found it better from both performance and code sanity sides
to extract types from mpl::vector to variadic sequence via partial template
specialization (with mpl::vectorN<Ts...> using boost PP) and then pass
variadic type sequence to whatever TMP library I'm using

You should be aware that this doesn't work in general, because MPL types
are unspecified and pattern matching them actually means relying on
implementation details. That is specially true for mpl::vector, which
returns a proxy type that in turn masks the contents of the original
vector whenever
mpl::insert or mpl::erase is used, in a way that cannot be pattern matched
like this. There is no portable way of transferring the contents of a MPL
sequence to a variadic type, except for using MPL's own algorithms. If you
check out the implementation of metal::from_mpl, you'll find that it relies
on mpl::fold to extract the contents of sequences into a metal::list.

This is by the way another advantage of Metal, since all of its types are
precisely defined and friendly to pattern matching.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk