Added a move-aware implementation of config::add_child.

This commit is contained in:
Guillaume Melquiond 2010-10-31 09:21:51 +00:00
parent 46dba2216f
commit 333f3761a2
2 changed files with 16 additions and 0 deletions

View file

@ -390,6 +390,18 @@ config& config::add_child(const std::string& key, const config& val)
return *v.back();
}
#ifdef HAVE_CXX0X
config &config::add_child(const std::string &key, config &&val)
{
check_valid(val);
child_list &v = children[key];
v.push_back(new config(std::move(val)));
ordered_children.push_back(child_pos(children.find(key), v.size() - 1));
return *v.back();
}
#endif
config &config::add_child_at(const std::string &key, const config &val, unsigned index)
{
check_valid(val);

View file

@ -275,6 +275,10 @@ public:
config& add_child(const std::string& key, const config& val);
config& add_child_at(const std::string &key, const config &val, unsigned index);
#ifdef HAVE_CXX0X
config &add_child(const std::string &key, config &&val);
#endif
/**
* Returns a reference to the attribute with the given @a key.
* Creates it if it does not exist.