From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2006-04-01 16:18:24
Andy Little wrote:
> I'm interested to know in what situations the promotion_traits libarary is meant
> to be used? I looked at the standard and I see that it seems to follow that,
> but in practise the only similar situation of needing to know promotion rules in
> my own code was in choosing the type that the input types are to be converted to
> in some operation.
Are you talking about _usual arithmetic conversions_?
I like fine granular model. Since usual arithmetic conversions depend on
integral promotion, it's logical to implement integral_promotion fisrt.
BTW, LibrariesUnderConstruction has a reference to
types_promotion_traits developed by Aleksey Gurtovoy.
Is arithmetic_conversions_traits<> defined there what you need?
> I am surprised to see that input parameters unrelated to promotion are allowed
> to pass unchanged to the output.The example given is e.g
> Expression ---> Result
> floating_point_promotion<int const>::type ---> int const
> I would expect, rather, to have a compilation failure in case of an invalid
I prefer promote-if-possible because it follows a semantic in the
standard. For example, integral promotions can be applied when passing
an argument to printf-like function. If integral promotions can't be
applied to the argument, nothing happens.
If you want to check whether promotion has an effect you can write
is_same< T, promote<T>::type >::value.
-- Alexander Nasonov
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk