0

In the discussions about using auto or not in c++, one side says that it is hard to see where you use a certain type, when you do not explicitly write it, but use auto. The other side says that with a modern ide, you can easily find this information.

Using visual studio 2017 I note that finding references do not point to auto usages. In the following, find references will point to these lines only

struct MyType

MyType foo()

void bar(MyType mt)

and not to the two lines in main, where the type, though not explicit, is in fact in use.

auto q = foo();

bar(q);

struct MyType{};

MyType foo()
{
    return MyType();
}

void bar(MyType mt){ }

int main(int value)
{
    auto q = foo();
    bar(q);
}

The question then being... is that not a problem in relation to this discussion? Alternatively, is there a way to make visual studio give all usages of MyType, when when it is auto realized.

Community
  • 1
  • 1
JoeTaicoon
  • 1,383
  • 1
  • 12
  • 28
  • The answer to your question is really subjective. This might help: https://stackoverflow.com/questions/6900459/the-new-keyword-auto-when-should-it-be-used-to-declare-a-variable-type. – R Sahu Dec 17 '17 at 19:05
  • It's not just `auto`. There's also `template ` which might be instantiated with `T==MyType`. – MSalters Dec 18 '17 at 10:52

0 Answers0