Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 C++20 Direct Aggregate Initialization

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
swinefeaster Posted - Nov 22 2021 : 5:37:49 PM
hey folks, are you going to support autocomplete/parsing for this soon? i use it a lot an visual assist completely drops the ball on this.

https://en.cppreference.com/w/cpp/language/aggregate_initialization

thanks
swine
5   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Dec 14 2021 : 09:33:54 AM
Sorry, that was about the only thing I didn't test.

It turns out that the indent changing depends on having:

VA Options -> Editor -> Convert dot to -> in C/C++

turned On. So you could try turning this Off, depending on which set of behaviours will be less irritating. Still a bug though:

case=147524

Once the format of the list initialization isn't right, you cannot use IDE formatting to fix it though.
swinefeaster Posted - Dec 10 2021 : 02:04:30 AM
really? i'm on vs 2022 and if i disable visual assist, typing the . doesn't unindent the current line. if i re-enable visual assist, as soon as i hit '.', i get thrown to column 0 and the formatted is all messed up...
feline Posted - Nov 24 2021 : 07:17:03 AM
For the formatting, VA does very little code formatting its self, instead calling the IDE formatting when required. This is because the IDE has an extensive, and growing, list of formatting options already, plus you can specify clang-format commands in addition.

Testing on a clean system, where VA has never been installed, I get exactly the same formatting problem. I am not seeing any sign of an IDE formatting option, or a clang-format option that would cover this case, so no obvious help there.

It would be easy to produce a regular expression find and replace to fix the indenting here, but it might pick up other code you don't want reformatted.

I have put a note onto case=146419 to suggest that the generated code is generated indented, but if you don't format the code as the IDE expects then you can end up fighting the IDE formatting settings.

So far no sign of the Alt-G problem, either in my own code or with your sample. I just added a simple struct to match the initialization, and tried removing the "foo.x = 5" line and restarting VS2022, to make sure VA had properly caught up.

Do you have a reproducible problem with Alt-G? It's possible the problem requires more context, or is triggered by something further up the file.
swinefeaster Posted - Nov 23 2021 : 12:37:31 PM
let's see, for starters, the alignment is really off. as soon as i type the period, it jumps to the first column.


void Test()
{
    DevicePoint foo
    {
.x = 5,
.y = 7,
    };

    foo.x = 5;
}


i'm also having problems with VAX.GotoImplementation (i have it mapped to Ctrl+D) on the .x for example. Initially, it got really confused and showed me a long list of unrelated symbols. Then, after I wrote the "foo.x = 5" line at the bottom and Ctrl+D'd on that x, which it found without issue, the other .x definition started working too...
feline Posted - Nov 23 2021 : 06:13:19 AM
The title says C++ 20, so I assume you are looking for help having the members listed in declaration order.

We are considering adding a refactoring command to generate a full initialization list, with each member listed in order. The problem with doing this is specifying some form of default value, so it will compile, or leaving the values blank so it won't compile.

But since you can do:

struct DataStorageCpp20
{
	std::string strName;
	short nCount;
	float fDensity;
	std::string strDescription;
	std::vector<std::string> vecNames;
};
void DesignatedInitializers()
{
	// all members can be set to empty / blank values
	DataStorageCpp20 initializeEmpty =
	{
		.strName = {},
		.nCount = {},
		.fDensity = {},
		.strDescription = {},
		.vecNames = {}
	};
}

this seems to solve the default value problem.

case=146419

would this help with what you are doing, or are you looking for something else?

What parsing problems are you seeing with this? Find References is working correctly for me in the above sample, and the slightly larger test case I put together when someone else asked about this C++ 20 feature.

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