diff options
author | Murray Cumming <murrayc@murrayc.com> | 2013-06-26 10:28:33 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2013-06-26 10:28:33 +0200 |
commit | 9b0554e2c9deca2399e654e7984c9dfe3b67e387 (patch) | |
tree | de4b706ec16ad9a1ab2435a4e4350dffcdc6ab75 /examples | |
parent | 19609dd50df826942ea3d77a409749adab57445f (diff) | |
download | glibmm-9b0554e2c9deca2399e654e7984c9dfe3b67e387.tar.gz |
C++11: Use auto in examples.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/child_watch/main.cc | 4 | ||||
-rw-r--r-- | examples/dbus/client_bus_listnames.cc | 4 | ||||
-rw-r--r-- | examples/dbus/server_without_bus.cc | 16 | ||||
-rw-r--r-- | examples/dbus/session_bus_service.cc | 12 | ||||
-rw-r--r-- | examples/iochannel_stream/fdstream.cc | 2 | ||||
-rw-r--r-- | examples/keyfile/main.cc | 8 | ||||
-rw-r--r-- | examples/markup/parser.cc | 10 | ||||
-rw-r--r-- | examples/network/resolver.cc | 40 | ||||
-rw-r--r-- | examples/network/socket-client.cc | 24 | ||||
-rw-r--r-- | examples/network/socket-server.cc | 14 | ||||
-rw-r--r-- | examples/options/main.cc | 4 | ||||
-rw-r--r-- | examples/properties/properties_example.cc | 2 | ||||
-rw-r--r-- | examples/regex/main.cc | 2 | ||||
-rw-r--r-- | examples/settings/settings.cc | 4 | ||||
-rw-r--r-- | examples/thread/dispatcher.cc | 2 | ||||
-rw-r--r-- | examples/thread/dispatcher2.cc | 5 | ||||
-rw-r--r-- | examples/thread/thread.cc | 6 |
17 files changed, 73 insertions, 86 deletions
diff --git a/examples/child_watch/main.cc b/examples/child_watch/main.cc index 3bbc368b..5e9fb673 100644 --- a/examples/child_watch/main.cc +++ b/examples/child_watch/main.cc @@ -38,7 +38,7 @@ private: void ChildWatch::run() { - GPid pid = fork(); + auto pid = fork(); if(pid==0) { @@ -59,7 +59,7 @@ void ChildWatch::on_child_exited(GPid pid, int status) int main() { - Glib::RefPtr<Glib::MainLoop> mainLoop = Glib::MainLoop::create(); + auto mainLoop = Glib::MainLoop::create(); ChildWatch cwatch(mainLoop); cwatch.run(); diff --git a/examples/dbus/client_bus_listnames.cc b/examples/dbus/client_bus_listnames.cc index b46fdcf8..b44c933e 100644 --- a/examples/dbus/client_bus_listnames.cc +++ b/examples/dbus/client_bus_listnames.cc @@ -56,7 +56,7 @@ void on_dbus_proxy_available(Glib::RefPtr<Gio::AsyncResult>& result) result.get_child(names_variant); // Get the vector of strings. - std::vector<Glib::ustring> names = names_variant.get(); + const auto names = names_variant.get(); std::cout << "The names on the message bus are:" << std::endl; @@ -81,7 +81,7 @@ int main(int, char**) loop = Glib::MainLoop::create(); // Get the user session bus connection. - Glib::RefPtr<Gio::DBus::Connection> connection = + auto connection = Gio::DBus::Connection::get_sync(Gio::DBus::BUS_TYPE_SESSION); // Check for an unavailable connection. diff --git a/examples/dbus/server_without_bus.cc b/examples/dbus/server_without_bus.cc index d50632dc..efdda932 100644 --- a/examples/dbus/server_without_bus.cc +++ b/examples/dbus/server_without_bus.cc @@ -35,7 +35,7 @@ namespace static Glib::RefPtr<Gio::DBus::NodeInfo> introspection_data; -static Glib::ustring introspection_xml = +static auto introspection_xml = "<node>" " <interface name='org.glibmm.DBus.Clock'>" " <method name='GetTime'>" @@ -67,12 +67,12 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& /* connect Glib::TimeVal curr_time; curr_time.assign_current_time(); - const Glib::ustring time_str = curr_time.as_iso8601(); - const Glib::Variant<Glib::ustring> time_var = + const auto time_str = curr_time.as_iso8601(); + const auto time_var = Glib::Variant<Glib::ustring>::create(time_str); // Create the tuple. - Glib::VariantContainerBase response = + auto response = Glib::VariantContainerBase::create_tuple(time_var); // Return the tuple with the included time. @@ -89,7 +89,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& /* connect parameters.get_child(param); // Get the time string. - const Glib::ustring time_str = param.get(); + const auto time_str = param.get(); if(!curr_alarm.assign_from_iso8601(time_str)) { @@ -114,7 +114,7 @@ const Gio::DBus::InterfaceVTable interface_vtable(sigc::ptr_fun(&on_method_call) bool on_server_new_connection(const Glib::RefPtr<Gio::DBus::Connection>& connection) { - Glib::RefPtr<Gio::Credentials> credentials = + auto credentials = connection->get_peer_credentials(); std::string credentials_str; @@ -179,7 +179,7 @@ int main(int, char**) Glib::RefPtr<Gio::DBus::Server> server; - const Glib::ustring address = "unix:abstract=myadd"; + const auto address = "unix:abstract=myadd"; try { server = Gio::DBus::Server::create_sync(address, @@ -200,7 +200,7 @@ int main(int, char**) server->signal_new_connection().connect(sigc::ptr_fun(&on_server_new_connection)); //Keep the server running until the process is killed: - Glib::RefPtr<Glib::MainLoop> loop = Glib::MainLoop::create(); + auto loop = Glib::MainLoop::create(); loop->run(); return EXIT_SUCCESS; diff --git a/examples/dbus/session_bus_service.cc b/examples/dbus/session_bus_service.cc index 0f0bd01d..dd735f61 100644 --- a/examples/dbus/session_bus_service.cc +++ b/examples/dbus/session_bus_service.cc @@ -35,7 +35,7 @@ namespace static Glib::RefPtr<Gio::DBus::NodeInfo> introspection_data; -static Glib::ustring introspection_xml = +static auto introspection_xml = "<node>" " <interface name='org.glibmm.DBusExample.Clock'>" " <method name='GetTime'>" @@ -65,12 +65,12 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& /* connect Glib::TimeVal curr_time; curr_time.assign_current_time(); - const Glib::ustring time_str = curr_time.as_iso8601(); - const Glib::Variant<Glib::ustring> time_var = + const auto time_str = curr_time.as_iso8601(); + const auto time_var = Glib::Variant<Glib::ustring>::create(time_str); // Create the tuple. - Glib::VariantContainerBase response = + auto response = Glib::VariantContainerBase::create_tuple(time_var); // Return the tuple with the included time. @@ -87,7 +87,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& /* connect parameters.get_child(param); // Get the time string. - const Glib::ustring time_str = param.get(); + const auto time_str = param.get(); if(!curr_alarm.assign_from_iso8601(time_str)) { @@ -163,7 +163,7 @@ int main(int, char**) sigc::ptr_fun(&on_name_lost)); //Keep the service running until the process is killed: - Glib::RefPtr<Glib::MainLoop> loop = Glib::MainLoop::create(); + auto loop = Glib::MainLoop::create(); loop->run(); Gio::DBus::unown_name(id); diff --git a/examples/iochannel_stream/fdstream.cc b/examples/iochannel_stream/fdstream.cc index be97676f..50e168eb 100644 --- a/examples/iochannel_stream/fdstream.cc +++ b/examples/iochannel_stream/fdstream.cc @@ -200,7 +200,7 @@ std::streamsize fdstreambuf::xsgetn(char* dest, std::streamsize num) // available would normally be 0, but could be up to 2 if there // have been putbacks or a peek and a putback - std::streamsize available = egptr() - gptr(); + auto available = egptr() - gptr(); // if num is less than or equal to the characters already in the // putback buffer, extract from buffer diff --git a/examples/keyfile/main.cc b/examples/keyfile/main.cc index 533bc532..4562044f 100644 --- a/examples/keyfile/main.cc +++ b/examples/keyfile/main.cc @@ -42,7 +42,7 @@ int main(int, char**) // An exception will be thrown if the value is not in the file: try { - const Glib::ustring value = keyfile.get_value("somegroup", "somekey"); + const auto value = keyfile.get_value("somegroup", "somekey"); std::cout << "somekey value=" << value << std::endl; } catch(const Glib::KeyFileError& ex) @@ -54,7 +54,7 @@ int main(int, char**) // An exception will be thrown if the value is not in the file: try { - const Glib::ustring value = keyfile.get_value("First Group", "Welcome"); + const auto value = keyfile.get_value("First Group", "Welcome"); std::cout << "Welcome value=" << value << std::endl; } catch(const Glib::KeyFileError& ex) @@ -66,9 +66,9 @@ int main(int, char**) // An exception will be thrown if the value is not in the file: try { - const std::vector<int> values = keyfile.get_integer_list("Another Group", "Numbers"); + const auto values = keyfile.get_integer_list("Another Group", "Numbers"); - for(std::vector<int>::const_iterator p = values.begin(); p != values.end(); ++p) + for(auto p = values.begin(); p != values.end(); ++p) std::cout << "Number list value: item=" << *p << std::endl; } catch(const Glib::KeyFileError& ex) diff --git a/examples/markup/parser.cc b/examples/markup/parser.cc index 30423a66..08e33422 100644 --- a/examples/markup/parser.cc +++ b/examples/markup/parser.cc @@ -32,13 +32,13 @@ void file_get_contents(const std::string& filename, Glib::ustring& contents) Glib::ustring trim_whitespace(const Glib::ustring& text) { - Glib::ustring::const_iterator pbegin (text.begin()); - Glib::ustring::const_iterator pend (text.end()); + auto pbegin (text.begin()); + auto pend (text.end()); while(pbegin != pend && Glib::Unicode::isspace(*pbegin)) ++pbegin; - Glib::ustring::const_iterator temp (pend); + auto temp (pend); while(pbegin != temp && Glib::Unicode::isspace(*--temp)) pend = temp; @@ -84,7 +84,7 @@ void DumpParser::on_start_element(Glib::Markup::ParseContext&, indent(); std::cout << '<' << element_name; - for(AttributeMap::const_iterator p = attributes.begin(); p != attributes.end(); ++p) + for(auto p = attributes.begin(); p != attributes.end(); ++p) { std::cout << ' ' << p->first << "=\"" << p->second << '"'; } @@ -104,7 +104,7 @@ void DumpParser::on_end_element(Glib::Markup::ParseContext&, const Glib::ustring void DumpParser::on_text(Glib::Markup::ParseContext&, const Glib::ustring& text) { - const Glib::ustring trimmed_text = trim_whitespace(text); + const auto trimmed_text = trim_whitespace(text); if(!trimmed_text.empty()) { diff --git a/examples/network/resolver.cc b/examples/network/resolver.cc index 4112c146..54196f69 100644 --- a/examples/network/resolver.cc +++ b/examples/network/resolver.cc @@ -95,7 +95,7 @@ print_resolved_addresses (const Glib::ustring& name, { G_LOCK (response); std::cout << Glib::ustring::compose ("Name: %1\n", name); - for (std::list<Glib::RefPtr<Gio::InetAddress> >::const_iterator iter = addresses.begin (); + for (auto iter = addresses.begin (); iter != addresses.end (); ++iter) { std::cout << Glib::ustring::compose ("Address: %1\n", (*iter)->to_string ()); @@ -112,7 +112,7 @@ print_resolved_service (const Glib::ustring& service, { G_LOCK (response); std::cout << Glib::ustring::compose ("Service: %1\n", service); - for (std::list<Gio::SrvTarget>::const_iterator iter = targets.begin (); + for (auto iter = targets.begin (); iter != targets.end (); ++iter) { std::cout << @@ -132,14 +132,14 @@ static std::vector<Glib::ustring> split_service_parts (const Glib::ustring& arg) { std::vector<Glib::ustring> parts; - std::size_t delim1 = 0; - std::size_t delim2 = 0; - delim1 = arg.find ('/', 0); + auto delim1 = arg.find ('/', 0); if (delim1 == std::string::npos) return parts; - delim2 = arg.find ('/', delim1 + 1); + + auto 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)); @@ -154,7 +154,7 @@ lookup_one_sync (const Glib::ustring& arg) { std::list<Gio::SrvTarget> targets; /* service/protocol/domain */ - std::vector<Glib::ustring> parts = split_service_parts (arg); + auto parts = split_service_parts (arg); if (parts.size () != 3) { usage (); return; @@ -173,10 +173,10 @@ lookup_one_sync (const Glib::ustring& arg) } else if (Gio::hostname_is_ip_address (arg)) { - Glib::RefPtr<Gio::InetAddress> addr = Gio::InetAddress::create (arg); + auto addr = Gio::InetAddress::create (arg); try { - Glib::ustring name = resolver->lookup_by_address (addr, cancellable); + const auto name = resolver->lookup_by_address (addr, cancellable); print_resolved_name (arg, name); } catch (const Gio::ResolverError& err) @@ -186,11 +186,9 @@ lookup_one_sync (const Glib::ustring& arg) } else { - std::list<Glib::RefPtr<Gio::InetAddress> > addresses; - try { - addresses = resolver->lookup_by_name (arg, cancellable); + const auto addresses = resolver->lookup_by_name (arg, cancellable); print_resolved_addresses (arg, addresses); } catch (const Gio::ResolverError& err) @@ -271,7 +269,7 @@ start_async_lookups (char **argv, int argc) if (arg.find ('/') != std::string::npos) { /* service/protocol/domain */ - std::vector<Glib::ustring> parts = split_service_parts (arg); + auto parts = split_service_parts (arg); if (parts.size () != 3) { usage (); return; @@ -286,7 +284,7 @@ start_async_lookups (char **argv, int argc) } else if (Gio::hostname_is_ip_address (argv[i])) { - Glib::RefPtr<Gio::InetAddress> addr = Gio::InetAddress::create (argv[i]); + auto addr = Gio::InetAddress::create (argv[i]); resolver->lookup_by_address_async (addr, sigc::bind (sigc::ptr_fun @@ -311,8 +309,7 @@ start_async_lookups (char **argv, int argc) static void print_connectable_sockaddr (Glib::RefPtr<Gio::SocketAddress> sockaddr) { - Glib::ustring phys; - Glib::RefPtr<Gio::InetSocketAddress> isa = + auto isa = Glib::RefPtr<Gio::InetSocketAddress>::cast_dynamic (sockaddr); if (!isa) @@ -323,7 +320,7 @@ print_connectable_sockaddr (Glib::RefPtr<Gio::SocketAddress> sockaddr) } else { - phys = isa->get_address ()->to_string (); + const auto phys = isa->get_address ()->to_string (); std::cout << Glib::ustring::compose ("Address: %1%2%3:%4\n", phys.find (':') != std::string::npos ? "[" : "", phys, @@ -382,14 +379,12 @@ Glib::RefPtr<Gio::SocketConnectable> global_connectable; static void do_connectable (const std::string& arg, gboolean synchronous) { - std::vector<Glib::ustring> parts; Glib::RefPtr<Gio::SocketConnectable> connectable; - Glib::RefPtr<Gio::SocketAddressEnumerator> enumerator; if (arg.find ('/') != std::string::npos) { /* service/protocol/domain */ - parts = split_service_parts (arg); + auto parts = split_service_parts (arg); if (parts.size () != 3) { usage (); return; @@ -421,7 +416,7 @@ do_connectable (const std::string& arg, gboolean synchronous) connectable = Gio::NetworkAddress::create (arg, port); } - enumerator = connectable->enumerate (); + auto enumerator = connectable->enumerate (); if (synchronous) do_sync_connectable (enumerator); @@ -435,9 +430,10 @@ static volatile int cancel_fd; static void interrupted (int /*sig*/) { - const int save_errno = errno; + const auto save_errno = errno; while (write(cancel_fd, "", 1) < 0 && errno == EINTR) {} + errno = save_errno; } diff --git a/examples/network/socket-client.cc b/examples/network/socket-client.cc index 29122573..44ed7046 100644 --- a/examples/network/socket-client.cc +++ b/examples/network/socket-client.cc @@ -28,18 +28,14 @@ static GOptionEntry cmd_entries[] = { Glib::ustring socket_address_to_string (const Glib::RefPtr<Gio::SocketAddress>& address) { - Glib::RefPtr<Gio::InetAddress> inet_address; - Glib::ustring str, res; - int port; - - Glib::RefPtr<Gio::InetSocketAddress> isockaddr = + auto isockaddr = Glib::RefPtr<Gio::InetSocketAddress>::cast_dynamic (address); if (!isockaddr) return Glib::ustring (); - inet_address = isockaddr->get_address (); - str = inet_address->to_string (); - port = isockaddr->get_port (); - res = Glib::ustring::compose ("%1:%2", str, port); + auto inet_address = isockaddr->get_address (); + auto str = inet_address->to_string (); + auto port = isockaddr->get_port (); + auto res = Glib::ustring::compose ("%1:%2", str, port); return res; } @@ -57,14 +53,12 @@ ensure_condition (const Glib::RefPtr<Gio::Socket>& socket, const Glib::RefPtr<Gio::Cancellable>& cancellable, Glib::IOCondition condition) { - GSource *source; - if (!non_blocking) return; if (use_source) { - source = g_socket_create_source (socket->gobj (), + auto source = g_socket_create_source (socket->gobj (), (GIOCondition) condition, cancellable->gobj ()); g_source_set_callback (source, @@ -103,14 +97,12 @@ main (int argc, Glib::RefPtr<Gio::SocketAddress> address; Gio::SocketType socket_type; GError *error = NULL; - GOptionContext *context; Glib::RefPtr<Gio::Cancellable> cancellable; - Glib::RefPtr<Gio::SocketAddressEnumerator> enumerator; Glib::RefPtr<Gio::SocketConnectable> connectable; Gio::init (); - context = g_option_context_new (" <hostname>[:port] - Test GSocket client stuff"); + auto context = g_option_context_new (" <hostname>[:port] - Test GSocket client stuff"); g_option_context_add_main_entries (context, cmd_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { @@ -156,7 +148,7 @@ main (int argc, return 1; } - enumerator = connectable->enumerate (); + auto enumerator = connectable->enumerate (); while (true) { try { diff --git a/examples/network/socket-server.cc b/examples/network/socket-server.cc index d5078596..597e7236 100644 --- a/examples/network/socket-server.cc +++ b/examples/network/socket-server.cc @@ -62,14 +62,12 @@ ensure_condition (const Glib::RefPtr<Gio::Socket>& socket, const Glib::RefPtr<Gio::Cancellable>& cancellable, Glib::IOCondition condition) { - GSource *source; - if (!non_blocking) return; if (use_source) { - source = g_socket_create_source (socket->gobj (), + const auto source = g_socket_create_source (socket->gobj (), (GIOCondition) condition, cancellable->gobj ()); g_source_set_callback (source, @@ -104,16 +102,14 @@ main (int argc, char *argv[]) { Glib::RefPtr<Gio::Socket> socket, new_socket, recv_socket; - Glib::RefPtr<Gio::SocketAddress> src_address; Glib::RefPtr<Gio::SocketAddress> address; Gio::SocketType socket_type; - GError *error = NULL; - GOptionContext *context; Glib::RefPtr<Gio::Cancellable> cancellable; + GError *error = NULL; Gio::init (); - context = g_option_context_new (" - Test GSocket server stuff"); + auto context = g_option_context_new (" - Test GSocket server stuff"); g_option_context_add_main_entries (context, cmd_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { @@ -145,7 +141,7 @@ main (int argc, if (non_blocking) socket->set_blocking (false); - src_address = Gio::InetSocketAddress::create (Gio::InetAddress::create_any ((Gio::SocketFamily) G_SOCKET_FAMILY_IPV4), port); + auto src_address = Gio::InetSocketAddress::create (Gio::InetAddress::create_any ((Gio::SocketFamily) G_SOCKET_FAMILY_IPV4), port); try { socket->bind (src_address, !dont_reuse_address); } catch (const Gio::Error& error) { @@ -181,7 +177,7 @@ main (int argc, new_socket->set_blocking (false); try { - address = new_socket->get_remote_address (); + address = new_socket->get_remote_address (); } catch (const Gio::Error& error) { std::cerr << Glib::ustring::compose ("Error getting remote address: %1\n", diff --git a/examples/options/main.cc b/examples/options/main.cc index ee524dac..f0f06699 100644 --- a/examples/options/main.cc +++ b/examples/options/main.cc @@ -222,7 +222,7 @@ int main(int argc, char** argv) //This one shows the results of multiple instance of the same option, such as --list=1 --list=a --list=b std::cout << " list = "; - for(Glib::OptionGroup::vecustrings::const_iterator iter = group.m_arg_list.begin(); iter != group.m_arg_list.end(); ++iter) + for(auto iter = group.m_arg_list.begin(); iter != group.m_arg_list.end(); ++iter) { std::cout << *iter << ", "; } @@ -230,7 +230,7 @@ int main(int argc, char** argv) //This one shows the remaining arguments on the command line, which had no name= form: std::cout << " remaining = "; - for(Glib::OptionGroup::vecustrings::const_iterator iter = group.m_remaining_list.begin(); iter != group.m_remaining_list.end(); ++iter) + for(auto iter = group.m_remaining_list.begin(); iter != group.m_remaining_list.end(); ++iter) { std::cout << *iter << ", "; } diff --git a/examples/properties/properties_example.cc b/examples/properties/properties_example.cc index 90111408..b12c7631 100644 --- a/examples/properties/properties_example.cc +++ b/examples/properties/properties_example.cc @@ -40,8 +40,10 @@ public: // the 'changed' signal, etc. Glib::PropertyProxy<Glib::ustring> property_firstname () { return prop_firstname.get_proxy (); } + Glib::PropertyProxy<Glib::ustring> property_lastname () { return prop_lastname.get_proxy (); } + Glib::PropertyProxy<int> property_age () { return prop_age.get_proxy (); } diff --git a/examples/regex/main.cc b/examples/regex/main.cc index cc128ab2..624b3284 100644 --- a/examples/regex/main.cc +++ b/examples/regex/main.cc @@ -24,7 +24,7 @@ int main(int, char**) Glib::init(); /* Reusing one regex pattern: */ - Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("(a)?(b)"); + auto regex = Glib::Regex::create("(a)?(b)"); std::cout << "Pattern=" << regex->get_pattern() << ", with string=abcd, result=" << std::boolalpha << regex->match("abcd") diff --git a/examples/settings/settings.cc b/examples/settings/settings.cc index b7ce0ca5..8ab588d2 100644 --- a/examples/settings/settings.cc +++ b/examples/settings/settings.cc @@ -30,7 +30,7 @@ static void on_key_changed(const Glib::ustring& key, const Glib::RefPtr<Gio::Set std::cout << Glib::ustring::compose("'%1' changed\n", key); if (key == STRING_KEY) { - Glib::ustring str = settings->get_string(key); + auto str = settings->get_string(key); std::cout << Glib::ustring::compose("New value of '%1': '%2'\n", key, str); @@ -63,7 +63,7 @@ int main(int, char**) Glib::setenv("GSETTINGS_SCHEMA_DIR", ".", true); Glib::setenv("GSETTINGS_BACKEND", "memory", true); - const Glib::RefPtr<Gio::Settings> settings = + const auto settings = Gio::Settings::create("org.gtkmm.demo"); settings->signal_changed().connect(sigc::bind(sigc::ptr_fun(&on_key_changed), settings)); diff --git a/examples/thread/dispatcher.cc b/examples/thread/dispatcher.cc index 21833e7f..5e11fa96 100644 --- a/examples/thread/dispatcher.cc +++ b/examples/thread/dispatcher.cc @@ -152,7 +152,7 @@ Application::Application() { for (std::vector<ThreadProgress*>::size_type i = 0; i < progress_threads_.size(); ++i) { - ThreadProgress *const progress = new ThreadProgress(i + 1); + const auto progress = new ThreadProgress(i + 1); progress_threads_[i] = progress; progress->signal_finished().connect( diff --git a/examples/thread/dispatcher2.cc b/examples/thread/dispatcher2.cc index dd7d7de8..ac909c88 100644 --- a/examples/thread/dispatcher2.cc +++ b/examples/thread/dispatcher2.cc @@ -156,9 +156,10 @@ bool ThreadTimer::timeout_handler() void ThreadTimer::thread_function() { // create a new Main Context - Glib::RefPtr<Glib::MainContext> context = Glib::MainContext::create(); + auto context = Glib::MainContext::create(); + // create a new Main Loop - Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(context, true); + auto mainloop = Glib::MainLoop::create(context, true); // attach a timeout handler, that is called every second, to the // newly created MainContext diff --git a/examples/thread/thread.cc b/examples/thread/thread.cc index ad7cfebd..5601e8c3 100644 --- a/examples/thread/thread.cc +++ b/examples/thread/thread.cc @@ -70,7 +70,7 @@ void MessageQueue::consumer() while(queue_.empty()) cond_push_.wait(mutex_); - const int i = queue_.front(); + const auto i = queue_.front(); queue_.pop(); std::cout << "\x08 \x08"; std::cout.flush(); @@ -97,10 +97,10 @@ int main(int, char**) MessageQueue queue; - Glib::Threads::Thread *const producer = Glib::Threads::Thread::create( + const auto producer = Glib::Threads::Thread::create( sigc::mem_fun(queue, &MessageQueue::producer)); - Glib::Threads::Thread *const consumer = Glib::Threads::Thread::create( + const auto consumer = Glib::Threads::Thread::create( sigc::mem_fun(queue, &MessageQueue::consumer)); producer->join(); |