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:
parent
efec4735ed
commit
923519d75a
1 changed files with 2 additions and 4 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue