Boost logo

Boost Users :

Subject: [Boost-users] [mpl] Discrepancy between documentation and code?
From: James Knight (james.nate.knight_at_[hidden])
Date: 2009-10-03 01:53:36


In looking at the documentation for the intrinsic metafunction mpl::at,
it seems to suggest that a three argument version that returns a default
type when a key is not found exists for associative sequences. I don't
see this implemented anywhere in the code, and the simple example below
doesn't compile. Am I missing something or is this an error in the
documentation? Thanks, Nate

#include <boost/mpl/map.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/pair.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/int.hpp>
#include <boost/type_traits/is_same.hpp>

using namespace boost::mpl;

int main() {
   typedef map< pair<int_<2>,int_<3> > > map_t;
   typedef at<map_t, int_<1>, int_<0> >::type missing;
   BOOST_MPL_ASSERT(( boost::is_same< missing, int_<0> > ));
}

With gcc 4.0.1 and Boost 1.37 on OS X I get

test.cpp: In function 'int main()':
test.cpp:12: error: wrong number of template arguments (3, should be 2)
../BoostInstall/boost_1_37_0/boost/mpl/at_fwd.hpp:20: error: provided
for 'template<class Sequence, class N> struct boost::mpl::at'
...


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