Skip to content

auto deduction with templates #11424

Answered by Colengms
dvoraen asked this question in Q&A
Sep 10, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

To clarify, as you observed, IntelliSense doesn't appear to be displaying 'auto' variable types unless it's able to (fully) resolve that type.

A simplified example:

template <typename T>
class A
{
public:
	T x;

	void foo();
};

template <typename T>
void A<T>::foo()
{
	auto y = x; // y is of an unknown type, so only 'auto' is displayed.
}

In your case, you're using a concept in place of typename. That filters acceptable types, but the type is still not yet known when evaluating shared_ptr<node<T>>, so falls back to displaying auto.

It would seem possible for it to instead display template<class T> std::shared_ptr<node<T>> (which is displays when hovering over pParent/pRight in your exam…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@dvoraen
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by dvoraen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants