Boost logo

Boost Users :

From: Markus Werle (yg-boost-users_at_[hidden])
Date: 2003-02-24 06:47:21


Hi!

I am trying to migrate some parts of my code from
loki to boost::mpl.

Q1: which is the best way to perform nested if-then-else?

Assume given "values":
bool B1, bool B2;
class ff, class tf, class ft, class tt;

I replaced

-----------------------------------------------------------
  typedef typename
  Loki::Select<B1,
               typename Loki::Select<B2, tt, tf>::Result,
               typename Loki::Select<B2, ft, ff>::Result
>::Result type;
-----------------------------------------------------------

with

  typedef typename
  apply_if
  <
   bool_c<B1>,
    
   apply_if
   <
    bool_c<B2>,
    identity<tt>,
    identity<tf>
>,

   apply_if
   <
    bool_c<B2>,
    identity<ft>,
    identity<ff>
>
>::type type;

Q2: Is apply_if always to be preferred over if_?

Q3: (OT) Is there a mpl-equivalent to run-time case?

best regards,

Markus


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