Announcing Template IntelliSense
C++ developers using function templates and class templates can now take full advantage of IntelliSense within their template bodies. In Visual Studio 2017 15.8 Preview 3, when your caret is inside a template, a new UI element called a “Template Bar” appears next to the template definition. The Template Bar allows you to provide sample template arguments for IntelliSense.
For example, let’s look in the Boost library at the function template is_partitioned_until inside of algorithm.hpp (which I slightly modified for this demo). We can use the Template Bar to give IntelliSense an example of the InputIterator type and the UnaryPredicate type.
- Click the <T> icon to expand/collapse the Template Bar.
- Click the pencil icon or double-click the Template Bar to open the Edit window.
Notice that we were able to use decltype on the UnaryPredicate called myPredicate. With this information provided, we have the full power of IntelliSense while we edit the template body. We get all the proper squiggles, quick info, parameter help, etc.
We are considering the Template Bar information to be user-specific, thus it is stored in the .vs folder and not shared on commits.
Download the latest Visual Studio 2017 Preview and try it with your projects. To disable/enable the feature, go to Tools > Options > C/C++ > Advanced > IntelliSense > Enable Template IntelliSense.
We will continue to improve this feature in subsequent releases. We already have plans to support nested templates and to handle edits outside of Visual Studio.
As with all new features, your feedback is very important in helping guide our development. You can send me your feedback on Twitter @nickuhlenhuth, or reach out to the Visual Studio C++ team @visualc or firstname.lastname@example.org.