From the course: Modern C++: Advanced Techniques and Features

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Additional library enhancements

Additional library enhancements

- So in this section, our final section, we're going to look at some additional library enhancements in the C++ library these days. A couple of topics in particular. Going to look at std variant, first of all, and a bit like std any, but more constrained. And then to wrap up, we'll have a look at the parallel algorithms. So first of all, std variant is a bit like std any, in the sense that it can contain multiple different types of variable only one at a time. Except that with std variant, you actually enumerate all the possible types upfront. Okay? So, you can see in this example here, well, first of all, #include the variant header and then when you create a std variant inside the angle brackets, you specify all the different types that could be contained inside this variant instance. And it's like a union. It'll either contain an integer or a double at any given moment in time. It's not completely open, you can't put a string into it, it can only be an integer or a double. So, it's…

Contents