OpenSiv3D
OpenSiv3D copied to clipboard
各種クラスの fmt 対応の不具合
- reported by: https://discord.com/channels/443310697397354506/1000291580915232879/1013121181500588123
Optional
についても同様の不具合があります。
format_to(ctx.out(), sv)
で検索をかけるといくつか出てきましたが、 Date
や IPv4Address
などは {}
が出てこないので問題なさそうです。
Array
や Grid
は {
と }
をそれぞれ {{
と }}
に置換することで解決していますが、 replace
メンバ関数の呼び出しのたびに要素のコピーが発生しているので、パフォーマンスに影響が出てそうです。この機会に改めるのもいいかもしれません。
format_to(ctx.out(), sv)
で検索して出てきたクラス
-
String
-
StringView
-
Optional
-
Date
-
DateTime
-
IPv4Address
-
UUIDValue
-
Array
-
Grid
# include <Siv3D.hpp> // OpenSiv3D v0.6.5
void Main()
{
Print << U"{}"_fmt(U"{}"s); // std::u32string は OK
Print << U"{}"_fmt(Optional{ U"{}"s }); // Optional<std::u32string> はダメ
while (System::Update());
}
ご指摘ありがとうございます!
開発中の v0.6.6 で修正
# include <Siv3D.hpp> // OpenSiv3D v0.6.6
void Main()
{
Console << U"{}"_fmt(U"{}");
Console << U"{}"_fmt(U"{}"_s);
Console << U"{}"_fmt(U"{}"_sv);
Console << U"{}"_fmt(Optional{ U"{}"s });
{
Array<int32> e = {};
Console << U"Hello {} array"_fmt(e);
Array<int32> v = { 1, 2, 3, 4, 5 };
Console << U"Hello {} array"_fmt(v);
Array<String> vs = { U"Aaa", U"Bbb", U"{}", U"Ddd" };
Console << U"Hello {} array"_fmt(vs);
Array<double> vd = { 1.23456, 2.2222, 3.33333, 4.4444, 5.55555 };
Array<Array<double>> vvd = { vd, vd, {} };
Console << U"{:.1f}"_fmt(vvd);
}
{
Grid<int32> e;
Console << U"Hello {} array"_fmt(e);
Grid<int32> v(Size{ 3, 4 }, 1);
Console << U"Hello {:#x} array"_fmt(v);
Grid<String> vs = { {U"Aaa", U"Bbb"}, {U"{}", U"Ddd"} };
Console << U"Hello {} array"_fmt(vs);
Grid<double> vd = { {1.23456, 2.2222}, {3.33333, 4.4444}, {5.55555, 6.66} };
Grid<Grid<double>> vvd(Size{ 2, 2 }, vd);
Console << U"{:.1f}"_fmt(vvd);
}
{
std::vector<int32> e = {};
Console << U"Hello {} array"_fmt(e);
std::vector<int32> v = { 1, 2, 3, 4, 5 };
Console << U"Hello {} array"_fmt(v);
std::vector<String> vs = { U"Aaa", U"Bbb", U"{}", U"Ddd" };
Console << U"Hello {} array"_fmt(vs);
std::vector<double> vd = { 1.23456, 2.2222, 3.33333, 4.4444, 5.55555 };
std::vector<std::vector<double>> vvd = { vd, vd, {} };
Console << U"{:.1f}"_fmt(vvd);
}
{
std::array<int32, 0> e = {};
Console << U"Hello {} array"_fmt(e);
std::array<int32, 5> v = { 1, 2, 3, 4, 5 };
Console << U"Hello {} array"_fmt(v);
std::array<String, 4> vs = { U"Aaa", U"Bbb", U"{}", U"Ddd" };
Console << U"Hello {} array"_fmt(vs);
Array<double> vd = { 1.23456, 2.2222, 3.33333, 4.4444, 5.55555 };
std::array<Array<double>, 3> vvd = { vd, vd, {} };
Console << U"{:.1f}"_fmt(vvd);
}
while (System::Update())
{
}
}