diff --git a/chapter_07/PolyVal.cc b/chapter_07/PolyVal.cc index 3d338f6c2c4d6da02d265ecc93a7fef2845022d3..7f32fe17cf909cc8e9a3c737bb7d3bcad60310e0 100644 --- a/chapter_07/PolyVal.cc +++ b/chapter_07/PolyVal.cc @@ -1,12 +1,12 @@ -#include <iostream> +#include <print> #include <memory> #include <vector> -#include <type_traits> +#include <concepts> using namespace std::string_literals; -void func1(int x) { std::cout << "Integer = " << x << "\n"; } -void func1(double x) { std::cout << "Double = " << x << "\n"; } -void func1(std::string x) { std::cout << "std::string = \"" << x << "\"\n"; } +void func1(int x) { std::print("Integer = {}\n", x); } +void func1(double x) { std::print("Double = {}\n", x); } +void func1(std::string_view x) { std::print("std::string = \"{}\"\n", x); } class PolyVal { struct Internal { @@ -57,10 +57,10 @@ auto main() -> int for (auto&& elem : v) { func1(elem); } - std::cout << "------------\n"; + std::print("------------\n"); for (int i = 0; i < 6; ++i) { - std::cout << "Calling function with i = " - << i << " and receiving PolyVal by value\n"; + std::print("Calling function with i = {} and receiving PolyVal by value\n", + i); PolyVal X = f(i); func1(X); }