Изменения в новых версиях / C++23

// note: C++23 - a newer compiler than the one this course is built
// against is needed (GCC 14, Clang 18, MSVC 19.40 or later, -std=c++23)
#include <cstdio>
#include <format>
#include <iostream>
#include <print>

// *** before: ***
void oldWay() {
    // C++20 could build the string but still had to hand it to a stream
    std::cout << std::format("{} is {}\n""Ann"31);
    std::printf("%s is %d\n""Bob"27);      // fast, but nothing is checked
}

// *** in version C++23: ***
void newWay() {
    std::print("{} is {}\n""Ann"31);
    std::println("{} is {}""Bob"27);       // adds the line break itself
    std::println("{:.2f} {:>6}"3.14159"right");
    std::println(stderr, "cannot open {}""notes.txt");

    // the text is written as UTF-8 whatever the stream is set to,
    // and the format string is still checked while compiling
}

int main() {
    oldWay();
    newWay();
}