
2011/10/21 John Maddock <boost.regex@virgin.net>
template <class R, class T> R round_to(const T&);
template <class R, class T> R trunc_to(const T&);
which would provide generic versions of iround/itrunc (although R need not be an integer type, as long as there's a static_cast from T to R).
I'm not particularly sold on those names though, I guess "round_cast/trunc_cast" would be an alternative.
John.
Personally, I prefer names "round_cast/trunc_cast", as they better describe what's being done. I already use a function "round_to", that does something else: template < class T > T round_to( const T& x, const T& order ) { return round( x / order ) * order; // By the way, can this be achieved more efficiently? } I'm not sure if "round_to" is the best name for this, but I think it is not the right name for "round_cast" ;-) Regards, Kris