November 2017

Simplifying Compile-Time Options With if constexpr--Philippe Groarke

New possibilities open in front of us!

Simplifying Compile-Time Options With if constexpr

by Philippe Groarke

From the article:

My latest little experiment relates to compile-time options and eliminating preprocessor checks in user code. I’m not a big fan of MACROs, especially when they are simply used to make compile-time branches. I am also not a fan of other techniques used to minimize this problem. With C++17, we now have a beautiful and simple tool that can help remove all these preprocessor checks, if constexpr...

Implementing the spaceship operator for optional--Barry Revzin

The future implementation?

Implementing the spaceship operator for optional

by Barry Revzin

From the article:

Last week, the C++ Standards Committee added operator<=>, known as the spaceship operator, to the working draft for what will eventually become C++20. This is an exciting new language feature for two reasons: it allows you to write one function to do all your comparisons where you used to have to write six, and it also allows you to write zero functions — just declare the operator as defaulted and the compiler will do all the work for you! Exciting times...

CppCast Episode 126: VS Code with Rong Lu

Episode 126 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Rong Lu to talk about C++ support with the Visual Studio Code Editor and some of the recent improvements made to it.

CppCast Episode 126: VS Code with Rong Lu

by Rob Irving and Jason Turner

About the interviewee:

Rong Lu is a Program Manager in the Visual C++ team at Microsoft. She has been on the Visual Studio team since she graduated with her master degree in computer science 10 years ago. She currently works on Visual Studio tools for games, C++ mobile, and the C++ experience in Visual Studio Code. Before joining the C++ team, she spent 4 years building the VS SharePoint and architecture tools.

C++ Core Check improvements in Visual Studio 2017 15.5--Sergiy Oryekhov

In Visual Studio 2017 15.5 Preview 4 the team has refreshed the C++ Core Guidelines Check extension for native code static analysis tools:

C++ Core Check improvements in Visual Studio 2017 15.5

by Sergiy Oryekhov

From the article:

Most of the work since 15.3 has been focused on new rules that will help developers starting new projects write safer C++ and those with legacy projects move toward safer, modern C++...

First Meeting C++ Trip Report -- Simon Brand

Simon Brand attended the recent Meeting C++ conference and wrote down his impressions:

Meeting C++ Trip Report

by Simon Brand

From the article:

This year was my first time at Meeting C++. It was also the first time I gave a full-length talk at a conference. But most of all it was a wonderful experience filled with smart, friendly people and excellent talks. This is my report on the experience. I hope it gives you an idea of some talks to watch when they’re up on YouTube, and maybe convince you to go along and submit talks next year! I’ll be filling out links to the talks as they go online.

 

CppCon2017 Trip Report -- Gordon Brown

Trip report from CppCon 2017. Highlights, trends and some tips for getting the most out of the conference.

CppCon2017 Trip Report

by Gordon Brown

From the article:

CppCon this year was bigger than ever with approaching 1200 attendees and 7 tracks; making it even harder to pick which talks to go to. Thankfully all the talks are made available online, so if you couldn’t make it to the conference or even if you did but couldn’t get to see all the talks you wanted to, you can go online and watch them. I only got to a handful of the talks as I often had conflicting appointments, but I’ve highlighted a few from what I saw that I would recommend checking out and some which I didn’t make it to but heard good things about.

Quick Q: What is the usefulness of `enable_shared_from_this`?

Quick A: It allows you to get a valid shared pointer from your instance directly.

Recently on SO:

What is the usefulness of `enable_shared_from_this`?

It enables you to get a valid shared_ptr instance to this, when all you have is this. Without it, you would have no way of getting a shared_ptr to this, unless you already had one as a member. This example from the boost documentation for enable_shared_from_this:

class Y: public enable_shared_from_this<Y>
{
public:

    shared_ptr<Y> f()
    {
        return shared_from_this();
    }
}

int main()
{
    shared_ptr<Y> p(new Y);
    shared_ptr<Y> q = p->f();
    assert(p == q);
    assert(!(p < q || q < p)); // p and q must share ownership
}

The method f() returns a valid shared_ptr, even though it had no member instance. Note that you cannot simply do this:

class Y: public enable_shared_from_this<Y>
{
public:

    shared_ptr<Y> f()
    {
        return shared_ptr<Y>(this);
    }
}

The shared pointer that this returned will have a different reference count from the "proper" one, and one of them will end up losing and holding a dangling reference when the object is deleted.

enable_shared_from_this is going to be a part of the new C++0x standard as well, so you can also get it from there as well as from boost.

PVS-Studio Reports Now in Html

FullHtml is a full-fledged report format for viewing analysis results.

PVS-Studio Reports Now in Html

by Svyatoslav Razmyslov

From the article:

It allows you to search for and sort messages by type, file, level, code, and warning text. What makes it special is that it allows you to navigate faulty fragments in the source files pointed out by the analyzer. The reported source files themselves are copied to Html and become part of the report. To see how FullHtml really looks like, I converted in this format one of the latest reports, which I've used when writing the article about the MuseScore project: MuseScoreHtml.7z.