I wrote a template function to an integer quick log base 2. It works in my testing program, but when I pasted it in my main project, I found that I had a problem with the heading of the windows.h . The issue is that I get c ++ std :: numeric_limits & lt; T & gt; I am using function, which also includes the macro windows.h on the max () max , which is going to be a macro, not a namespace information And overrides my attempt to use the real C ++ function. Is there any way I can not do other than windows.h ? (Which is not really an option)
Here's my job:
// return x where x = log2 (n) template & lt; Typename T & gt; T Log 2i (TN) {Static Constt Infinity (Stade :: Numeric_Limit : (Maximum)); Tx = 0; If (n == 0) {return infinite infinite; } If (n> 1) {When (n>> = 1) {++ x; }} Return x; }
static const t infinity ((std :: numeric_limits & lt; T & gt;: max) ()); Will work: additional bracket blocks the macro extension.
No comments:
Post a Comment