Choosing a variable size

Given a template function that has two incoming integral types to work with, I want to declare some variables for intermediate use. How do I easily make a typedef for the larger of the two? It doesn't need to be perfect. I'm just trying to avoid using a 64-bit integer when it isn't needed, since 32-bit targets will be penalized for that. TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

On 12 April 2010 16:07, John Dlugosz
Given a template function that has two incoming integral types to work with, I want to declare some variables for intermediate use. How do I easily make a typedef for the larger of the two?
It's indirect, but if you find the size of the larger, Boost.Integer will give you an integer of that size.

John Dlugosz wrote:
Given a template function that has two incoming integral types to work with, I want to declare some variables for intermediate use. How do I easily make a typedef for the larger of the two?
Something like this will do (untested!): typedef typename boost::mpl::if_c< sizeof( T1 ) >= sizeof( T2 ), T1, T2 >::type larger_type; HTH, Gevorg
participants (3)
-
Gevorg Voskanyan
-
John Dlugosz
-
Scott McMurray