summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2016-02-05 23:28:12 +0100
committerMurray Cumming <murrayc@murrayc.com>2016-02-05 23:39:39 +0100
commit1c212efc8e0983a69b29a5cbef7565b13e4ebfa3 (patch)
tree0fa97d18f9a0255c8c6aa07aee4b3173c8d9ab3a
parent757fab512e4f390fa6e8645202efd87eebb42b66 (diff)
downloadglibmm-1c212efc8e0983a69b29a5cbef7565b13e4ebfa3.tar.gz
C++11: Use emplace_back() instead of push_back().
-rw-r--r--examples/network/resolver.cc8
-rw-r--r--gio/src/application.ccg6
-rw-r--r--glib/glibmm/class.cc2
-rw-r--r--glib/glibmm/containerhandle_shared.h2
-rw-r--r--glib/glibmm/dispatcher.cc2
-rw-r--r--glib/glibmm/interface.cc4
-rw-r--r--glib/glibmm/property.cc6
-rw-r--r--glib/glibmm/threadpool.cc2
-rw-r--r--glib/glibmm/wrap.cc2
-rw-r--r--glib/src/miscutils.ccg4
-rw-r--r--glib/src/optiongroup.ccg6
-rw-r--r--glib/src/variant.ccg6
-rw-r--r--glib/src/variant.hg2
-rw-r--r--tests/glibmm_btree/main.cc4
14 files changed, 28 insertions, 28 deletions
diff --git a/examples/network/resolver.cc b/examples/network/resolver.cc
index 57504795..a4f60bd0 100644
--- a/examples/network/resolver.cc
+++ b/examples/network/resolver.cc
@@ -137,9 +137,9 @@ split_service_parts (const Glib::ustring& arg)
delim2 = arg.find ('/', delim1 + 1);
if (delim2 == std::string::npos)
return parts;
- parts.push_back (arg.substr (0, delim1));
- parts.push_back (arg.substr (delim1 + 1, delim2 - delim1 - 1));
- parts.push_back (arg.substr (delim2 + 1));
+ parts.emplace_back (arg.substr (0, delim1));
+ parts.emplace_back (arg.substr (delim1 + 1, delim2 - delim1 - 1));
+ parts.emplace_back (arg.substr (delim2 + 1));
return parts;
}
@@ -210,7 +210,7 @@ start_threaded_lookups (char **argv, int argc)
{
const Glib::ustring arg = argv[i];
const auto thread = new std::thread(&lookup_thread, arg);
- result.push_back(thread);
+ result.emplace_back(thread);
}
return result;
diff --git a/gio/src/application.ccg b/gio/src/application.ccg
index 4c98dd59..d8dd6e26 100644
--- a/gio/src/application.ccg
+++ b/gio/src/application.ccg
@@ -451,11 +451,11 @@ void Application::add_main_option_entry_private(GOptionArg arg, const Glib::ustr
Application_delete_extra_application_data);
}
- extra_application_data->option_entry_strings.push_back(lname);
+ extra_application_data->option_entry_strings.emplace_back(lname);
if (desc)
- extra_application_data->option_entry_strings.push_back(desc);
+ extra_application_data->option_entry_strings.emplace_back(desc);
if (arg_desc)
- extra_application_data->option_entry_strings.push_back(arg_desc);
+ extra_application_data->option_entry_strings.emplace_back(arg_desc);
// Fill in array[0].
array[0].arg = arg;
diff --git a/glib/glibmm/class.cc b/glib/glibmm/class.cc
index bf57f84e..bbaf37fa 100644
--- a/glib/glibmm/class.cc
+++ b/glib/glibmm/class.cc
@@ -218,7 +218,7 @@ void Class::custom_class_init_function(void* g_class, void* class_data)
GValue* g_value = g_new0(GValue, 1);
g_value_init(g_value, iface_props[p]->value_type);
g_param_value_set_default(iface_props[p], g_value);
- props->push_back(g_value);
+ props->emplace_back(g_value);
g_object_class_override_property(gobject_class, props->size(), prop_name);
}
diff --git a/glib/glibmm/containerhandle_shared.h b/glib/glibmm/containerhandle_shared.h
index d88182da..4d5a552c 100644
--- a/glib/glibmm/containerhandle_shared.h
+++ b/glib/glibmm/containerhandle_shared.h
@@ -378,7 +378,7 @@ template <class Cont, class In>
void fill_container(Cont& container, In pbegin, In pend)
{
for(; pbegin != pend; ++pbegin)
- container.push_back(*pbegin);
+ container.emplace_back(*pbegin);
}
#endif /* GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS */
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index 1bbab0ec..f0ea19de 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -330,7 +330,7 @@ void DispatchNotifier::send_notification(Dispatcher* dispatcher)
const std::lock_guard<std::mutex> lock (mutex_);
const bool was_empty = notify_queue_.empty();
- notify_queue_.push_back(DispatchNotifyData(dispatcher, this));
+ notify_queue_.emplace_back(DispatchNotifyData(dispatcher, this));
if(was_empty)
{
diff --git a/glib/glibmm/interface.cc b/glib/glibmm/interface.cc
index be04a50d..f592d1b0 100644
--- a/glib/glibmm/interface.cc
+++ b/glib/glibmm/interface.cc
@@ -81,7 +81,7 @@ Interface::Interface(const Interface_Class& interface_class)
GValue* g_value = g_new0(GValue, 1);
g_value_init(g_value, iface_props[p]->value_type);
g_param_value_set_default(iface_props[p], g_value);
- props->push_back(g_value);
+ props->emplace_back(g_value);
const gchar* prop_name = g_param_spec_get_name(iface_props[p]);
GParamSpec* new_spec = g_param_spec_override(prop_name, iface_props[p]);
@@ -99,7 +99,7 @@ Interface::Interface(const Interface_Class& interface_class)
// The GObject is not instantiated yet. Add to the custom_interface_classes
// and add the interface in the Glib::Object constructor.
std::lock_guard<std::mutex> lock(extra_object_base_data_mutex);
- extra_object_base_data[this].custom_interface_classes.push_back(&interface_class);
+ extra_object_base_data[this].custom_interface_classes.emplace_back(&interface_class);
}
}
}
diff --git a/glib/glibmm/property.cc b/glib/glibmm/property.cc
index 0971e14d..302d48a0 100644
--- a/glib/glibmm/property.cc
+++ b/glib/glibmm/property.cc
@@ -186,7 +186,7 @@ void custom_set_property_callback(GObject* object, unsigned int property_id,
GValue* g_value = g_new0(GValue, 1);
g_value_init(g_value, G_VALUE_TYPE((*iface_props)[p]));
g_value_copy((*iface_props)[p], g_value);
- obj_iface_props->push_back(g_value);
+ obj_iface_props->emplace_back(g_value);
}
}
@@ -245,7 +245,7 @@ bool PropertyBase::lookup_property(const Glib::ustring& name)
g_assert(G_PARAM_SPEC_VALUE_TYPE(param_spec_) == G_VALUE_TYPE(value_.gobj()));
g_param_spec_ref(param_spec_);
- get_obj_custom_props(object_->gobj())->push_back(this);
+ get_obj_custom_props(object_->gobj())->emplace_back(this);
}
return (param_spec_ != nullptr);
@@ -271,7 +271,7 @@ void PropertyBase::install_property(GParamSpec* param_spec)
auto obj_custom_props = get_obj_custom_props(object_->gobj());
const unsigned int pos_in_obj_custom_props = obj_custom_props->size();
- obj_custom_props->push_back(this);
+ obj_custom_props->emplace_back(this);
// We need to offset by 1 as zero is an invalid property id.
const unsigned int property_id = pos_in_obj_custom_props + iface_props_size + 1;
diff --git a/glib/glibmm/threadpool.cc b/glib/glibmm/threadpool.cc
index f0218154..163fb19d 100644
--- a/glib/glibmm/threadpool.cc
+++ b/glib/glibmm/threadpool.cc
@@ -58,7 +58,7 @@ sigc::slot<void>* ThreadPool::SlotList::push(const sigc::slot<void>& slot)
{
Threads::Mutex::Lock lock (mutex_);
- list_.push_back(slot);
+ list_.emplace_back(slot);
return &list_.back();
}
diff --git a/glib/glibmm/wrap.cc b/glib/glibmm/wrap.cc
index eebe888c..18725a99 100644
--- a/glib/glibmm/wrap.cc
+++ b/glib/glibmm/wrap.cc
@@ -86,7 +86,7 @@ void wrap_register(GType type, WrapNewFunction func)
return;
const guint idx = wrap_func_table->size();
- wrap_func_table->push_back(func);
+ wrap_func_table->emplace_back(func);
// Store the table index in the type's static data.
g_type_set_qdata(type, Glib::quark_, GUINT_TO_POINTER(idx));
diff --git a/glib/src/miscutils.ccg b/glib/src/miscutils.ccg
index 76b539d4..c0600a6c 100644
--- a/glib/src/miscutils.ccg
+++ b/glib/src/miscutils.ccg
@@ -135,7 +135,7 @@ std::vector<std::string> get_system_data_dirs()
for(const gchar* const * iter = cresult; *iter != nullptr; ++iter)
{
- result.push_back(
+ result.emplace_back(
convert_const_gchar_ptr_to_stdstring(*iter));
}
@@ -152,7 +152,7 @@ std::vector<std::string> get_system_config_dirs()
for(const gchar* const * iter = cresult; *iter != nullptr; ++iter)
{
- result.push_back(
+ result.emplace_back(
convert_const_gchar_ptr_to_stdstring(*iter));
}
diff --git a/glib/src/optiongroup.ccg b/glib/src/optiongroup.ccg
index 0dbba0db..56236e4d 100644
--- a/glib/src/optiongroup.ccg
+++ b/glib/src/optiongroup.ccg
@@ -766,7 +766,7 @@ void OptionGroup::CppOptionEntry::convert_c_to_cpp()
//for(Glib::StringArrayHandle::iterator iter = array_handle.begin(); iter != array_handle.end(); ++iter)
//{
- // typed_cpp_arg->push_back(*iter);
+ // typed_cpp_arg->emplace_back(*iter);
//}
//So we do this:
@@ -774,7 +774,7 @@ void OptionGroup::CppOptionEntry::convert_c_to_cpp()
char** char_array_next = *typed_arg;
while(*char_array_next)
{
- typed_cpp_arg->push_back(*char_array_next);
+ typed_cpp_arg->emplace_back(*char_array_next);
++char_array_next;
}
}
@@ -793,7 +793,7 @@ void OptionGroup::CppOptionEntry::convert_c_to_cpp()
char** char_array_next = *typed_arg;
while(*char_array_next)
{
- typed_cpp_arg->push_back(*char_array_next);
+ typed_cpp_arg->emplace_back(*char_array_next);
++char_array_next;
}
}
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index a99c17c6..aba6902b 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -175,7 +175,7 @@ VariantContainerBase
VariantContainerBase::create_tuple(const VariantBase& child)
{
std::vector<VariantBase> vec;
- vec.push_back(child);
+ vec.emplace_back(child);
return create_tuple(vec);
}
@@ -492,7 +492,7 @@ type_vec_ustring Variant<type_vec_ustring>::get() const
GVariant* gvariant =
g_variant_get_child_value(const_cast<GVariant*>(gobj()), i);
- result.push_back(Glib::Variant<Glib::ustring>(gvariant).get());
+ result.emplace_back(Glib::Variant<Glib::ustring>(gvariant).get());
}
return result;
@@ -597,7 +597,7 @@ type_vec_string Variant<type_vec_string>::get() const
GVariant* gvariant =
g_variant_get_child_value(const_cast<GVariant*>(gobj()), i);
- result.push_back(Glib::Variant<std::string>(gvariant).get());
+ result.emplace_back(Glib::Variant<std::string>(gvariant).get());
}
return result;
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index 5f9a440e..c73fc8ed 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -1137,7 +1137,7 @@ std::vector<T> Variant< std::vector<T> >::get() const
g_variant_get_child_value(const_cast<GVariant*>(gobj()), i);
variant.init(gvariant);
- result.push_back(variant.get());
+ result.emplace_back(variant.get());
}
return result;
diff --git a/tests/glibmm_btree/main.cc b/tests/glibmm_btree/main.cc
index 837b7ae7..69566ccf 100644
--- a/tests/glibmm_btree/main.cc
+++ b/tests/glibmm_btree/main.cc
@@ -140,9 +140,9 @@ main()
auto ptree = Glib::BalancedTree<type_p_key_value, type_p_key_value>::create(sigc::ptr_fun(my_p_key_compare));
for (type_key_value::size_type i = 0; i < str.size(); ++i)
- pstr.push_back(new type_key_value(str.substr(i, 1)));
+ pstr.emplace_back(new type_key_value(str.substr(i, 1)));
for (type_key_value::size_type i = 0; i < str2.size(); ++i)
- pstr2.push_back(new type_key_value(str2.substr(i, 1)));
+ pstr2.emplace_back(new type_key_value(str2.substr(i, 1)));
for (type_key_value::size_type i = 0; i < str.size(); ++i)
ptree->insert(pstr[i], pstr[i]);