Markus Werle wrote:
Q3: (OT) Is there a mpl-equivalent to run-time case?
:-)
Aleksey and I have been discussing some shorthands for
if (c1) then t1 else if (c2) then t2 else if (c3) then t3 ... else if (c4) then t4
but that's not quite the same as a case statement.
A std::map equivalent would help here a lot. It should be possible to search within a typelist of std::pair
... Unfortunately I am still stumbling through the mpl source [getting mad about all those WORKAROUND_FOR(STUPID_COMPILER_VENDOR)] Could You please give me an idea how to search within such a typelist?
With the current CVS, you don't have to do it by yourself:
#include "boost/mpl/vector.hpp"
#include "boost/mpl/switch.hpp"
#include "boost/mpl/project1st.hpp"
#include "boost/mpl/pair.hpp"
#include "boost/mpl/always.hpp"
#include "boost/mpl/bool_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/type_traits/remove_reference.hpp"
#include "boost/type_traits/add_const.hpp"
#include "boost/type_traits/is_pointer.hpp"
#include "boost/type_traits/is_reference.hpp"
using namespace boost::mpl;
typedef vector<
pair< boost::is_pointer<_1>, _1 >
, pair< boost::is_reference<_1>, boost::remove_reference<_1> >
, pair< always