I'm trying to reproduce the example "3.1 Dimensional Analysis" from the book "C++ Template Metaprogramming" by Abrahams and Gurtovoy. At some moment, they compare that the "dimensions" of a value (of type mpl::vector_c
) is the same as the "dimensions" of a transformed value (mpl::transform
is applied to two mpl::vector_c
).
By me, the compare is always false
and I can't understand where I went wrong. The simplified example, without transformations:
#include <iostream>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/type_index.hpp>
using boost::typeindex::type_id_with_cvr;
using namespace boost;
using X1 = mpl::vector_c<int, 1, 2, 3>;
using X2 = mpl::vector<mpl::int_<1>, mpl::int_<2>, mpl::int_<3>>;
using CMP = mpl::equal<X1, X2>;
int main() {
std::cout << "X1: " << type_id_with_cvr<X1>().pretty_name() << std::endl;
std::cout << "X2: " << type_id_with_cvr<X2>().pretty_name() << std::endl;
std::cout << "CMP: " << type_id_with_cvr<CMP>().pretty_name() << std::endl;
std::cout << "CMP::type: " << type_id_with_cvr<CMP::type>().pretty_name() << std::endl;
std::cout << "CMP::type::value: " << CMP::type::value << std::endl;
}
From the output:
CMP: boost::mpl::equal<boost::mpl::vector_c<int, 1l, 2l, 3l, 21474
83647l, 2147483647l, 2147483647l, 2147483647l, 2147483647l, 214748
3647l, 2147483647l, 2147483647l, 2147483647l, 2147483647l, 2147483
647l, 2147483647l, 2147483647l, 2147483647l, 2147483647l, 21474836
47l, 2147483647l>, boost::mpl::vector<mpl_::int_<1>, mpl_::int_<2>
, mpl_::int_<3>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::
na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::is_s
ame<mpl_::arg<-1>, mpl_::arg<-1> > >
CMP::type: mpl_::bool_<false>
CMP::type::value: 0