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
!
C++ For C# Developers: Part 35 – Modules, The New Build Model
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!
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!
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.
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.
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.
C++ For C# Developers: Part 29 – Template Constraints
C# where
constraints enable our generics to do a lot more. C++ also has constraints and they enable us to write more expressive and efficient code. Today we’ll see how to add some constraints to our templates to achieve these goals.
C++ For C# Developers: Part 28 – Variadic Templates
All of the templates we’ve written so far had a fixed number of parameters, but C++ lets us take a variable number of parameters too. This is like params
in C# functions, but for parameters to C++ templates. Today we’ll dig into this feature, which has no C# equivalent, and learn how to write and use templates with any number of parameters.
C++ For C# Developers: Part 27 – Template Deduction and Specialization
Template deduction in C++ is like generic type parameter deduction in C#: it allows us to omit template arguments. Template specialization has no C# equivalent, but enables special-casing of templates based on certain arguments. Today we’ll look at how these features can make our code a lot less noisy and also a lot more efficient.
C++ For C# Developers: Part 26 – Template Parameters
Last time, we started looking at a core feature of C++: templates. We compared and contrasted them to C# generics and saw how they’re applied to classes, functions, lambdas, and even variables. Today we’ll leverage the power of so-called “non-type template parameters” and “template template parameters” to write some really interesting code.