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_implboost::__mpl::non_sequence_tag«
This suggest mpl::pair's are not MPL sequences :(
ah thanks, now I can interpret this (probably RTFM)
Try using mpl::vector2 instead of mpl::pair? Or patch Boost.MPL to make
mpl::pair's be MPL sequences?
here my 2nd try:
---8<---
#include
#include
#include
#include
#include <iostream>
namespace mpl = boost::mpl;
struct code {
enum type {
undefined, foo, bar
};
};
typedef mpl::vector, mpl::size_t<0> >, // undefined
mpl::vector< mpl::size_t<1>, mpl::size_t<3> >, // foo
mpl::vector< mpl::size_t<2>, mpl::size_t<5> > // bar
arity_info;
template
struct arity
: mpl::at_c::type
{ };
template
struct min_arity
: mpl::at_c<
typename arity<code>::type, 0
>::type
{ };
template
struct max_arity
: mpl::at_c<
typename arity<code>::type, 1
>::type
{ };
int main()
{
std::cout << "min aritycode::foo = "
<< min_aritycode::foo::value << '\n';
std::cout << "max aritycode::foo = "
<< max_aritycode::foo::value << '\n';
std::cout << "min aritycode::bar = "
<< min_aritycode::bar::value << '\n';
std::cout << "max aritycode::bar = "
<< max_aritycode::bar::value << '\n';
}
--->8---
where the output is:
min aritycode::foo = 0
max aritycode::foo = 0
min aritycode::bar = 1
max aritycode::bar = 3
the code is shifted about 1, why? Expected is
min aritycode::foo = 1
max aritycode::foo = 3
min aritycode::bar = 2
max aritycode::bar = 5
Thanks,
Olaf