News

Move safety - know what can be done in the moved-from state—Jonathan Müller

What state is an object after move?

Move safety - know what can be done in the moved-from state

by Jonathan Müller

From the article:

C++ programmers have this notion of exception safety. It is a very useful concept. With it one can easily describe the post-conditions of a function if it throws.

There is another situation where you need to easily describe some post-conditions: when talking about the state of an object after a move operation, i.e. after a move constructor or move assignment operator. I thus want to introduce vocabulary for those post-conditions of the right-hand argument similar to the exception safety of a function: The move safety, if you will.

The exception safety describes the post-conditions of a function if the function throws an exception. Similarly, the move safety describes the post-conditions of the object after a move operation. It thus gives information about what can be done safely with a moved-from object...

C++/Graphics Workshop—Stephanie Hurlburt

Are you interested?

C++/Graphics Workshop

by Stephanie Hurlburt

Description of the event:

Ever been curious about C++ and graphics programming, but not sure where to start?
Maybe you are an artist who'd like to build your own tools. Maybe you're a game developer wishing your games would run faster, or have even better graphics effects. Regardless, knowledge of the way graphics work at a low level is an empowering skill.
We'll be covering real-time graphics with C++/OpenGL as well as raytracing. It'll be aimed at beginners, but everyone is welcome.
This'll be an intimate workshop, meant for around 20 people. We'll give a talk and then walk you through some hands-on examples. Be sure to bring a laptop if you can!

CppCon 2015 Cross-Platform Mobile App Development with Visual C++—Ankit Asthana & Marc Gregoire

Have you registered for CppCon 2016 in September? Don’t delay – 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:

Cross-Platform Mobile App Development with Visual C++

by Ankit Asthana & Marc Gregoire

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Visual C++ 2015 supports the development of apps for the Windows platform as well as for Android and iOS. A single code base, possibly with a thin platform-specific UI layer, can be compiled to run on Windows, Android, and iOS. The resulting binary can be published to a device and debugged, all from within Visual C++ 2015. This presentation introduces you to such cross-platform mobile app development, including debugging and emulation, and includes a number of demos.

Quick Q: Why two null constructors for std::unique_ptr?

Quick A: The nullptr_t constructor was added later.

Recently on SO:

Why two null constructors for std::unique_ptr?

For (1), consider that it ensures that both the no-arg constructor unique_ptr() and null-pointer constructor unique_ptr(nullptr_t) have the same compile-time guarantees, i.e. both are constexpr. We can see the difference in §20.8.1.2:

constexpr unique_ptr() noexcept;
explicit unique_ptr(pointer p) noexcept;
...
constexpr unique_ptr(nullptr_t) noexcept
: unique_ptr() { }

Why the two were not combined into a single constructor with a default value is likely historical contingency.

With regards to (2), why we should care about constexpr despite having a non-trivial destructor, consider the answer given here:

constexpr constructors can be used for constant initialization, which, as a form of static initialization, is guaranteed to happen before any dynamic initialization takes place.

For example, given a global std::mutex:

std::mutex mutex;

In a conforming implementation (read: not MSVC), constructors of other objects can safely lock and unlock mutex, becuase std::mutex's constructor is constexpr.

CppCon 2015 C++: How I learned to stop worrying and love metaprogramming—Edouard Alligand

Have you registered for CppCon 2016 in September? Don’t delay – 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:

C++: How I learned to stop worrying and love metaprogramming

by Edouard Alligand

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Horrible software engineering technique conceived in the forge of Hell or the Only True Way of doing C++ in 2015, template metaprogramming and its cohort of companion techniques are sure to create animation in a group of programmers.

What if we were to tell you that an actual software product, actually sold to real customers and in production for now several years has been built on it? What if we were to tell you that a lot of advanced template techniques helped us to build a better software faster?

This talk is all about real life examples of template metaprogramming, why they are useful and when and how you could use them in your own projects.

An update on the Meeting C++ Workshop Day

I finally can announce that the workshops will end with talks by James McNellis and Michael Caisse:

An Update on the workshop day

by Jens Weller

From the article:

Michael Caisse - boost.fusion: power to the tuples

    Tuples provide heterogeneous, compile-time containers; however, they can be difficult to use at run-time. Boost.Fusion brings together compile-time and run-time semantics to produce the STL of the meta-programming world. It is the machinery behind several Boost libraries and is a common element in many of the solutions provided by Ciere Consulting.


James McNellis - Practical C++ Coroutines

    One of the most interesting new features being proposed for C++ standardization is coroutines, formerly known as “resumable functions”. C++ coroutines are designed to be highly scalable, highly efficient (no overhead), and highly extensible, while still interacting seamlessly with the rest of the C++ language.

CppCon 2015 Parallelizing the C++ Standard Template Library—Grant Mercer & Danial Bourgeois

Have you registered for CppCon 2016 in September? Don’t delay – 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:

Parallelizing the C++ Standard Template Library

by Grant Mercer & Danial Bourgeois

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

As the era of frequency scaling comes to an end, multi-core parallelism has become an essential focal point in computational research. Mainstream languages, however, have not yet adapted to take full advantage of parallelism provided by the hardware. While new languages such as Rust and Swift are catching on and implementing multi-core algorithms in their libraries, C++ has only started to do so. A parallel Standard Library could bring with it many positive features that users can begin taking advantage of.

This talk will focus around two standards proposals, N4409 and N4406. N4409 outlines the details of a parallel Standard Library and features of these new parallel algorithms. The complementary N4406 outlines abstractions to take advantage of various mechanisms for parallel execution. We will cover the reasons why the new Standard Library would be beneficial to C++ users and our experience implementing these algorithms in HPX. The presentation will address what exactly the two proposals define, the challenges we faced, and the results we collected. In addition, we will discuss extensions made to these proposals and the C++11/14 standard in HPX to support these semantics in a distributed environment.

Enum Bitfields: A Gentle Introduction to SFINAE

Jon Kalb's talk at the New York C++ Developer meetup based on Anthony Williams' article in Overload is now online:

Using enum structs as bitfields (slides)

by Jon Kalb

From the description:

Jon Kalb gave a talk on Enum Bitfields at the New York C++ Developers group 2016-07-12. The talk was based on an article by Anthony Williams that is a gentle introduction to SFINAE. It includes a few nice library development pointers.