From 2ded50396f73e5221f38359dbd40620c9ea6dfc5 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Tue, 29 May 2012 07:23:55 +1000 Subject: [PATCH] Add support for g++ 4.7 when compiling in C++11 mode. --- asio/boostify.pl | 4 ++++ asio/include/asio/detail/config.hpp | 18 +++++++++++++++++- asio/include/asio/impl/error.ipp | 6 +++--- asio/include/asio/impl/error_code.ipp | 2 +- asio/include/asio/ssl/impl/error.ipp | 2 +- asio/src/doc/history.qbk | 2 ++ 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/asio/boostify.pl b/asio/boostify.pl index 144b1cac..e4b6dd02 100755 --- a/asio/boostify.pl +++ b/asio/boostify.pl @@ -121,6 +121,10 @@ sub copy_source_file { $line =~ s/asio_detail_posix_thread_function/boost_asio_detail_posix_thread_function/g; } + if ($line =~ /const ASIO_ERROR_CATEGORY_NOEXCEPT$/) + { + $line =~ s/ ASIO_ERROR_CATEGORY_NOEXCEPT$//; + } if ($line =~ /ASIO_/ && !($line =~ /BOOST_ASIO_/)) { $line =~ s/ASIO_/BOOST_ASIO_/g; diff --git a/asio/include/asio/detail/config.hpp b/asio/include/asio/detail/config.hpp index 86e110df..62829343 100644 --- a/asio/include/asio/detail/config.hpp +++ b/asio/include/asio/detail/config.hpp @@ -112,6 +112,20 @@ # endif // defined(__GNUC__) #endif // !defined(ASIO_DISABLE_STD_SYSTEM_ERROR) +// Compliant C++11 compilers put noexcept specifiers on error_category members. +#if !defined(ASIO_ERROR_CATEGORY_NOEXCEPT) +# if defined(__GNUC__) +# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4) +# if defined(__GXX_EXPERIMENTAL_CXX0X__) +# define ASIO_ERROR_CATEGORY_NOEXCEPT noexcept(true) +# endif // defined(__GXX_EXPERIMENTAL_CXX0X__) +# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4) +# endif // defined(__GNUC__) +# if !defined(ASIO_ERROR_CATEGORY_NOEXCEPT) +# define ASIO_ERROR_CATEGORY_NOEXCEPT +# endif // !defined(ASIO_ERROR_CATEGORY_NOEXCEPT) +#endif // !defined(ASIO_ERROR_CATEGORY_NOEXCEPT) + // Standard library support for arrays. #if !defined(ASIO_DISABLE_STD_ARRAY) # if defined(__GNUC__) @@ -163,7 +177,9 @@ # if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4) # if defined(__GXX_EXPERIMENTAL_CXX0X__) # define ASIO_HAS_STD_CHRONO -# define ASIO_HAS_STD_CHRONO_MONOTONIC_CLOCK +# if ((__GNUC__ == 4) && (__GNUC_MINOR__ == 6)) +# define ASIO_HAS_STD_CHRONO_MONOTONIC_CLOCK +# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ == 6)) # endif // defined(__GXX_EXPERIMENTAL_CXX0X__) # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4) # endif // defined(__GNUC__) diff --git a/asio/include/asio/impl/error.ipp b/asio/include/asio/impl/error.ipp index 836b2005..74488130 100644 --- a/asio/include/asio/impl/error.ipp +++ b/asio/include/asio/impl/error.ipp @@ -30,7 +30,7 @@ namespace detail { class netdb_category : public asio::error_category { public: - const char* name() const + const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT { return "asio.netdb"; } @@ -62,7 +62,7 @@ namespace detail { class addrinfo_category : public asio::error_category { public: - const char* name() const + const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT { return "asio.addrinfo"; } @@ -92,7 +92,7 @@ namespace detail { class misc_category : public asio::error_category { public: - const char* name() const + const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT { return "asio.misc"; } diff --git a/asio/include/asio/impl/error_code.ipp b/asio/include/asio/impl/error_code.ipp index e9e326ca..a9db6fa6 100644 --- a/asio/include/asio/impl/error_code.ipp +++ b/asio/include/asio/impl/error_code.ipp @@ -34,7 +34,7 @@ namespace detail { class system_category : public error_category { public: - const char* name() const + const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT { return "asio.system"; } diff --git a/asio/include/asio/ssl/impl/error.ipp b/asio/include/asio/ssl/impl/error.ipp index a9fd2c4d..a092241b 100644 --- a/asio/include/asio/ssl/impl/error.ipp +++ b/asio/include/asio/ssl/impl/error.ipp @@ -29,7 +29,7 @@ namespace detail { class ssl_category : public asio::error_category { public: - const char* name() const + const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT { return "asio.ssl"; } diff --git a/asio/src/doc/history.qbk b/asio/src/doc/history.qbk index 8a3773fd..9066d313 100644 --- a/asio/src/doc/history.qbk +++ b/asio/src/doc/history.qbk @@ -23,6 +23,8 @@ * Improved the performance of strand rescheduling. +* Added support for [^g++] 4.7 when compiling in C++11 mode. + [heading Asio 1.8.0] * Added a new class template `basic_waitable_timer` based around the C++11 clock