C++ Get object type at compile time, e.g., numeric_limits<typeof<a>>::max()? -


given int a; , I know that returns the lowest value that can be a << Pre> numeric_limits & lt; Int & gt; :: max ()

However, I want to get this information without knowing that a is a int I want to do something like this:

 numeric_limits  & lt; Typeof & lt; A & gt; & Gt;  :: max () 
Not with this exact syntax, but is it possible that it is ISO C ++?


Thanks, all. Aurélien Vallée's type_of () comes closest, but I will not add anything extra to my codebase since we already use Boost, so in the context of Boeing Eric Malenfant To type me type me

 numeric_limit  & lt; BOOST_TYPEOF (m_focusspeed) & gt; : max () 

I have never used it again, thanks again for very well known reactions.

numeric_length, which is the type attribute This type of relative information is a contradiction Stores in a manner.

Regarding your question, you can define only a template function that will determine the type of variable for you.

  template & lt; Typename T & gt; T Value_max (Const T & V) {Return Numeric_limits & lt; T & gt; :: max (); }; Template & lt; Typename T & gt; T Valuer (Const T & V) {Return Numeric_limit's & lt; T & gt; :: min (); };  

Or just create a short form of return structure:

  template & lt; Typename T & gt; Structure typeof {type ft type; }; Template & lt; Typename T & gt; Typeof & LT; T & gt; Type_f (CONST T & V) {Return Type Off & lt; T & gt; (); } Int a; Numeric_limits & lt; Type_of (a): type & gt; :: Maximum ();  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -