Posted November 25, 2024Nov 25 Recent versions of the C++ language (C++20 and C++23) may allow you to change drastically how you program in C++. I want to provide some fun examples. Having Fun with Modern C++ by Daniel Lemire From the article: Thanks to the integration of the features from the popular fmt library, it is much easier to format strings elegantly in C++. In turn the fmt library was inspired by the work done in languages like Python. Suppose that you have a vector of integers and you want to print its content: std::vector<int> v = {1, 2, 3, 4, 5}; std::println("{}", v); Suppose you want it to be centered in a line of 40 characters, with underscore characters around it: std::vector<int> v = {1, 2, 3, 4, 5}; std::println("{:_^40}", v); // ____________[1, 2, 3, 4, 5]_____________ View the full article
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.