
On Thu, Apr 18, 2013 at 11:47 AM, Olaf Peter <ope-devel@gmx.de> wrote:
Hello,
in these code I try to unpack the 1stand 2nd element, but it doesn't compile (here, it complains about »apply« in »struct boost::mpl::at_impl<boost::**mpl::non_sequence_tag>«
This suggest mpl::pair's are not MPL sequences :( Is there a better way and how to get it to compile?
Try using mpl::vector2 instead of mpl::pair? Or patch Boost.MPL to make mpl::pair's be MPL sequences? Thanks,
Olaf
---8<--- #include <boost/mpl/vector.hpp> #include <boost/mpl/vector_c.hpp> #include <boost/mpl/max_element.hpp> #include <boost/mpl/pair.hpp> #include <boost/mpl/integral_c.hpp> #include <boost/mpl/size_t.hpp> #include <boost/mpl/placeholders.hpp> #include <boost/mpl/at.hpp>
#include <iostream>
namespace mpl = boost::mpl;
struct code { enum type { undefined, foo, bar }; };
typedef mpl::vector<std::size_t, // min max mpl::pair< mpl::size_t<0>, mpl::size_t<0> >, // undefined mpl::pair< mpl::size_t<1>, mpl::size_t<3> >, // foo mpl::pair< mpl::size_t<2>, mpl::size_t<5> > // bar
arity_info;
template <code::type code> struct min_arity : mpl::at_c< typename mpl::at_c<arity_info, code>::type, 0 >::type { };
// same for max_arity at index 1 (pair::second)
int main() { std::cout << "min arity = " << min_arity<code::bar>::value << '\n'; // std::cout << "max arity = " // << max_arity<code::bar>::value << '\n'; }
--->8--- ______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**users<http://lists.boost.org/mailman/listinfo.cgi/boost-users>