From the course: C++ Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Format - C++ Tutorial
From the course: C++ Essential Training
Format
- [Instructor] The format library is new to C++ 20. Until now, if you wanted to format text, you could use either the legacy printf functions or the STL I/O Stream library. Both have serious flaws but we've used them because they work. Beginning with C++ 20, the format function provides text formatting inspired by Python 3's formatter. This is format.cpp from chapter nine of the exercise files. The C++ 20 format library does not include a print function but it's relatively simple to implement. We come down here around line 30. We'll see our print function. You'll notice it's templated and the template argument has these three dots, followed by args. This is a parameter pack and we'll cover parameter packs in the companion course: C++ Templates and the STL. For now, you can simply copy and paste this. And this will work as a print function that works exactly like the format function, except instead of returning…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.