Closed
Description
With intrinsic type T
, given:
EEPROMStorage<T> first_thing(0, 0);
EEPROMStorage<T> second_thing((sizeof(T) + 1), 0);
Code such as the following:
...
second_thing = first_thing;
...
does not result in the value in first_thing
being copied into second_thing
, which misled me (an experienced coder) and probably would be very misleading to a novice (common among Arduino users). It in fact appears to cause the checksum of second_thing
to become invalid, as evidenced by the constructor reinitializing the default value on the next boot.
Using a temporary variable yields the expected result, e.g.,
...
T temp = first_thing;
second_thing = temp;
...
I suggest that EEPROMStorage<T>::operator=(const EEPROMStorage & rhs)
and EEPROMStorage<T>::operator=(const T& rhs)
should be equivalent.
Metadata
Metadata
Assignees
Labels
No labels