News

C++ Performance: Common Wisdoms and Common “Wisdoms”—Sergey Ignatchenko

Sergey is writing a book and making draft chapters available for review. Here are sBB_part095_BookChapter013b_v1-640x427.pngSome tried-and-true, well-illustrated and entertaining tips:

C++ Performance: Common Wisdoms and Common "Wisdoms"

by Sergey Ignatchenko

From the draft chapter intro:

The opposite of a fact is falsehood, but the opposite of one profound truth may very well be another profound truth. — Niels Bohr

There are quite a few common wisdoms when it comes to C++ and games. As it always the case when facing a bunch of common wisdoms, some of them have their merits, some are obsolete-beyond-belief, and some are just taken from a very different context and are not really applicable. Let’s take a look at the most popular ones...

C++ Today—Bjarne Stroustrup

An interesting video to watch!

C++ Today

by Bjarne Stroustrup

Summary of the video:

During a short visit to College on 13 May 2016, Bjarne gave a talk describing what C++ is today (May 2016, C++14) and how it can be used well. He will focus on ISO standard C++ and the way it is developing.

 

May update for the C/C++ extension in Visual Studio Code—Ankit Asthana

News from Visual Studio:

May update for the C/C++ extension in Visual Studio Code

by Ankit Asthana

From the article:

We would like to thank all of you who have tried out the C/C++ extension in Visual Studio Code and have already provided
rich feedback on your experiences and filed issues and requests with us. We are working hard on incorporating your feedback
into the product. Continuing with our effort to make Visual Studio Code as the editor tool of choice for C++ developers with
this update of the C/C++ extension, we are introducing the following features:

• Code formatting with clang-format
• Fuzzy Auto-Complete for C/C++ code
• Debugging on Windows for Cygwin/MinGW applications
• Console application debugging with GDB on the Mac

Now let’s dive into each one of these in more detail...

CppCon 2015 Lambdas from First Principles: A Whirlwind Tour of C++—Arthur O’Dwyer

Have you registered for CppCon 2016 in September? Don’t delay – Early Bird registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2015 for you to enjoy. Here is today’s feature:

Lambdas from First Principles: A Whirlwind Tour of C++

by Arthur O'Dwyer

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Lambdas (even those mysterious generic lambdas) are just syntactic sugar atop constructs that are perfectly understandable when approached from the right direction.

We'll start with the implementation of C-style functions, then move to overloading, function templates, non-static member functions, C++11 lambdas, and then demystify C++14 generic ("auto") lambdas. Finally, we'll detour into the implementations of std::function and std::bind to show how they're different from lambdas.

doctest—the lightest feature rich C++ single header testing framework version 1.0.0 released!

The lightest feature rich C++ single header testing framework for unit tests and TDD

doctest 1.0.0 released!

From the release:

The doctest library is inspired by the unittest {} functionality of the D programming language and Python's docstrings - tests can be considered a form of documentation and should be able to reside near the production code which they test.

It is modeled after Catch which is currently the most popular and easy to use alternative for testing in C++

Quick Q: Is final used for optimization in C++?

Quick A: Possibly.

Recently on SO:

Is final used for optimization in C++?

It can be.

An optimisation along these lines would relate to the "de-virtualization" of the virtual calls. This is not always immediately affected by the final of the class nor method. Albeit they offer help to determine this, the normal rules of the virtual functions and class hierarchy apply.

If the compiler can determine that at runtime a particular method will always be called (e.g. given the OP example, with an automatic object), it could apply such an optimisation anyway, irrespective of whether the method is final or not.

Optimisations fall under the as-if rule, that allow the compiler to apply any transformation so long as the observable behaviour is as-if the original code had been executed.

C++ Modules - Spring Update—Gabriel Dos Reis

Let's talk about modules!

C++ Modules - Spring Update

by Gabriel Dos Reis

Abstract

“Modules” are a frequently requested and long-awaited feature by C++ programmers. The basic idea is a direct language support for (a) expressing the boundaries and dependencies of program components; (b) isolating source codes from macro vagaries; (c) scaling compile time, especially for large projects, given the ubiquity of “headers-only” template libraries; (d) spur innovation and deployment of semantics-aware developer tools. I will give an overview of the design points, goals, with emphasis on how modules address the four major problems mentioned above. I will also address standardization process and implementation issues

CppCon 2015 What’s New in Visual C++ 2015 and Future Directions—Steve Carroll • Ayman Shoukry

Have you registered for CppCon 2016 in September? Don’t delay – Early Bird registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2015 for you to enjoy. Here is today’s feature:

What's New in Visual C++ 2015 and Future Directions

by Steve Carroll • Ayman Shoukry

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

In this talk, we'll discuss new features, optimizations, and scenarios in Visual Studio 2015. We'll cover new backend optimizations, improved build throughput, new productivity and diagnostics features, and give a detailed update on our conformance progress, as well as talk about cool new c++1y features that we are shipping from await to modules.

Visual Studio isn't just for Microsoft platform developers. We'll also demonstrate our latest cross platform C++ development features for Android and iOS. We'll also give a sneak peak at our work on combining the Clang frontend with our existing backend to bring Clang support for Windows to Visual Studio.

CppCast Episode 57: Runtime Compiled C++ with Doug Binks

Episode 57 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Doug Binks from Enkisoftware to discuss Runtime Compile C++.

CppCast Episode 57: Runtime Compiled C++ with Doug Binks

by Rob Irving and Jason Turner

About the interviewee:

Doug Binks is programming the game Avoyd using Runtime Compiled C++, a technique he co-developed with industry friends; and enkiTS, a lightweight task scheduler.

An experienced game developer, Doug was previously Technical Lead of the Game Architecture Initiative at Intel. He has worked in the games industry in roles ranging from the R&D development manager at Crytek to head of studio at Strangelite, as well as lead programmer. An early interest in games development was sidetracked by a doctorate in Physics at Oxford University, and two post-doctoral posts as an academic researcher in experimental nonlinear pattern formation, specializing in fluid mechanics. His fondest childhood memories are of programming games in assembly on the ZX81.

Quick Q: was raw-pointer constructor of shared_ptr a mistake?

Quick A: No, its usage is well defined.

Recently on SO:

was raw-pointer constructor of shared_ptr a mistake?

In hindsight, given make_shared, would shared_ptr have a constructor that takes a raw pointer had it been introduced with C++11?
What if you don't control the allocation of the object? What if you need to use a custom deleter? What if you need list-initialization instead of parens?

None of these cases is handled by make_shared.

Additionally, if you're using weak_ptr, a shared_ptr allocated via make_shared won't free any memory until all the weak_ptrs are destroyed as well. So even if you have a normal shared pointer where none of the above apply, it's possible that you may still prefer the raw pointer constructor.

Yet another situation would be if your type provides overloads for operator new and operator delete. These may make it ill-suited for make_shared, since those overloads will not be called - and presumably they exist for a reason.