[mpl] defaults with associative sequence

Hi, Maybe I am misreading the documentation, but if I have an mpl::map and try and get an element associated with a key all's good, while if I assign a default - I get an error that mpl::at only takes 2 and not 3 template parameters. Simple example for sake of completness: using namespace boost::mpl; typedef map< pair<int, int_<0> > , pair<float, int_<1> > > m; at<m, float>::type::value; // Ok at<m, double, int_<2> >::type::value; // compiler error Indeed a look in boost/mpl/at.hpp even leads me to believe that mpl::at only takes two template parameters (maybe I mistaken), but documentation suggests otherwise. [Compiler: GCC-4.4.2 ; Boost-1.42] Am I doing something blatantly wrong? Cheers, -- Manfred

El 05/03/2010 06:31 a.m., Manfred Doudar escribió:
Hi,
Maybe I am misreading the documentation, but if I have an mpl::map and try and get an element associated with a key all's good, while if I assign a default - I get an error that mpl::at only takes 2 and not 3 template parameters.
Am I doing something blatantly wrong?
No. The mpl::at version that takes a default parameter does not exist. Documentation and source code are out of synch. When I need it I use this implementation: typename boost::mpl::eval_if< typename boost::mpl::has_key< Map, Key >::type , boost::mpl::at< Map, Key > , boost::mpl::identity< Default >
::type
Agustín K-ballo Bergé.- http://talesofcpp.blogspot.com

On Fri, 05 Mar 2010 14:38:15 -0300 Agustín K-ballo Bergé <kaballo86@hotmail.com> wrote:
El 05/03/2010 06:31 a.m., Manfred Doudar escribió:
Hi,
Maybe I am misreading the documentation, but if I have an mpl::map and try and get an element associated with a key all's good, while if I assign a default - I get an error that mpl::at only takes 2 and not 3 template parameters.
Am I doing something blatantly wrong?
No. The mpl::at version that takes a default parameter does not exist. Documentation and source code are out of synch. When I need it I use this implementation:
typename boost::mpl::eval_if< typename boost::mpl::has_key< Map, Key >::type , boost::mpl::at< Map, Key > , boost::mpl::identity< Default >
::type
Agustín K-ballo Bergé.
Thank you Agustín for your reply, it's appreciated. --Manfred
participants (2)
-
Agustín K-ballo Bergé
-
Manfred Doudar