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
 "Create impl" from template specialization
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peterchen
Tomato Guru

118 Posts

Posted - Jan 29 2019 :  06:27:44 AM  Show Profile  Reply with Quote
given a class template and a specialization,

template <typename T>
struct Tea
{
   void drink() {}
};


template<>
struct Tea<int>
{
   void drink();
};


"Create IMplementation" for a method of the specializatio ("drink" in the example) generates weird code:


Observed:

template<>
void Tea<int><>::drink()
{

}


Expected;

void Tea<int>::drink()
{

}


Insert position is weird (above the specialization in the example I tried).

Also consider that the specialization may be moved to the .cpp (but that's a very minor thing, and arguments could be made both ways)

Anyway, enjoy your day! :)

feline
Whole Tomato Software

United Kingdom
15905 Posts

Posted - Jan 29 2019 :  08:04:28 AM  Show Profile  Reply with Quote
The wrong code being generated is a known bug:

case=19782

I am not sure what you mean about the insert position being weird though. I am not seeing anything obviously odd about the insert position here when testing this example. Do you get the odd position if you test this in an otherwise empty .h file? I am wondering if somehow the other file content is a factor here.

As for putting the code into the cpp file, the current plan is to keep template code in the header files. Also remember that you can have part specialised templates, so they still need to be "created" when used.

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

peterchen
Tomato Guru

118 Posts

Posted - Jan 29 2019 :  10:49:00 AM  Show Profile  Reply with Quote
Hi, good to now that it's already known.

Insert position: Having above example in a .cpp, it gets transformed to


template <typename T>
struct Tea
{
   void drink() {}
};

template<>
void Tea<int><>::drink()
{

}

template<>
struct Tea<int>
{
   void drink();
};


Note that the declaration of the specialization comes after its declaration. Not much of a problem, but I thought I'd mention it.



VA_X.dll file version 10.9.2291.0 built 2018.09.21
DevEnv.exe version 15.9.28307.344 Professional
msenv.dll version 15.0.28307.329
Comctl32.dll version 6.10.17134.441
Windows 10 10.0 1803 Build 17134.441
12 processors (x86-64, WOW64)
Language info: 1252, 0x407

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15905 Posts

Posted - Feb 05 2019 :  08:41:07 AM  Show Profile  Reply with Quote
I see the problem with the insert position now, thank you for the clear description. I have put in a bug report for this:

case=136216

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