[glibmm/c++11] C++11: examples: Use nullptr.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/c++11] C++11: examples: Use nullptr.
- Date: Thu, 27 Jun 2013 08:25:35 +0000 (UTC)
commit cd56987eac7865a76f75019bc54b7581ed69889e
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Jun 27 10:25:21 2013 +0200
C++11: examples: Use nullptr.
examples/child_watch/main.cc | 2 +-
examples/iochannel_stream/fdstream.cc | 8 ++++----
examples/network/resolver.cc | 2 +-
examples/network/socket-client.cc | 18 +++++++++---------
examples/network/socket-server.cc | 22 +++++++++++-----------
examples/thread/dispatcher.cc | 4 ++--
examples/thread/dispatcher2.cc | 10 +++++-----
glib/glibmm/utility.h | 2 +-
8 files changed, 34 insertions(+), 34 deletions(-)
---
diff --git a/examples/child_watch/main.cc b/examples/child_watch/main.cc
index 5e9fb67..007490b 100644
--- a/examples/child_watch/main.cc
+++ b/examples/child_watch/main.cc
@@ -40,7 +40,7 @@ void ChildWatch::run()
{
auto pid = fork();
- if(pid==0)
+ if(!pid)
{
sleep(5);
exit(0);
diff --git a/examples/iochannel_stream/fdstream.cc b/examples/iochannel_stream/fdstream.cc
index 50e168e..4ce1fce 100644
--- a/examples/iochannel_stream/fdstream.cc
+++ b/examples/iochannel_stream/fdstream.cc
@@ -280,8 +280,8 @@ std::streamsize fdstreambuf::xsgetn(char* dest, std::streamsize num)
}
fdstream::fdstream(int fd, bool manage)
-: std::istream(0),
- std::ostream(0),
+: std::istream(nullptr),
+ std::ostream(nullptr),
buf(fd, manage)
{
std::istream::rdbuf(&buf);
@@ -289,8 +289,8 @@ fdstream::fdstream(int fd, bool manage)
}
fdstream::fdstream()
-: std::istream(0),
- std::ostream(0)
+: std::istream(nullptr),
+ std::ostream(nullptr)
{
std::istream::rdbuf(&buf);
std::ostream::rdbuf(&buf);
diff --git a/examples/network/resolver.cc b/examples/network/resolver.cc
index 276b155..6a5b51f 100644
--- a/examples/network/resolver.cc
+++ b/examples/network/resolver.cc
@@ -400,7 +400,7 @@ do_connectable (const std::string& arg, gboolean synchronous)
{
host = arg.substr (0, pos);
port_str = arg.substr(pos);
- port = strtoul (port_str.c_str (), NULL, 10);
+ port = strtoul (port_str.c_str (), nullptr, 10);
}
else
port = 0;
diff --git a/examples/network/socket-client.cc b/examples/network/socket-client.cc
index 44ed704..505df6b 100644
--- a/examples/network/socket-client.cc
+++ b/examples/network/socket-client.cc
@@ -13,15 +13,15 @@ int cancel_timeout = 0;
static GOptionEntry cmd_entries[] = {
{"cancel", 'c', 0, G_OPTION_ARG_INT, &cancel_timeout,
- "Cancel any op after the specified amount of seconds", NULL},
+ "Cancel any op after the specified amount of seconds", nullptr},
{"udp", 'u', 0, G_OPTION_ARG_NONE, &use_udp,
- "Use udp instead of tcp", NULL},
+ "Use udp instead of tcp", nullptr},
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
- "Be verbose", NULL},
+ "Be verbose", nullptr},
{"non-blocking", 'n', 0, G_OPTION_ARG_NONE, &non_blocking,
- "Enable non-blocking i/o", NULL},
+ "Enable non-blocking i/o", nullptr},
{"use-source", 's', 0, G_OPTION_ARG_NONE, &use_source,
- "Use GSource to wait for non-blocking i/o", NULL},
+ "Use GSource to wait for non-blocking i/o", nullptr},
{0, 0, 0, G_OPTION_ARG_NONE, 0, 0, 0}
};
@@ -63,8 +63,8 @@ ensure_condition (const Glib::RefPtr<Gio::Socket>& socket,
cancellable->gobj ());
g_source_set_callback (source,
(GSourceFunc) source_ready,
- NULL, NULL);
- g_source_attach (source, NULL);
+ nullptr, nullptr);
+ g_source_attach (source, nullptr);
loop->run ();
}
else
@@ -96,14 +96,14 @@ main (int argc,
Glib::RefPtr<Gio::SocketAddress> src_address;
Glib::RefPtr<Gio::SocketAddress> address;
Gio::SocketType socket_type;
- GError *error = NULL;
+ GError *error = nullptr;
Glib::RefPtr<Gio::Cancellable> cancellable;
Glib::RefPtr<Gio::SocketConnectable> connectable;
Gio::init ();
auto context = g_option_context_new (" <hostname>[:port] - Test GSocket client stuff");
- g_option_context_add_main_entries (context, cmd_entries, NULL);
+ g_option_context_add_main_entries (context, cmd_entries, nullptr);
if (!g_option_context_parse (context, &argc, &argv, &error))
{
std::cerr << Glib::ustring::compose ("%1: %2\n", argv[0], error->message);
diff --git a/examples/network/socket-server.cc b/examples/network/socket-server.cc
index 597e723..12cb2cb 100644
--- a/examples/network/socket-server.cc
+++ b/examples/network/socket-server.cc
@@ -14,19 +14,19 @@ int cancel_timeout = 0;
static GOptionEntry cmd_entries[] = {
{"port", 'p', 0, G_OPTION_ARG_INT, &port,
- "Local port to bind to", NULL},
+ "Local port to bind to", nullptr},
{"cancel", 'c', 0, G_OPTION_ARG_INT, &cancel_timeout,
- "Cancel any op after the specified amount of seconds", NULL},
+ "Cancel any op after the specified amount of seconds", nullptr},
{"udp", 'u', 0, G_OPTION_ARG_NONE, &use_udp,
- "Use udp instead of tcp", NULL},
+ "Use udp instead of tcp", nullptr},
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
- "Be verbose", NULL},
+ "Be verbose", nullptr},
{"no-reuse", 0, 0, G_OPTION_ARG_NONE, &dont_reuse_address,
- "Don't SOADDRREUSE", NULL},
+ "Don't SOADDRREUSE", nullptr},
{"non-blocking", 'n', 0, G_OPTION_ARG_NONE, &non_blocking,
- "Enable non-blocking i/o", NULL},
+ "Enable non-blocking i/o", nullptr},
{"use-source", 's', 0, G_OPTION_ARG_NONE, &use_source,
- "Use GSource to wait for non-blocking i/o", NULL},
+ "Use GSource to wait for non-blocking i/o", nullptr},
{0, 0, 0, G_OPTION_ARG_NONE, 0, 0, 0}
};
@@ -72,8 +72,8 @@ ensure_condition (const Glib::RefPtr<Gio::Socket>& socket,
cancellable->gobj ());
g_source_set_callback (source,
(GSourceFunc) source_ready,
- NULL, NULL);
- g_source_attach (source, NULL);
+ nullptr, nullptr);
+ g_source_attach (source, nullptr);
loop->run ();
}
else
@@ -105,12 +105,12 @@ main (int argc,
Glib::RefPtr<Gio::SocketAddress> address;
Gio::SocketType socket_type;
Glib::RefPtr<Gio::Cancellable> cancellable;
- GError *error = NULL;
+ GError *error = nullptr;
Gio::init ();
auto context = g_option_context_new (" - Test GSocket server stuff");
- g_option_context_add_main_entries (context, cmd_entries, NULL);
+ g_option_context_add_main_entries (context, cmd_entries, nullptr);
if (!g_option_context_parse (context, &argc, &argv, &error))
{
std::cerr << Glib::ustring::compose ("%1: %1\n", argv[0], error->message);
diff --git a/examples/thread/dispatcher.cc b/examples/thread/dispatcher.cc
index 5e11fa9..5f69440 100644
--- a/examples/thread/dispatcher.cc
+++ b/examples/thread/dispatcher.cc
@@ -80,7 +80,7 @@ public:
ThreadProgress::ThreadProgress(int id)
:
- thread_ (0),
+ thread_ (nullptr),
id_ (id),
progress_ (0)
{
@@ -91,7 +91,7 @@ ThreadProgress::ThreadProgress(int id)
ThreadProgress::~ThreadProgress()
{
// It is an error if the thread is still running at this point.
- g_return_if_fail(thread_ == 0);
+ g_return_if_fail(thread_ == nullptr);
}
int ThreadProgress::id() const
diff --git a/examples/thread/dispatcher2.cc b/examples/thread/dispatcher2.cc
index ac909c8..985b295 100644
--- a/examples/thread/dispatcher2.cc
+++ b/examples/thread/dispatcher2.cc
@@ -77,7 +77,7 @@ ThreadTimer::ThreadTimer()
// Create a new Glib::Dispatcher that is attached to the default main context,
signal_increment_ (),
// This pointer will be initialized later by the 2nd thread.
- signal_finished_ptr_ (NULL)
+ signal_finished_ptr_ (nullptr)
{
// Connect the cross-thread signal.
signal_increment_.connect(sigc::mem_fun(*this, &ThreadTimer::timer_increment));
@@ -99,7 +99,7 @@ void ThreadTimer::launch()
sigc::mem_fun(*this, &ThreadTimer::thread_function));
// Wait for the 2nd thread's startup notification.
- while(signal_finished_ptr_ == NULL)
+ while(!signal_finished_ptr_)
startup_cond_.wait(startup_mutex_);
}
@@ -109,10 +109,10 @@ void ThreadTimer::signal_finished_emit()
signal_finished_ptr_->emit();
// wait for the thread to join
- if(thread_ != NULL)
+ if(thread_)
thread_->join();
- signal_finished_ptr_ = NULL;
+ signal_finished_ptr_ = nullptr;
}
void ThreadTimer::print() const
@@ -190,7 +190,7 @@ ThreadTimer::type_signal_end ThreadTimer::signal_end_;
ThreadDispatcher::ThreadDispatcher()
:
- timer_ (NULL)
+ timer_ (nullptr)
{
std::cout << "Thread Dispatcher Example #2" << std::endl;
diff --git a/glib/glibmm/utility.h b/glib/glibmm/utility.h
index 723418d..abb4535 100644
--- a/glib/glibmm/utility.h
+++ b/glib/glibmm/utility.h
@@ -30,7 +30,7 @@
* GLIBMM_INITIALIZE_STRUCT(Var, Type) is provided. It even avoids creating
* a temporary if the compiler is GCC.
*/
-#if ((__GNUC__ >= 3) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) && !defined(__STRICT_ANSI__)
+#if ((__GNUC__ >= 3) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
#define GLIBMM_INITIALIZE_STRUCT(Var, Type) __builtin_memset(&(Var), 0, sizeof(Type))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]