AI-Assisted Code Completion Suggestions Come to C++ via IntelliCode

By Nick Uhlenhuth

After reading and writing enough code, you begin to notice certain usage patterns. For example, if a stream is open, it will eventually be closed. More interestingly, if a string is used in the context of an if-statement, it will often be to check if the string is empty or if it has a certain size. You begin to identify and use these coding patterns over time, but what if Visual Studio already knew these common patterns and could suggest them to you as you code? That’s exactly what IntelliCode does. 

IntelliCode uses machine learning to train over thousands of real-world projects including open-source projects on GitHub. As such, IntelliCode will be most helpful when using common libraries such as STL. Based on this training, IntelliCode saves your time by putting what you’re most likely to use at the top of your IntelliSense completion list. IntelliCode for C++ is now available as an extension for Visual Studio 2019. 

As you use the IntelliCode extension, you will start to notice starred items at the top of your Member List – those are IntelliCode recommendations. For example, below we see “cend” being recommended based on the context of using “cbegin”. This is important since mixing “cbegin” with plain “end” is a compiler error with STL algorithms. 

What’s Next 

In a future release we will give C++ developers the ability to let IntelliCode learn from your own code. We are also considering adding C++ IntelliCode support to Visual Studio Code. 

Give Us Your Feedback  

IntelliCode is new for C++ developers using Visual Studio, so we are eager to hear your feedback as we continue to improve your experience. We can be reached via the comments below or via email at visualcpp@microsoft.com. If you encounter problems with IntelliCode for C++ or have a suggestion for Visual Studio please let us know through the Send Feedback button in the top right corner of Visual Studio, or via Developer Community. You can also find us on Twitter @VisualC.