|
Boost Users : |
Subject: [Boost-users] Nested If in boost:mpl::if_
From: Leon Sit (wing1127aishi_at_[hidden])
Date: 2010-12-02 15:09:02
hi all
I am trying to use mpl to do some simple type computation that involves nest
if statements
The logic is somewhat like
if(T is Libor)
return LiborType
if(
or(
or(T = Euribor,
T = EURLibor),
is_base_of(T, Libor)
),
ConstrType2,
if(
or(is_base_of(T, Euribor),
is_base_of(T, EURLibor)),
ConstrType1,
ConstrType
)
)
When I first coded it and instantiate T with some derived class of
Libor, the final type is always a generic type. Few more testing shows
that the inner if_ in the code below
typedef typename
boost::mpl::if_
<
boost::is_same<InType, QuantLib::Libor>,
QuantLib::Libor,
boost::mpl::if_
<
boost::mpl::or_
<
boost::is_same<InType, QuantLib::Euribor>,
boost::is_same<InType, QuantLib::EURLibor>,
boost::is_base_of<QuantLib::Libor, InType>
>
ConstrType2,
boost::mpl::if_
<
boost::mpl::or_
<
boost::is_base_of<QuantLib::Euribor, InType>,
boost::is_base_of<QuantLib::EURLibor, InType>
>,
ConstrType1,
ConstrType
>
>
>::type Type;
does not reduce to ConstrType1/ConstrType2/ConstrType but the whole is
used as a type. So the final Type is just a type with 3 nested if_
class inside. I tried linearising the logic but this introduces other
problem. Is this a bug or a limitation of mpl::if_?
Thanks
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