C++ For C# Developers: Part 39 – Language Support Library

Some parts of C++ require parts of the C++ Standard Library. We’ve lightly touched on classes like std::initializer_list and std::typeinfo already, but today we’ll look at a whole lot more. We’ll see parts of the Standard Library that would typically be built into the language or are otherwise strongly tied to making use of particular language features.

Read the rest of this article »

C++ For C# Developers: Part 38 – C Standard Library

Today we’ll begin exploring the C++ Standard Library. As C++ is mostly a superset of C, the C++ Standard Library is mostly a superset of the C Standard Library. So we’ll begin there!

Read the rest of this article »

C++ For C# Developers: Part 37 – Missing Language Features

We’ve covered all the features in the C++ language! Still, C# has some features that are missing from C++. Today we’ll look at those and explore some alternatives to fill these gaps.

Read the rest of this article »

C++ For C# Developers: Part 36 – Coroutines

In today’s final article covering the C++ language, we’ll explore a new C++20 feature: coroutines. These are analogous to both C# iterator functions (i.e. those with yield) and C# async functions. There are a lot of interesting aspects of coroutines, so let’s dive in explore!

Read the rest of this article »

C++ For C# Developers: Part 35 – Modules, The New Build Model

We’ve already seen C++’s traditional build model based on #include. Today we’ll look at the all-new build model introduced in C++20. This is built on “modules” and is much more analogous to the C# build model. Read on to learn how to use it by itself and in combination with #include!

Read the rest of this article »

C++ For C# Developers: Part 34 – Fold Expressions and Elaborated Type Specifiers

Today we’ll cover a couple of more minor features that don’t have C# equivalents: fold expressions and elaborated type specifiers. Though they are small, they can be quite useful!

Read the rest of this article »

C++ For C# Developers: Part 33 – Alignment, Assembly, and Language Linkage

Today we’ll explore some of the lower-level concepts in C++. These are tools that get brought out of the toolchest when performance really matters and interoperability is paramount. Read on to learn about C++’s escape hatches and take fine-grained control over memory!

Read the rest of this article »

C++ For C# Developers: Part 32 – Thread-Local Storage and Volatile

There is language-level support in C# for per-thread storage of variables. The same goes for the volatile keyword. C++ also supports per-thread variables, but with per-thread initialization and de-initialization. It has a volatile keyword too, but it’s meaning is quite different from C#. Read on to learn how to properly use these features in each language.

Read the rest of this article »

C++ For C# Developers: Part 31 – Deconstructing and Attributes

Both languages have both deconstructing (var (x, y) = vec;) and attributes ([MyAttribute]). C++ differs from C# in several ways, so today we’ll take a look at those differences and learn how to make use of these language features.

Read the rest of this article »

C++ For C# Developers: Part 30 – Type Aliases

C# has support for type aliases in the form of using ScoreMap = System.Collections.Generic.Dictionary<string, int>; directives. This allows us to use ScoreMap instead of the verbose System.Collections.Generic.Dictionary<string, int> or even Dictionary<string, int>. C++ also has type aliases, but they go way beyond what C# supports. Today we’ll dig into everything C++ offers us to make our code more concise and readable.

Read the rest of this article »