News

Pure Virtual C++ Videos Available

All videos from the Pure Virtual C++ 2023 conference are now online.

Pure Virtual C++ Videos Available

by Sy Brand

From the announcement:

Overall we had 18 videos on a wide variety of C++ topics, from Rust interop, to value semantics, to improving compiler errors.

CppCon 2022 Cute Approach for Polymorphism in C++ -- Liad Aben Sour Asayag

cppcon-2022-cute-approach-for-polymorphism-in-cpp-liad-aben-sour-asayag.pngRegistration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2023!

Lightning Talk: Cute Approach for Polymorphism in C++

by Liad Aben Sour Asayag

Summary of the talk:

I will talk about some tricks on how to stay generic and have good performance, while using polymorphism and virtual methods. Using aggregation.

Dealing with Mutation: Thread-Safe Interface -- Rainer Grimm

dealingwithmutations.pngI continue my journey with concurrency patterns in today's post. The Thread-Safe Interface fits very well when the critical sections are just objects.

Dealing with Mutation: Thread-Safe Interface

by Rainer Grimm

From the article:

The naive idea to protect all member functions of a class with a lock causes, in the best case, a performance issue and, in the worst case, a deadlock.

A Deadlock

The small code snippet has a deadlock.

struct Critical{
    void memberFunction1(){
        lock(mut);
        memberFunction2();
    ...
}

void memberFunction2(){
        lock(mut);
        ...
    }

    mutex mut;
};

Critical crit;
crit.memberFunction1();

Calling crit.memberFunction1 causes the mutex mut to be locked twice. For simplicity reasons, the lock is a scoped lock. Here are the two issues:

Into the Extreme – Fold-Expressions -- Coral Kashri

CoralKashri.pngFold expressions exist in C++ since C++17 and significantly affect how we treat variadic templates. Back in the day, I wrote about fold-expressions as part of the metaprogramming series, but today we will explore the extreme cases of fold-expression usages.

Into the Extreme – Fold-Expressions

by Coral Kashri

From the article:

In the case of a unary fold (fold expression without initialization), this case is legal for 3 types of operators: &&||, and ,.

Operator &&

template <typename ...Args>
auto and_cond(Args... args) {
    return (args && ...);
}

In case of empty parameters (for the call and_cond()), the function will return true. A reasonable explanation for this decision might be that && operator requires there won’t be any part that evaluates false. In this case, there are no parts at all, so none of the parts evaluates false, and therefore the result should be...

CppCon 2022 What’s New in C++23 -- Sy Brand

cppcon-2022-whats-new-in-cpp23-sy-brand.pngRegistration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2023!

What’s New in C++23

by Sy Brand

Summary of the talk:

C++23 comes with a host of language and library features to simplify your code, make it more expressive, and give you more power to play with. With the help of my cats, I’ll walk you through the majority of upcoming features, showing you how they can work together and what benefits you’ll gain from upgrading when the time comes.

Dealing with Mutation: Locking -- Rainer Grimm

dealingwithmutationlocking.pngLocking is a straightforward idea to protect a critical section. A critical section is a section of code that, at most, one thread can use at any time.

Dealing with Mutation: Locking

by Rainer Grimm

From the article:

Scoped locking is the idea of RAII applied to a mutex. Scoped locking is also known as synchronized block and guard. The key idea of this idiom is to bind the resource acquisition and release to an object’s lifetime. As the name suggests, the lifetime of the object is scoped. Scoped means that the C++ run time is responsible for object destruction and, therefore, for releasing the resource.

The class ScopedLock implements Scoped Locking.

CppCon 2022 The Future of C++ -- Neil Henderson

cppcon-2022-the-future-of-cpp-neil-henderson.pngRegistration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2023!

Lightning Talk: The Future of C++

by Neil Henderson

Summary of the talk:

Hopefully a light-hearted, comedic and entertaining look at the future of C++ from an Australian perspective.

The Case of the Two Billion Characters Long String -- Giovanni Dicanio

Several times you need to pass data (including text) from cross-platform C++ code to platform-specific C++ code. If you don't pay enough attention, weird bugs can happen at the boundary.

The Case of the Two Billion Characters Long String

by Giovanni Dicanio

From the article:

What is going on here? What is the origin of this bug? Why is the string reported as being more than 2 billion characters long?

Let's try to solve this mystery, with a sprinkle of assembly language, too!

 

Storage duration and Non-local Objects in C++ -- Bartlomiej Filipek

Filipek-book.pngC++ allows us to declare various forms of non-local objects: they usually live throughout the execution of the whole program. In this article, we’ll look at global variables, dynamic, and thread-local objects. We’ll also consider new features for safe initialization C++20.

Storage duration and Non-local Objects in C++

by Bartlomiej Filipek

From the article:

To start, we need to understand two key properties of an object in C++: storage and linkage. Let’s begin with the definition of storage, from [basic.stc#general]:
"The storage duration is the property of an object that defines the minimum potential lifetime of the storage containing the object. The storage duration is determined by the construct used to create the object."
An object in C++ has one of the following storage duration options:

CppCon 2022 Reflection in C++ - Past, Present, and Hopeful Future -- Andrei Alexandrescu

cppcon-2022-reflection-in-cpp-past-present-and-hopeful-future-andrei-alexan.pngRegistration is now open for CppCon 2023! The conference starts on October 1 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2023!

Reflection in C++ - Past, Present, and Hopeful Future

by Andrei Alexandrescu

Summary of the talk:

Aspect Oriented Programming. Metaobject protocols. Intentional programming. AspectC++. OpenC++. C++ metaclasses. Reflection and related technologies already has a long history in the theory and practice of several programming languages, including C++. However, the lofty promises of the 1990s (user-defined language semantics, infinite configurability, ultimate code reuse) failed to materialize in mainstream success.

Within the standard C++ realm, a reflection proposal has had a long and meandering road that is finally converging. Will it be successful? Why is this time different? And most importantly, what's in it for the community - what compelling applications are at the horizon to justify the addition to an already large language core?

This talk explores these questions and several related others. Although you won't take home code and insights that you can put to work tomorrow, you will acquire something that is less urgent but arguably more important: a vision of a better way of writing programs. Think generic programming without the pain, high-leverage generic code, seamless integration with foreign languages, and much more.