Posts Tagged template

C++ For C# Developers: Part 40 – Utilities Library

Tags: , , , , ,

Today we’ll continue to explore the C++ Standard Library by delving into its utility classes and functions. These extremely common tools provide us with basics like std::tuple whose C# equivalent is so essential it’s built right into the language.

Read the rest of this article »

4 Comments

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

Tags: , , ,

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 »

No Comments

C++ For C# Developers: Part 29 – Template Constraints

Tags: , ,

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.

Read the rest of this article »

No Comments

C++ For C# Developers: Part 28 – Variadic Templates

Tags: , ,

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.

Read the rest of this article »

2 Comments

C++ For C# Developers: Part 27 – Template Deduction and Specialization

Tags: , , ,

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.

Read the rest of this article »

No Comments

C++ For C# Developers: Part 26 – Template Parameters

Tags: , , ,

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.

Read the rest of this article »

2 Comments

C++ For C# Developers: Part 25 – Intro to Templates

Tags: , , , ,

C# generics (List<T>) look a lot like C++ templates (list<T>), but they’re different in many key ways. It’s a big subject, so today we’ll start by looking at some of the most common uses of templates: applying them to classes, functions, members, lambdas, and variables.

Read the rest of this article »

2 Comments

C++ Scripting: Part 7 – MonoBehaviour Messages

Tags: , , , ,

The series continues this week by addressing a pretty important issue. Previously, we were limited to doing all our work in just two C++ functions: PluginMain and PluginUpdate. This isn’t at all the normal way to work in Unity. It’d be a lot more natural to write our code in MonoBehaviour classes. So today we’ll come up with some tricks to allow us to write our MonoBehaviour code in C++ so we are truly scripting in C++.

Read the rest of this article »

No Comments