Boost logo

Boost Users :

From: Aleksey Loginov (aleksey.loginov_at_[hidden])
Date: 2006-05-10 07:36:52


I got a trouble when used boost::mpl.

This code works for std::vector, but fail for std::map (gcc 3.4.2)

#include <boost/mpl/apply.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/type_traits/is_same.hpp>
#include <iostream>
#include <vector>
#include <map>
#include <utility>

namespace mpl=boost::mpl;

template<typename Pair>
struct first {
        typedef typename Pair::first_type type;
};

template<typename Pair>
struct second {
        typedef typename Pair::second_type type;
};

int main ()
{

        typedef mpl::lambda<
                std::vector< second< mpl::arg<1> > > > vector;

        std::cout << boost::is_same<
                mpl::apply<vector, std::pair<char,int> >::type,
                std::vector<int> >::value << std::endl;

        typedef mpl::lambda<
                std::map< first< mpl::arg<1> >, second< mpl::arg<1> > > > map;

        std::cout << boost::is_same<
                mpl::apply<map, std::pair<char,int> >::type,
                std::map<char,int> >::value << std::endl;

        return 0;
}

Simple tests show that problem in std::allocator< std::pair<const Key,Type> >
Looks like compiler bug, but may be it's my error.
Any thought's how avoid the problem?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net