
I don't remember the following being suggested:
Yep it's a possibility. It's close to my last attempt, using the MPL: template <int N> struct even_positive_power { template <typename T> static typename tools::promote_args<T>::type result(T base) { return positive_power<2>::result( positive_power<N/2>::result(base)); } }; template <int N> struct odd_positive_power { template <typename T> static typename tools::promote_args<T>::type result(T base) { return base*positive_power<2>::result( positive_power<N/2>::result(base)); } }; template <int N> struct positive_power { template <typename T> static typename tools::promote_args<T>::type result(T base) { return mpl::if_< mpl::greater_equal<mpl::int_<N%2>, mpl::int_<1> >, odd_positive_power<N>, even_positive_power<N> >::type::result(base); } }; BTW, I have a question about the MPL. I would have preferred to write "equal<int_<N%2>, int_<0> >" followed by even_ then odd_ but it doesn't work. I'm apparently missing something in the use of mpl::equal. Could someone explain me why: mpl::equal<mpl::int_<1>, mpl::int_<0> >::type::value equals to 1?? Thanks Bruno