Subject: [boost] [mpl] Error in map docs (or bug)
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2008-10-26 19:43:30
I think I've found an error in the MPL docs (In trunk and 1.35, and
presumably everything in between).
The documentation for mpl::map state that "count<m,k>::type" yields "The
number of elements with the key k in m", where in fact what it returns
is the number of elements *equal* to k in m. This is consistent with
the documentation of mpl::count. I suspect this is an error in the docs
rather than a bug, since there is also mpl::has_key, which serves the
purpose count claims to be serving (but isn't).
Consider this code:
using namespace boost::mpl;
BOOST_MPL_ASSERT((has_key<my_set, int >::type));
BOOST_MPL_ASSERT((count<my_set, int >::type));
BOOST_MPL_ASSERT((has_key<my_map, int >::type));
BOOST_MPL_ASSERT((count<my_map, int >::type));
BOOST_MPL_ASSERT((count<my_map, pair<int,int> >::type));
The fourth assertion fails. If the map docs were accurate then it would
be the fifth assertion that failed.
The same error is in the Associative Sequence docs, and perhaps other
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk