Added move operators to class config,

...in order to speed up standard containers (e.g. std::vector).
This commit is contained in:
Guillaume Melquiond 2010-10-31 08:44:19 +00:00
parent 1e4eab72fc
commit 63caf15a2f
2 changed files with 23 additions and 2 deletions

View File

@ -209,6 +209,22 @@ config& config::operator=(const config& cfg)
return *this;
}
#ifdef HAVE_CXX0X
config::config(config &&cfg):
values(std::move(cfg.values)),
children(std::move(cfg.children)),
ordered_children(std::move(cfg.ordered_children))
{
}
config &config::operator=(config &&cfg)
{
clear();
swap(cfg);
return *this;
}
#endif
bool config::has_attribute(const std::string &key) const
{
check_valid();

View File

@ -79,7 +79,13 @@ public:
// Create an empty node.
config();
config(const config& cfg);
config(const config &);
config &operator=(const config &);
#ifdef HAVE_CXX0X
config(config &&);
config &operator=(config &&);
#endif
/**
* Creates a config object with an empty child of name @a child.
@ -88,7 +94,6 @@ public:
~config();
config& operator=(const config& cfg);
#ifdef HAVE_CXX0X
explicit operator bool() const