Friday 15 June 2012

c++ - Optional Parameters in VS2010 templitized class function -


I have a strange gesture in MSVS 2010. I have a class with a function that is templitized and the default value for a parameter.

In my header file:

  typed unfilled int data 32 square myClass {Private: ... public: ... template & lt; Typename T & gt; T * Mif (Data 32); } ... template & lt; Typename T & gt; T * myClass :: myF (data32 size = 1) {...}   

OK, now I have something like this in my head:

  Int main () {myClass A; Data32 * myInt = A.myF & lt; Data 32 & gt; (100); // No complain with pre-compiler data 32 * myInt2 = A.myF & lt; Data32 & gt; (); // pre-compiler complains "error: any example of the function template matches" myClass :: myF "logic list"}   

I understand why it is unhappy Because I do not have the function prototype defined for 'myF ()', but it should not be better known? I thought the points of defaults were to make the parameters optional in the call. Even after compiling the code and running ok, it felt that the precompiler is unhappy and it flagged as a problem.

Any ideas ?? Thanks!

"post-text" itemprop = "text">

The intelligence analyst in VS 2010 has bugs (false alarm). And it seems like one of them. The analyzer used for intellisance differs from the actual parser used in the compiler.

No comments:

Post a Comment