Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the compiler error of C2664 #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions 05.15-stdFmtStockIndexCustomFormatter1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ struct std::formatter<StockIndex> {
return it;
}

template<typename T>
const T& unmove(T&& x) const
{
return x;
}

auto format(const StockIndex& index, auto& ctx) const
{
if(IndexFormat::Short == indexFormat) {
Expand All @@ -102,9 +108,9 @@ struct std::formatter<StockIndex> {
ctx.out(),
fmt,
std::make_format_args(index.name(),
index.points(),
index.pointsDiff(),
index.pointsPercent()));
unmove(index.points()),
unmove(index.pointsDiff()),
unmove(index.pointsPercent())));
}
}
};
Expand Down
14 changes: 10 additions & 4 deletions 05.17-stdFmtStockIndexCustomFormatter2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ struct std::formatter<StockIndex> {
return it;
}

template<typename T>
const T& unmove(T&& x) const
{
return x;
}

auto format(const StockIndex& index, auto& ctx) const
{
// #D Add localized
Expand All @@ -110,7 +116,7 @@ struct std::formatter<StockIndex> {
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{
Expand All @@ -123,9 +129,9 @@ struct std::formatter<StockIndex> {
ctx.out(),
fmt,
std::make_format_args(index.name(),
index.points(),
index.pointsDiff(),
index.pointsPercent()));
unmove(index.points()),
unmove(index.pointsDiff()),
unmove(index.pointsPercent())));
}
}
};
Expand Down