Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 "Create impl" from template specialization

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
peterchen Posted - Jan 29 2019 : 06:27:44 AM
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! :)
3   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Feb 05 2019 : 08:41:07 AM
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
peterchen Posted - Jan 29 2019 : 10:49:00 AM
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

feline Posted - Jan 29 2019 : 08:04:28 AM
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.

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