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
 VAX fails to parse recurring template
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

joostn
Junior Member

16 Posts

Posted - Mar 19 2015 :  04:08:00 AM  Show Profile  Reply with Quote
For background see:
http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern

template <class T>
class BBB
{
};

template <class T>
class AAA : public BBB<AAA<T> >
{
public:
  void DoSomething();
};

void test()
{
  AAA<double> d;
  d.DoSomething();
}


If I try to use Refactor - Rename to rename the DoSomething function, it fails to recognize the occurrence d.DoSomething() in the function test. In other words refactoring results in broken code.

Also clicking on d.DoSomething() does not display the function signature in the VAX Definition window.

If I remove the ': public BBB<AAA<T> >' inheritance, or if AAA is a non-templated class, things work fine, so it seems VAX is unable to parse this specific syntax.

I'm using this pattern in several places to easily define comparison operators (<, <=, != etc) similar to this:
http://www.boost.org/doc/libs/1_55_0b1/libs/utility/operators.htm

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Mar 19 2015 :  6:11:23 PM  Show Profile  Reply with Quote
You are right, this is clearly confusing our parser. To be fair, it is doing a fairly good job of confusing me too I have seen some other odd template code confuse us, but none of that looks quite like this. I have put a bug report in for this:

case=88595

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

cduncan
Starting Member

USA
1 Posts

Posted - Mar 16 2016 :  2:53:36 PM  Show Profile  Reply with Quote
VA Version: VA_X.dll file version 10.9.2086.0 built 2015.12.16
VS Versoin: Visual Studio 2012
OS: Windows 7

I have a similar case with difficulty parsing a CRTP.

Oddly enough, if I type out "ArrayDerived<32, int>::", the suggestion list does appear, and it shows both base_function and derived_function. The issue is that the suggestion list does not appear after typing out "thing." (to show functions on the instantiated object).

This issue also occurs on joostn's example. The below is just a more complex case that I run into frequently.

SAMPLE CODE:
------------------------------------


template<typename element_type, typename derived_type>
class IArray
{
public:
	const element_type &operator[](unsigned int element_index) const;
	element_type &operator[](unsigned int element_index);

	void i_array_function();
};

template<typename element_type, typename derived_type>
class ArrayBase : public IArray<element_type, derived_type>
{
public:
	void base_function();
};

template<int element_count, typename element_type>
struct ArrayDerived : public ArrayBase<element_type, ArrayDerived<element_count, element_type> >
{
public:
	void derived_function();
};

inline void test()
{
	// ArrayDerived<32, int>::    // suggestions work

	ArrayDerived<32, int> thing;
	thing.i_array_function();
	// thing.                     // suggestions don't work
}



Edited by - cduncan on Mar 16 2016 4:45:12 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Mar 16 2016 :  5:15:20 PM  Show Profile  Reply with Quote
Thank you for the example. No member listboxes is unhelpful, but makes sense given that both VA and the IDE is getting confused with this code. I have added this to the case, it will be helpful for testing purposes when we have a look at this.

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:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000