Boost MPL documentation says boost :: map :: equal
"Returns the true integral constant if the two sequences Seq1 and Seq2 are identical when comparing _element_ by _element_.
but it seems that the associative sequence map is not checked for element _wise _ equality:
The following demo will show this: Map2 should equal Map3, which both increment the value of 'int_ <1>' value_type by 'key'. Take a look at the typedef defining Map3. The size and the only item is reset in the demo:
#include<iostream> #include<boost/mpl/map.hpp> #include<boost/mpl/at.hpp> #include<boost/mpl/insert.hpp> #include<boost/mpl/erase_key.hpp> #include<boost/mpl/pair.hpp> #include<boost/mpl/int.hpp> #include<boost/mpl/plus.hpp> #include<boost/mpl/equal.hpp> #include<boost/mpl/size.hpp> #include<boost/mpl/front.hpp> namespace mpl = boost::mpl; using mpl::int_; using std::cout; using std::endl; using std::is_same; int main(int argc, char *argv[]) { typedef int key; typedef typename mpl::map<mpl::pair<key, int_<1>>> Map; typedef typename mpl::map<mpl::pair<key, int_<2>>> Map2; typedef typename mpl::insert< typename mpl::erase_key<Map, key>::type, mpl::pair<key, typename mpl::plus<int_<1>, typename mpl::at<Map, key>::type>::type >::type >::type Map3; cout << "equal? " << mpl::equal<Map2,Map3>::type::value << endl; cout << "size? " << mpl::size<Map3>::value << endl; cout << "key type at front? " << typeid(mpl::front<Map3>::type::first).name() << endl; cout << "value type at front? " << mpl::front<Map3>::type::second::value << endl; cout << "expected size? " << mpl::size<Map2>::value << endl; cout << "expected key type at front? " << typeid(mpl::front<Map2>::type::first).name() << endl; cout << "expected value type at front? " << mpl::front<Map2>::type::second::value << endl; return 0; }
I am using gcc 4.8.1 with boost 1.51
source share