Siv3D / OpenSiv3D

C++20 framework for creative coding 🎮🎨🎹 / Cross-platform support (Windows, macOS, Linux, and the Web)
https://siv3d.github.io/
MIT License
1k stars 138 forks source link

v0.6.14 での JSON の挙動の問題 #1192

Closed Reputeless closed 7 months ago

Reputeless commented 7 months ago
Raclamusi commented 7 months ago

1165 で JSON::operator =(const JSON&) の挙動を m_detail->get() の代入から m_detail の代入に変更したので、参照を持つ JSON オブジェクトに対して JSON::operator =(const JSON&) を使うと参照のすげ替えが起こり、要素の値を JSON オブジェクトで書き換えることができなくなっています( std::reference_wrapper::operator= みたいな挙動になっています)。

ツイートのコードでは、destJson[U"array"] = srcJson2; の行でその問題が発生しています。

JSON::operator =(const JSON&)m_detail->get() をコピーする実装のほうがよさそうです。