diff --git a/05.15-stdFmtStockIndexCustomFormatter1/main.cpp b/05.15-stdFmtStockIndexCustomFormatter1/main.cpp index 35d94dc..a289cce 100644 --- a/05.15-stdFmtStockIndexCustomFormatter1/main.cpp +++ b/05.15-stdFmtStockIndexCustomFormatter1/main.cpp @@ -85,6 +85,12 @@ struct std::formatter { return it; } + template + const T& unmove(T&& x) const + { + return x; + } + auto format(const StockIndex& index, auto& ctx) const { if(IndexFormat::Short == indexFormat) { @@ -102,9 +108,9 @@ struct std::formatter { ctx.out(), fmt, std::make_format_args(index.name(), - index.points(), - index.pointsDiff(), - index.pointsPercent())); + unmove(index.points()), + unmove(index.pointsDiff()), + unmove(index.pointsPercent()))); } } }; diff --git a/05.17-stdFmtStockIndexCustomFormatter2/main.cpp b/05.17-stdFmtStockIndexCustomFormatter2/main.cpp index eff51bc..ca6f9dd 100644 --- a/05.17-stdFmtStockIndexCustomFormatter2/main.cpp +++ b/05.17-stdFmtStockIndexCustomFormatter2/main.cpp @@ -96,6 +96,12 @@ struct std::formatter { return it; } + template + const T& unmove(T&& x) const + { + return x; + } + auto format(const StockIndex& index, auto& ctx) const { // #D Add localized @@ -110,7 +116,7 @@ struct std::formatter { return std::vformat_to( ctx.out(), fmt, - std::make_format_args(index.name(), index.points())); + std::make_format_args(index.name(), unmove(index.points()))); } else { const auto fmt{ @@ -123,9 +129,9 @@ struct std::formatter { ctx.out(), fmt, std::make_format_args(index.name(), - index.points(), - index.pointsDiff(), - index.pointsPercent())); + unmove(index.points()), + unmove(index.pointsDiff()), + unmove(index.pointsPercent()))); } } };