Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Syntax errors C++: lambda's and variadic templates
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bta
Ketchup Master

Belgium
57 Posts

Posted - Jan 25 2016 :  05:19:33 AM  Show Profile  Reply with Quote
It seems that VAX cannot handle the variadic templates syntax, it always gives a syntax error.
Next to that sometimes it also has problems with lambda syntax.
(but not always though...)

See this code snippet for some examples.


#include <vector>
#include <memory>

namespace A
   {
   template <typename Arg>
   struct NotNull final
      {};

   template <typename TReturnType, typename... TArgs, typename FunctionType> // Syntax error on TArgs (variadic templates)
   std::unique_ptr<C1> foo(FunctionType function)
      {
      }
   }

namespace
   {
   class C1
      {};

   class C2
      {
      public:
         void f() {}
      };

   class C3
      {
      public:
         void bar()
            {
            auto lambda = [this](C2 &c2) -> std::vector<C1> { return{}; }; // Syntax error on std (or vector when std:: is removed)
                                                                           // no syntax error on c2

            A::foo<C1, A::NotNull<C2>>([this](C2 &c2) -> std::vector<C1> { return{}; }); // Syntax error on c2
                                                                                         // no syntax error on std
            }
      };
   }

feline
Whole Tomato Software

United Kingdom
17591 Posts

Posted - Jan 25 2016 :  6:58:34 PM  Show Profile  Reply with Quote
If you disable VA, via:

VAssistX -> Enable/Disable Visual Assist X

do you still see this underlining? I am seeing this underlining in VS2015 Update 1, even on a machine where VA has never been installed.

The more recent IDE's added C++ underlining, and when this is happening VA steps back and lets the IDE to the underlining, which is what is happening in this case.

zen is the art of being at one with the two'ness
Go to Top of Page

bta
Ketchup Master

Belgium
57 Posts

Posted - Jan 26 2016 :  03:10:04 AM  Show Profile  Reply with Quote
Feline,

no, I do not see this underlining when I disable VAX.
So I guess it is VAX that is providing this functionality?
I'm working with VS2013 Update 5:

VA_X.dll file version 10.9.2086.0 built 2015.12.16
DevEnv.exe version 12.0.40629.0 Professional
msenv.dll version 12.0.40629.0

Note that I have the IntelliSense turned off completely.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17591 Posts

Posted - Jan 29 2016 :  2:21:58 PM  Show Profile  Reply with Quote
Ah, my mistake, I did not think to check the effect of disabling the IDE intellisense, I am seeing the same problem here once I disable the IDE intellisense database:

case=94742

You are quite right, this is bug / limitation in our parser. If you have a lot of code like this have you considered turning the IDE intellisense database back on? Obviously you turned it off for a reason, so you will have to consider if the trade off is worth it.

zen is the art of being at one with the two'ness
Go to Top of Page

bta
Ketchup Master

Belgium
57 Posts

Posted - Feb 02 2016 :  03:06:43 AM  Show Profile  Reply with Quote
The reason for turning of the IDE intellisense (for several years now already) was that it was too slow and didn't even give us correct results for our project size (20.000+ cpp files, 25.000+ header files).
The results from VAX were way better.
So we decided on saving disk space/power consumption by disabling it completely.

I'll see if I can turn it on again and let you know if it helps...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17591 Posts

Posted - Feb 02 2016 :  7:09:16 PM  Show Profile  Reply with Quote
I am glad to hear that VA handled your solution so well, it is always good to hear about our successes

The IDE intellisense parser has improved with time, but you do risk running two parsers and using the extra hard drive space. Still, perhaps it will work better now for you.

zen is the art of being at one with the two'ness
Go to Top of Page

bta
Ketchup Master

Belgium
57 Posts

Posted - Feb 03 2016 :  03:21:50 AM  Show Profile  Reply with Quote
Some info:
I just upgraded to your new build (10.9.2089), but with this one the same syntax error indications are given.

I also tried enabling Intellisense and all mentioned syntax errors are gone.

To be honest, there was an other error mentioned by Intellisense on the call of A::foo() telling that it was ambiguous.
In fact the code sample in the first post didn't compile. The class C1 was not known at foo() function implementation.
The real sample should be:

#include <vector>
#include <memory>

namespace
   {
   class C1
      {};
   }

namespace A
   {
   template <typename Arg>
   struct NotNull final
      {};

   template <typename TReturnType, typename... TArgs, typename FunctionType> // Syntax error on TArgs (variadic templates)
   std::unique_ptr<C1> foo(FunctionType function)
      {
      return std::unique_ptr<C1>(nullptr);
      }
   }

namespace
   {
   class C2
      {
      public:
         void f()
            {
            }
      };

   class C3
      {
      public:
         void bar()
            {
            auto lambda = [this](C2 &c2) -> std::vector<C1> { return{}; }; // Syntax error on std (or vector when std:: is removed)
            // no syntax error on c2

            A::foo<C1, A::NotNull<C2>>([this](C2 &c2) -> std::vector<C1> { return{}; }); // Syntax error on c2
            // no syntax error on std
            }
      };
   }



We'll still need to further validate the option of re-enabling the intellisense.
However, still hoping we can use VAX alone!
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17591 Posts

Posted - Feb 03 2016 :  10:43:41 PM  Show Profile  Reply with Quote
VS2013 is doing something odd with this code.

Testing on a clean machine, there is no Visual Assist installed, and I get different underlining from the IDE depending on which file I paste the code into, but it always compiles. So no underlining on your system is helpful.

We are hoping to look at this bug fairly soon, but unfortunately I don't yet have an estimate for when this might be fixed. This thread should be updated when this has been fixed though.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2021 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000