Add AnyScalar::clear()

This commit is contained in:
Michael Davidsaver
2018-02-21 10:27:03 -08:00
parent 7e8c49f0a0
commit 172046e78f

View File

@@ -138,13 +138,7 @@ public:
}
#endif
~AnyScalar() {
if(_stype==pvString) {
typedef std::string string;
_as<string>().~string();
}
// other types need no cleanup
}
~AnyScalar() {clear();}
AnyScalar& operator=(const AnyScalar& o) {
AnyScalar(o).swap(*this);
@@ -159,16 +153,24 @@ public:
#if __cplusplus>=201103L
AnyScalar& operator=(AnyScalar&& o) {
if(_stype==pvString) {
typedef std::string string;
_as<string>().~string();
}
_stype = (ScalarType)-1;
clear();
swap(o);
return *this;
}
#endif
//! Reset internal state.
//! Added after 7.0.0
//! @post empty()==true
void clear() {
if(_stype==pvString) {
typedef std::string string;
_as<string>().~string();
}
// other types need no cleanup
_stype = (ScalarType)-1;
}
void swap(AnyScalar& o) {
typedef std::string string;
switch((int)_stype) {