6.13.0 broken for non-copy-constructable String types
Created by: mikee47
With commit 6da6f921 both ElementProxy and MemberProxy take copies of the TString argument instead of taking a reference.
This breaks existing code which depends upon the referencing behaviour, and also has performance/efficiency implications.
The fault addressed by the above commit is briefly outlined in #1120 (closed), caused by a dangling reference
. To clarify, this is where the ElementProxy/MemberProxy take a reference to a temporary object (e.g. arduino String) which the compiler optimises out before the reference is used. This leads to unpredictable behaviour, so clearly taking proper copies is the safest (default) behaviour.
However, I have a custom FlashString
class (with adapter) which is not copy-constructible and so now no longer works as intended.
Here are the details:
- FlashString
- ArduinoJson FlashStringRefAdapter
I've been unable to find a workable solution without modifying ArduinoJson so I'll propose that and see where we go.
It feels like there's room for improvement here. Can we detect when it's safe to take a reference, and do that when possible?