Re: [Boost-users] [preporcessor]Can we use BOOST_PP_SEQ_FOLD_LEFT on sequences with one element?
________________________________________ De: boost-users-bounces@lists.boost.org [boost-users-bounces@lists.boost.org] En nombre de vicente.botet [vicente.botet@wanadoo.fr] Enviado el: viernes, 11 de julio de 2008 10:56 Para: boost-users@lists.boost.org Asunto: Re: [Boost-users] [preporcessor]Can we use BOOST_PP_SEQ_FOLD_LEFT on sequences with one element? [...]
Thanks Joaquin,
the question now is how to treat sequences of size 1 separately from the general case. I have tried with BOOST_PP_IF, but it is no better. [...] #define XX_SEQ_TO_QNAME(S) BOOST_PP_IF(XX_SIZE_GREATER_THAN_1(S)\ , XX_SEQ_TO_QNAME_N(S) \ , XX_SEQ_TO_QNAME_1(S))
The problem lies in the invocation to BOOST_PP_IF: you're evaluating
both XX_SEQ_TO_QNAME_N(S) and XX_SEQ_TO_QNAME_1(S),
which is precisely what you're trying to avoid. This is akin to doing the
following in runtime C++:
int if_(bool c,int then_,int else_)
{
if(c)return then_;
else return else_;
}
int safe_div(int n,int d)
{
return if_(d!=0,n/d,0);
}
cout<
----- Original Message -----
From: "JOAQUIN M. LOPEZ MUÑOZ"
participants (2)
-
JOAQUIN M. LOPEZ MUÑOZ
-
vicente.botet