boost::mpl::plus changes type
It is a major annoyance that these arrithmetic operations return a different type than the input! I mean I input boost::mpl::long_ and I get a boost::mpl::integral_c Peter
AMDG On 04/09/2011 04:36 PM, Peter Foelsche wrote:
It is a major annoyance that these arrithmetic operations return a different type than the input! I mean I input boost::mpl::long_ and I get a boost::mpl::integral_c
It isn't really different. mpl::long_ is just a shortcut for integral_c. In Christ, Steven Watanabe
"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:4DA0FE31.7080401@providere-consulting.com...
AMDG
On 04/09/2011 04:36 PM, Peter Foelsche wrote:
It is a major annoyance that these arrithmetic operations return a different type than the input! I mean I input boost::mpl::long_ and I get a boost::mpl::integral_c
It isn't really different. mpl::long_ is just a shortcut for integral_c.
typename boost::mpl::at< typename boost::mpl::insert< boost::mpl::map<>, boost::mpl::pair< typename boost::mpl::plus< boost::mpl::long_<0>, boost::mpl::long_<1> >::type, boost::mpl::long_<0> >::type, boost::mpl::long_<1>
::type
I think this gives void_. In words (in case of I did something wrong): Insert a result from add into a map and then try to find it via at. It cannot be found anymore, as it is not a long_ but an integral_c now. Peter
AMDG On 04/09/2011 06:38 PM, Peter Foelsche wrote:
typename boost::mpl::at< typename boost::mpl::insert< boost::mpl::map<>, boost::mpl::pair< typename boost::mpl::plus< boost::mpl::long_<0>, boost::mpl::long_<1>
::type, boost::mpl::long_<0> ::type, boost::mpl::long_<1> ::type
I think this gives void_. In words (in case of I did something wrong): Insert a result from add into a map and then try to find it via at. It cannot be found anymore, as it is not a long_ but an integral_c now.
MPL in general gives no guarantee about the exact types that operations produce. In Christ, Steven Watanabe
"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:4DA10FAE.20202@providere-consulting.com...
MPL in general gives no guarantee about the exact types that operations produce.
Please don't treat me like a customer of a US cellphone company (grin). template<long I> struct long_ { static const long value = I; template<long J> struct create { typedef long_<J> type; }; }; template<typename T0, typename T1> struct plus { typedef typename T0::template create<T0::value + T1::value>::type type; };
On 10/04/11 04:22, Peter Foelsche wrote:
Please don't treat me like a customer of a US cellphone company (grin). I LOL'd
template<long I> struct long_ { static const long value = I;
template<long J> struct create { typedef long_<J> type; }; };
template<typename T0, typename T1> struct plus { typedef typename T0::template create<T0::value + T1::value>::type type; }; What about mpl::plus< mpl::char<1>, mpl::long<2> > ? you need to get the common type out of char and long then rebuild it. Currently we put it in an integral_c. Doing it as you wish require a small look-up to match Type -> mpl::Type.
Would you mind filling a ticket so I dont lose this ?
participants (3)
-
Joel Falcou
-
Peter Foelsche
-
Steven Watanabe