diff --git a/src/config.cpp b/src/config.cpp index 0e6dbd03f93..1c398c5ca53 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -571,7 +571,8 @@ config& config::add_child_at_total(config_key_type key, const config &val, size_ if(next == end) { config& res = config::add_child(key, val); - std::rotate(ordered_children.begin() + pos, ordered_children.end(), ordered_children.end() - 1); + //rotate the just inserted element to position pos. + std::rotate(ordered_children.begin() + pos, ordered_children.end() - 1, ordered_children.end()); return res; }