C++ Team Blog

The latest in C++, Visual Studio, VS Code, and vcpkg from the MSFT C++ team

Latest posts

Nov 26, 2018
Post comments count 5
Post likes count 0

Using Visual Studio for Cross Platform C++ Development Targeting Windows and Linux

Marc Goodner

A great strength of C++ is the ability to target multiple platforms without sacrificing performance. If you are using the same codebase for multiple targets, then CMake is the most common solution for building your software. You can use Visual Studio for your C++ cross platform development when using CMake without needing to create or generate Visual Studio projects. Just open the folder with your sources in Visual Studio (File > Open Folder). Visual Studio will recognize CMake is being used, then use metadata CMake produces to configure IntelliSense and builds automatically. You can quickly be editing, buildi...

Nov 20, 2018
Post comments count 0
Post likes count 0

Q&A: Fine-grained friendship

Herb Sutter

This post is part of a regular series of posts where the C++ product team here at Microsoft answers questions we have received from customers. The questions can be about anything C++ related: Visual C++, the standard language and library, the C++ standards committee, isocpp.org, CppCon, etc. Today's Q&A is by Herb Sutter. Question Reader @thesamhughescom recently asked: Has there ever been a consideration for allowing individual private functions to whitelist other classes or functions to call them? Similar to the per class friend method, I was thinking you could annotate a function with or just an ide...

Nov 7, 2018
Post comments count 1
Post likes count 0

Use the official range-v3 with MSVC 2017 version 15.9

Casey Carter

We’re happy to announce that the ongoing conformance work in the MSVC compiler has reached a new milestone: support for Eric Niebler’s range-v3 library. It’s no longer necessary to use the range-v3-vs2015 fork that was introduced for MSVC 2015 Update 3 support; true upstream range-v3 is now usable directly with MSVC 2017. The last push to achieve range-v3 support involved Microsoft-sponsored changes in both the MSVC compiler and range-v3. The compiler changes involved fixing about 60 historically blocking bugs, of which 30+ were alias template bugs in /permissive- mode. Changes to range-v3 were to add support...

Nov 6, 2018
Post comments count 1
Post likes count 0

Exploring Clang Tooling Part 3: Rewriting Code with clang-tidy

Stephen Kelly

In the previous post in this series, we used clang-query to examine the Abstract Syntax Tree of a simple source code file. Using clang-query, we can prototype an AST Matcher which we can use in a clang-tidy check to refactor code in bulk. This time, we will complete the rewriting of the source code. Let's return to MyFirstCheck.cpp we generated earlier and update the registerMatchers method. First we can refactor it to port both function declarations and function calls, using the callExpr() and callee() matchers we used in the previous post: Because Matchers are really C++ code, we can extract them i...

Oct 23, 2018
Post comments count 0
Post likes count 1

Exploring Clang Tooling Part 2: Examining the Clang AST with clang-query

Stephen Kelly

This post is part of a regular series of posts where the C++ product team and other guests answer questions we have received from customers. The questions can be about anything C++ related: MSVC toolset, the standard language and library, the C++ standards committee, isocpp.org, CppCon, etc. Today’s post is by guest author Stephen Kelly, who is a developer at Havok, a contributor to Qt and CMake and a blogger. This post is part of a series where he is sharing his experience using Clang tooling in his current team. In the last post, we created a new clang-tidy check following documented steps and encountered...

Oct 19, 2018
Post comments count 0
Post likes count 1

Exploring Clang Tooling Part 1: Extending Clang-Tidy

Stephen Kelly

This post is part of a regular series of posts where the C++ product team and other guests answer questions we have received from customers. The questions can be about anything C++ related: MSVC toolset, the standard language and library, the C++ standards committee, isocpp.org, CppCon, etc. Today’s post is by guest author Stephen Kelly, who is a developer at Havok, a contributor to Qt and CMake and a blogger. This post is part of a series where he is sharing his experience using Clang tooling in his current team. This post is part of a three-part series about using the Clang AST Matchers to mechanically re...

Oct 16, 2018
Post comments count 0
Post likes count 0

Standard Library Algorithms: Changes and Additions in C++17

Visual CPP Team

Today we have a guest post from Marc Gregoire, Software Architect at Nikon Metrology and Microsoft MVP since 2007.   The C++14 standard already contains a wealth of different kinds of algorithms. C++17 adds a couple more algorithms and updates some existing ones. This article explains what’s new and what has changed in the C++17 Standard Library. New Algorithms Sampling C++17 includes the following new sampling algorithm: It uses the given random number generator () to pick random elements from a given range [, ) and writes them to the given output iterator (). Here is a simple piece of c...

Oct 11, 2018
Post comments count 0
Post likes count 0

How to Use Class Template Argument Deduction

Stephan T. Lavavej - MSFT

Class Template Argument Deduction (CTAD) is a C++17 Core Language feature that reduces code verbosity. C++17's Standard Library also supports CTAD, so after upgrading your toolset, you can take advantage of this new feature when using STL types like std::pair and std::vector. Class templates in other libraries and your own code will partially benefit from CTAD automatically, but sometimes they'll need a bit of new code (deduction guides) to fully benefit. Fortunately, both using CTAD and providing deduction guides is pretty easy, despite template metaprogramming's fearsome reputation! CTAD support is availab...

Oct 4, 2018
Post comments count 3
Post likes count 0

std::any: How, when, and why

Casey Carter

This post is part of a regular series of posts where the C++ product team here at Microsoft and other guests answer questions we have received from customers. The questions can be about anything C++ related: MSVC toolset, the standard language and library, the C++ standards committee, isocpp.org, CppCon, etc. Today’s post is by Casey Carter. C++17 adds several new "vocabulary types" - types intended to be used in the interfaces between components from different sources - to the standard library. MSVC has been shipping implementations of , , and since the Visual Studio 2017 release, but we haven't provided any ...