Change config assignment op to copy-and-swap

The previous implementation was not strongly exception safe.
This code is nearly identical logically, but with strong exception safety.
It's also good practice and more readable.
This commit is contained in:
Nathan Walker 2014-03-19 22:28:49 -05:00
parent efec4735ed
commit 923519d75a

View file

@ -437,10 +437,8 @@ config& config::operator=(const config& cfg)
if(this == &cfg) { if(this == &cfg) {
return *this; return *this;
} }
config tmp(cfg);
clear(); swap(tmp);
append_children(cfg);
values.insert(cfg.values.begin(), cfg.values.end());
return *this; return *this;
} }