[glibmm] C++11: Use initializer list instead of push_back() for initial single item.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] C++11: Use initializer list instead of push_back() for initial single item.
- Date: Fri, 5 Feb 2016 22:39:50 +0000 (UTC)
commit 757fab512e4f390fa6e8645202efd87eebb42b66
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Feb 5 23:27:15 2016 +0100
C++11: Use initializer list instead of push_back() for initial single item.
gio/src/appinfo.ccg | 12 ++++--------
tests/glibmm_variant/main.cc | 7 ++-----
2 files changed, 6 insertions(+), 13 deletions(-)
---
diff --git a/gio/src/appinfo.ccg b/gio/src/appinfo.ccg
index b0aa292..c9c251e 100644
--- a/gio/src/appinfo.ccg
+++ b/gio/src/appinfo.ccg
@@ -51,8 +51,7 @@ Glib::RefPtr<AppInfo> AppInfo::create_duplicate() const
bool AppInfo::launch(const Glib::RefPtr<Gio::File>& file, const Glib::RefPtr<AppLaunchContext>&
launch_context)
{
- std::vector< Glib::RefPtr<Gio::File> > vec;
- vec.push_back(file);
+ std::vector< Glib::RefPtr<Gio::File> > vec = {file};
GError* gerror = nullptr;
const bool retvalue = g_app_info_launch(gobj(),
@@ -66,8 +65,7 @@ bool AppInfo::launch(const Glib::RefPtr<Gio::File>& file, const Glib::RefPtr<App
bool AppInfo::launch(const Glib::RefPtr<Gio::File>& file)
{
- std::vector< Glib::RefPtr<Gio::File> > vec;
- vec.push_back(file);
+ std::vector< Glib::RefPtr<Gio::File> > vec = {file};
GError* gerror = nullptr;
const bool retvalue = g_app_info_launch(gobj(),
@@ -81,8 +79,7 @@ bool AppInfo::launch(const Glib::RefPtr<Gio::File>& file)
bool AppInfo::launch_uri(const std::string& uri, const Glib::RefPtr<AppLaunchContext>& launch_context)
{
- std::vector<std::string> vec;
- vec.push_back(uri);
+ std::vector<std::string> vec = {uri};
GError* gerror = nullptr;
const bool retvalue = g_app_info_launch_uris(gobj(),
@@ -96,8 +93,7 @@ bool AppInfo::launch_uri(const std::string& uri, const Glib::RefPtr<AppLaunchCon
bool AppInfo::launch_uri(const std::string& uri)
{
- std::vector<std::string> vec;
- vec.push_back(uri);
+ std::vector<std::string> vec = {uri};
GError* gerror = nullptr;
const bool retvalue = g_app_info_launch_uris(gobj(),
diff --git a/tests/glibmm_variant/main.cc b/tests/glibmm_variant/main.cc
index 47943de..bf17d14 100644
--- a/tests/glibmm_variant/main.cc
+++ b/tests/glibmm_variant/main.cc
@@ -51,8 +51,7 @@ int main(int, char**)
//vector<std::string>:
- std::vector<std::string> vec_strings;
- vec_strings.push_back("a");
+ std::vector<std::string> vec_strings = {"a"};
auto variant_vec_strings =
Glib::Variant<std::vector<std::string> >::create(vec_strings);
@@ -146,9 +145,7 @@ int main(int, char**)
typedef std::vector< std::map< Glib::ustring, Glib::Variant<int> > >
ComplexVecType;
- ComplexVecType complex_vector;
- complex_vector.push_back(complex_dict1);
- complex_vector.push_back(complex_dict2);
+ ComplexVecType complex_vector = {complex_dict1, complex_dict2};
auto complex_variant =
Glib::Variant<ComplexVecType>::create(complex_vector);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]