Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 VAX fails to parse recurring template

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
joostn Posted - Mar 19 2015 : 04:08:00 AM
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
3   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Mar 16 2016 : 5:15:20 PM
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.
cduncan Posted - Mar 16 2016 : 2:53:36 PM
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
}


feline Posted - Mar 19 2015 : 6:11:23 PM
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

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000