Author Topic: push-tag on "auto" keyword should go to the definition of the type in C++  (Read 5053 times)

rowbearto

  • Senior Community Member
  • Posts: 2336
  • Hero Points: 132
When I have something in C++ like:

auto variable = &(myIterator->second);

And I perform a "push-tag" on "auto", I would like to go to the definition of the type that "variable" will be.

Dennis

  • Senior Community Member
  • Posts: 3992
  • Hero Points: 520
This is a good idea.  I will file a feature request to that effect.  It will need to be a do-nothing if the type evaluates to a built-in (well, actually, probably should show the built-in type on the message line).

rowbearto

  • Senior Community Member
  • Posts: 2336
  • Hero Points: 132
Thanks Dennis!

A similar request (as I've been looking at Google Go language lately) is to allow to perform the push-tag on a ":=", and/or perhaps a push-tag on the variable name itself in the "auto" or ":=" statement.
« Last Edit: March 08, 2019, 04:45:23 PM by rowbearto »

Dennis

  • Senior Community Member
  • Posts: 3992
  • Hero Points: 520
One problem with this is that with a lot of modern C++, the push-tag is going to evaluate to a smart-pointer template.  While that *could* be special cased, I prefer not to muddy the waters with special cases.  You want to go to the type of a variable and it is a smart pointer, then you are probably going to wind up in a smart-pointer class.  Just pointing out that this will not be as straightforward of a feature as it may sound.

rowbearto

  • Senior Community Member
  • Posts: 2336
  • Hero Points: 132
I understand, it is why I made my next feature request in this post: https://community.slickedit.com/index.php/topic,16854.0.html

To be able to get the type into the clipboard.


rowbearto

  • Senior Community Member
  • Posts: 2336
  • Hero Points: 132
Perhaps the push-tag could give some type of pop-up menu showing the actual type and then giving a bunch of choices as to which part of the template to navigate to?

Dennis

  • Senior Community Member
  • Posts: 3992
  • Hero Points: 520
That was the idea I was just brainstorming:
Code: [Select]
SmartPointer<DumbStruct, vector<Peanuts>> spoda;
auto *b = &spoda;

push-tag on auto would prompt with:

Select Symbol for SmartPointer<DumbStruct, vector<Peanuts>>:
===================
SmartPointer
DumbStruct
vector
Peanuts

rowbearto

  • Senior Community Member
  • Posts: 2336
  • Hero Points: 132
Exactly! That would be very very useful!

Dennis

  • Senior Community Member
  • Posts: 3992
  • Hero Points: 520
Of course, this means that push-tag on std::string is going to give you about a half dozen whacky alternatives because of the allocator templates and char_traits and basic_string and enable_if, and every other nasty thing that makes up std::string now.  Although, I guess if it gets cut off at the typedef, then that won't be a problem, but this is just one example.