From b9fbd88eb6076223ecab2c9e36c2d63c290155c5 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 7 Oct 2009 13:27:27 +0000 Subject: [PATCH 01/30] System: minor code clean up [SVN r56631] --- include/boost/system/error_code.hpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 87f255d..37d73e2 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -183,11 +183,14 @@ namespace boost { public: virtual ~error_category(){} - virtual inline const char * name() const; // see implementation note below - virtual inline std::string message( int ev ) const; // see implementation note below - virtual inline error_condition default_error_condition( int ev ) const; - virtual inline bool equivalent( int code, const error_condition & condition ) const; - virtual inline bool equivalent( const error_code & code, int condition ) const; + + virtual const char * name() const = 0; + virtual std::string message( int ev ) const = 0; + virtual error_condition default_error_condition( int ev ) const; + virtual bool equivalent( int code, + const error_condition & condition ) const; + virtual bool equivalent( const error_code & code, + int condition ) const; bool operator==(const error_category & rhs) const { return this == &rhs; } bool operator!=(const error_category & rhs) const { return this != &rhs; } @@ -496,19 +499,6 @@ namespace boost return *this == code.category() && code.value() == condition; } - // error_category implementation note: VC++ 8.0 objects to name() and - // message() being pure virtual functions. Thus these implementations. - inline const char * error_category::name() const - { - return "error: should never be called"; - } - - inline std::string error_category::message( int ) const - { - static std::string s("error: should never be called"); - return s; - } - } // namespace system } // namespace boost From f096d171766d2099f4b8a0b60396befe6b25722a Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 02:07:38 +0000 Subject: [PATCH 02/30] rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back [SVN r56942] --- CMakeLists.txt | 27 --------------------------- module.cmake | 1 - src/CMakeLists.txt | 13 ------------- 3 files changed, 41 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 module.cmake delete mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index b4f92f3..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -#---------------------------------------------------------------------------- -# This file was automatically generated from the original CMakeLists.txt file -# Add a variable to hold the headers for the library -set (lib_headers - system -) - -# Add a library target to the build system -boost_library_project( - system - SRCDIRS src - # TESTDIRS - HEADERS ${lib_headers} - # DOCDIRS - # DESCRIPTION - MODULARIZED - # AUTHORS - # MAINTAINERS -) - - diff --git a/module.cmake b/module.cmake deleted file mode 100644 index 9a50a96..0000000 --- a/module.cmake +++ /dev/null @@ -1 +0,0 @@ -boost_module(system DEPENDS utility) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 999684f..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -boost_add_library( - boost_system - error_code.cpp - SHARED_COMPILE_FLAGS "-DBOOST_SYSTEM_DYN_LINK=1" - STATIC_COMPILE_FLAGS "-DBOOST_SYSTEM_STATIC_LINK=1" - ) - From 6a925690ca6c2032934e2eec5fed96faedbb66d3 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 10 Nov 2009 19:31:24 +0000 Subject: [PATCH 03/30] System: Correct too_many_symbolic_link_levels misspelling. Fix #3559. [SVN r57553] --- include/boost/system/error_code.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 37d73e2..d0eb6c5 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -129,7 +129,7 @@ namespace boost too_many_files_open_in_system = ENFILE, too_many_files_open = EMFILE, too_many_links = EMLINK, - too_many_synbolic_link_levels = ELOOP, + too_many_symbolic_link_levels = ELOOP, value_too_large = EOVERFLOW, wrong_protocol_type = EPROTOTYPE }; From d493021c7d6ff036cbe76651785093c752af77ce Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Thu, 12 Nov 2009 20:42:09 +0000 Subject: [PATCH 04/30] System: fix too_many_symbolic_link_levels typo [SVN r57615] --- src/error_code.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error_code.cpp b/src/error_code.cpp index 3eb6a21..fa2cb0b 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -193,7 +193,7 @@ namespace case EIO: return make_error_condition( io_error ); case EISCONN: return make_error_condition( already_connected ); case EISDIR: return make_error_condition( is_a_directory ); - case ELOOP: return make_error_condition( too_many_synbolic_link_levels ); + case ELOOP: return make_error_condition( too_many_symbolic_link_levels ); case EMFILE: return make_error_condition( too_many_files_open ); case EMLINK: return make_error_condition( too_many_links ); case EMSGSIZE: return make_error_condition( message_size ); From 2f6659f39e8d32a4265039c2ae7d49a9205a58dd Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 13 Feb 2010 17:08:39 +0000 Subject: [PATCH 05/30] Fix #3927 [SVN r59673] --- include/boost/system/system_error.hpp | 7 +- test/error_code_test.cpp | 146 +++++++++--------- test/system_error_test.cpp | 15 +- test/system_msvc/common.vsprops | 1 + .../error_code_test/error_code_test.vcproj | 4 +- test/system_msvc/system_msvc.sln | 6 + 6 files changed, 97 insertions(+), 82 deletions(-) diff --git a/include/boost/system/system_error.hpp b/include/boost/system/system_error.hpp index 4091647..3e83500 100644 --- a/include/boost/system/system_error.hpp +++ b/include/boost/system/system_error.hpp @@ -62,11 +62,8 @@ namespace boost try { m_what = this->std::runtime_error::what(); - if ( m_error_code ) - { - if ( !m_what.empty() ) m_what += ": "; - m_what += m_error_code.message(); - } + if ( !m_what.empty() ) m_what += ": "; + m_what += m_error_code.message(); } catch (...) { return std::runtime_error::what(); } } diff --git a/test/error_code_test.cpp b/test/error_code_test.cpp index 69f6c3c..4870b2d 100644 --- a/test/error_code_test.cpp +++ b/test/error_code_test.cpp @@ -7,7 +7,10 @@ // See library home page at http://www.boost.org/libs/system -//----------------------------------------------------------------------------// +//----------------------------------------------------------------------------// + +// test without deprecated features +#define BOOST_SYSTEM_NO_DEPRECATED #include @@ -59,31 +62,31 @@ int main( int, char ** ) std::cout << "General tests...\n"; // unit tests: - BOOST_TEST( posix_category == posix_category ); + BOOST_TEST( generic_category == generic_category ); BOOST_TEST( system_category == system_category ); - BOOST_TEST( posix_category != system_category ); - BOOST_TEST( system_category != posix_category ); + BOOST_TEST( generic_category != system_category ); + BOOST_TEST( system_category != generic_category ); - if ( std::less()( &posix_category, &system_category ) ) + if ( std::less()( &generic_category, &system_category ) ) { - BOOST_TEST( posix_category < system_category ); - BOOST_TEST( !(system_category < posix_category) ); + BOOST_TEST( generic_category < system_category ); + BOOST_TEST( !(system_category < generic_category) ); } else { - BOOST_TEST( system_category < posix_category ); - BOOST_TEST( !(posix_category < system_category) ); + BOOST_TEST( system_category < generic_category ); + BOOST_TEST( !(generic_category < system_category) ); } error_code ec; - error_condition dec; + error_condition econd; BOOST_TEST( !ec ); BOOST_TEST( ec.value() == 0 ); - dec = ec.default_error_condition(); - BOOST_TEST( dec.value() == 0 ); - BOOST_TEST( dec.category() == posix_category ); - BOOST_TEST( ec == posix::success ); + econd = ec.default_error_condition(); + BOOST_TEST( econd.value() == 0 ); + BOOST_TEST( econd.category() == generic_category ); + BOOST_TEST( ec == errc::success ); BOOST_TEST( ec.category() == system_category ); BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 ); BOOST_TEST( !(ec < error_code( 0, system_category )) ); @@ -94,10 +97,10 @@ int main( int, char ** ) error_code ec_0_system( 0, system_category ); BOOST_TEST( !ec_0_system ); BOOST_TEST( ec_0_system.value() == 0 ); - dec = ec_0_system.default_error_condition(); - BOOST_TEST( dec.value() == 0 ); - BOOST_TEST( dec.category() == posix_category ); - BOOST_TEST( ec_0_system == posix::success ); + econd = ec_0_system.default_error_condition(); + BOOST_TEST( econd.value() == 0 ); + BOOST_TEST( econd.category() == generic_category ); + BOOST_TEST( ec_0_system == errc::success ); BOOST_TEST( ec_0_system.category() == system_category ); BOOST_TEST( std::strcmp( ec_0_system.category().name(), "system") == 0 ); check_ostream( ec_0_system, "system:0" ); @@ -115,38 +118,40 @@ int main( int, char ** ) ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category ); BOOST_TEST( ec ); BOOST_TEST( ec.value() == BOOST_ACCESS_ERROR_MACRO ); - dec = ec.default_error_condition(); - BOOST_TEST( dec.value() == static_cast(posix::permission_denied) ); - BOOST_TEST( dec.category() == posix_category ); - BOOST_TEST( dec == error_condition( posix::permission_denied, posix_category ) ); - BOOST_TEST( dec == posix::permission_denied ); - BOOST_TEST( posix::permission_denied == dec ); - BOOST_TEST( ec == posix::permission_denied ); + econd = ec.default_error_condition(); + BOOST_TEST( econd.value() == static_cast(errc::permission_denied) ); + BOOST_TEST( econd.category() == generic_category ); + BOOST_TEST( econd == error_condition( errc::permission_denied, generic_category ) ); + BOOST_TEST( econd == errc::permission_denied ); + BOOST_TEST( errc::permission_denied == econd ); + BOOST_TEST( ec == errc::permission_denied ); BOOST_TEST( ec.category() == system_category ); BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 ); - // test the explicit make_error_code conversion for posix - ec = make_error_code( posix::bad_message ); + // test the explicit make_error_code conversion for errc + ec = make_error_code( errc::bad_message ); BOOST_TEST( ec ); - BOOST_TEST( ec == posix::bad_message ); - BOOST_TEST( posix::bad_message == ec ); - BOOST_TEST( ec != posix::permission_denied ); - BOOST_TEST( posix::permission_denied != ec ); - BOOST_TEST( ec.category() == posix_category ); + BOOST_TEST( ec == errc::bad_message ); + BOOST_TEST( errc::bad_message == ec ); + BOOST_TEST( ec != errc::permission_denied ); + BOOST_TEST( errc::permission_denied != ec ); + BOOST_TEST( ec.category() == generic_category ); - // test the deprecated predefined error_category synonyms - BOOST_TEST( &system_category == &native_ecat ); - BOOST_TEST( &posix_category == &errno_ecat ); - BOOST_TEST( system_category == native_ecat ); - BOOST_TEST( posix_category == errno_ecat ); + //// test the deprecated predefined error_category synonyms + //BOOST_TEST( &system_category == &native_ecat ); + //BOOST_TEST( &generic_category == &errno_ecat ); + //BOOST_TEST( system_category == native_ecat ); + //BOOST_TEST( generic_category == errno_ecat ); // test error_code and error_condition message(); // see Boost.Filesystem operations_test for code specific message() tests ec = error_code( -1, system_category ); std::cout << "error_code message for -1 is \"" << ec.message() << "\"\n"; + std::cout << "error_code message for 0 is \"" << ec_0_system.message() << "\"\n"; #if defined(BOOST_WINDOWS_API) // Borland appends newline, so just check text BOOST_TEST( ec.message().substr(0,13) == "Unknown error" ); + BOOST_TEST( ec_0_system.message().substr(0,36) == "The operation completed successfully" ); #elif defined(linux) || defined(__linux) || defined(__linux__) // Linux appends value to message as unsigned, so it varies with # of bits BOOST_TEST( ec.message().substr(0,13) == "Unknown error" ); @@ -162,63 +167,66 @@ int main( int, char ** ) BOOST_TEST( ec.message() != "" ); BOOST_TEST( ec.message().substr( 0, 13) != "Unknown error" ); - dec = error_condition( -1, posix_category ); - std::cout << "error_condition message for -1 is \"" << dec.message() << "\"\n"; + econd = error_condition( -1, generic_category ); + error_condition econd_ok; + std::cout << "error_condition message for -1 is \"" << econd.message() << "\"\n"; + std::cout << "error_condition message for 0 is \"" << econd_ok.message() << "\"\n"; #if defined(BOOST_WINDOWS_API) // Borland appends newline, so just check text - BOOST_TEST( dec.message().substr(0,13) == "Unknown error" ); + BOOST_TEST( econd.message().substr(0,13) == "Unknown error" ); + BOOST_TEST( econd_ok.message().substr(0,8) == "No error" ); #elif defined(linux) || defined(__linux) || defined(__linux__) // Linux appends value to message as unsigned, so it varies with # of bits - BOOST_TEST( dec.message().substr(0,13) == "Unknown error" ); + BOOST_TEST( econd.message().substr(0,13) == "Unknown error" ); #elif defined(__hpux) - BOOST_TEST( dec.message() == "" ); + BOOST_TEST( econd.message() == "" ); #elif defined(__osf__) - BOOST_TEST( dec.message() == "Error -1 occurred." ); + BOOST_TEST( econd.message() == "Error -1 occurred." ); #elif defined(__vms) - BOOST_TEST( dec.message() == "error -1" ); + BOOST_TEST( econd.message() == "error -1" ); #endif - dec = error_condition( BOOST_ACCESS_ERROR_MACRO, posix_category ); - BOOST_TEST( dec.message() != "" ); - BOOST_TEST( dec.message().substr( 0, 13) != "Unknown error" ); + econd = error_condition( BOOST_ACCESS_ERROR_MACRO, generic_category ); + BOOST_TEST( econd.message() != "" ); + BOOST_TEST( econd.message().substr( 0, 13) != "Unknown error" ); #ifdef BOOST_WINDOWS_API std::cout << "Windows tests...\n"; - // these tests probe the Windows posix decoder + // these tests probe the Windows errc decoder // test the first entry in the decoder table: ec = error_code( ERROR_ACCESS_DENIED, system_category ); BOOST_TEST( ec.value() == ERROR_ACCESS_DENIED ); - BOOST_TEST( ec == posix::permission_denied ); - BOOST_TEST( ec.default_error_condition().value() == posix::permission_denied ); - BOOST_TEST( ec.default_error_condition().category() == posix_category ); + BOOST_TEST( ec == errc::permission_denied ); + BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied ); + BOOST_TEST( ec.default_error_condition().category() == generic_category ); // test the second entry in the decoder table: ec = error_code( ERROR_ALREADY_EXISTS, system_category ); BOOST_TEST( ec.value() == ERROR_ALREADY_EXISTS ); - BOOST_TEST( ec == posix::file_exists ); - BOOST_TEST( ec.default_error_condition().value() == posix::file_exists ); - BOOST_TEST( ec.default_error_condition().category() == posix_category ); + BOOST_TEST( ec == errc::file_exists ); + BOOST_TEST( ec.default_error_condition().value() == errc::file_exists ); + BOOST_TEST( ec.default_error_condition().category() == generic_category ); // test the third entry in the decoder table: ec = error_code( ERROR_BAD_UNIT, system_category ); BOOST_TEST( ec.value() == ERROR_BAD_UNIT ); - BOOST_TEST( ec == posix::no_such_device ); - BOOST_TEST( ec.default_error_condition().value() == posix::no_such_device ); - BOOST_TEST( ec.default_error_condition().category() == posix_category ); + BOOST_TEST( ec == errc::no_such_device ); + BOOST_TEST( ec.default_error_condition().value() == errc::no_such_device ); + BOOST_TEST( ec.default_error_condition().category() == generic_category ); // test the last non-Winsock entry in the decoder table: ec = error_code( ERROR_WRITE_PROTECT, system_category ); BOOST_TEST( ec.value() == ERROR_WRITE_PROTECT ); - BOOST_TEST( ec == posix::permission_denied ); - BOOST_TEST( ec.default_error_condition().value() == posix::permission_denied ); - BOOST_TEST( ec.default_error_condition().category() == posix_category ); + BOOST_TEST( ec == errc::permission_denied ); + BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied ); + BOOST_TEST( ec.default_error_condition().category() == generic_category ); // test the last Winsock entry in the decoder table: ec = error_code( WSAEWOULDBLOCK, system_category ); BOOST_TEST( ec.value() == WSAEWOULDBLOCK ); - BOOST_TEST( ec == posix::operation_would_block ); - BOOST_TEST( ec.default_error_condition().value() == posix::operation_would_block ); - BOOST_TEST( ec.default_error_condition().category() == posix_category ); + BOOST_TEST( ec == errc::operation_would_block ); + BOOST_TEST( ec.default_error_condition().value() == errc::operation_would_block ); + BOOST_TEST( ec.default_error_condition().category() == generic_category ); // test not-in-table condition: ec = error_code( 1234567890, system_category ); @@ -230,12 +238,12 @@ int main( int, char ** ) std::cout << "POSIX tests...\n"; ec = error_code( EACCES, system_category ); - BOOST_TEST( ec == error_code( posix::permission_denied, system_category ) ); - BOOST_TEST( error_code( posix::permission_denied, system_category ) == ec ); - BOOST_TEST( ec == posix::permission_denied ); - BOOST_TEST( posix::permission_denied == ec ); - BOOST_TEST( ec.default_error_condition().value() == posix::permission_denied ); - BOOST_TEST( ec.default_error_condition().category() == posix_category ); + BOOST_TEST( ec == error_code( errc::permission_denied, system_category ) ); + BOOST_TEST( error_code( errc::permission_denied, system_category ) == ec ); + BOOST_TEST( ec == errc::permission_denied ); + BOOST_TEST( errc::permission_denied == ec ); + BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied ); + BOOST_TEST( ec.default_error_condition().category() == generic_category ); # ifdef __CYGWIN__ diff --git a/test/system_error_test.cpp b/test/system_error_test.cpp index 269fb5d..0f3dbe4 100644 --- a/test/system_error_test.cpp +++ b/test/system_error_test.cpp @@ -9,6 +9,9 @@ //----------------------------------------------------------------------------// +// test without deprecated features +#define BOOST_SYSTEM_NO_DEPRECATED + #include #include @@ -80,24 +83,24 @@ int test_main( int, char *[] ) system_error c6_0( 0, system_category, "c6_0" ); system_error c6_1( 1, system_category, "c6_1" ); - TEST( c1_0, 0, "" ); + TEST( c1_0, 0, "The operation completed successfully" ); TEST( c1_1, 1, "Incorrect function" ); TEST( c1_2u, 2, "The system cannot find the file specified" ); - TEST( c2_0, 0, "c2_0" ); + TEST( c2_0, 0, "c2_0: The operation completed successfully" ); TEST( c2_1, 1, "c2_1: Incorrect function" ); - TEST( c3_0, 0, "c3_0" ); + TEST( c3_0, 0, "c3_0: The operation completed successfully" ); TEST( c3_1, 1, "c3_1: Incorrect function" ); - TEST( c4_0, 0, "" ); + TEST( c4_0, 0, "The operation completed successfully" ); TEST( c4_1, 1, "Incorrect function" ); TEST( c4_2u, 2, "The system cannot find the file specified" ); - TEST( c5_0, 0, "c5_0" ); + TEST( c5_0, 0, "c5_0: The operation completed successfully" ); TEST( c5_1, 1, "c5_1: Incorrect function" ); - TEST( c6_0, 0, "c6_0" ); + TEST( c6_0, 0, "c6_0: The operation completed successfully" ); TEST( c6_1, 1, "c6_1: Incorrect function" ); return 0; diff --git a/test/system_msvc/common.vsprops b/test/system_msvc/common.vsprops index 9a558f8..4dce1d5 100644 --- a/test/system_msvc/common.vsprops +++ b/test/system_msvc/common.vsprops @@ -9,6 +9,7 @@ AdditionalIncludeDirectories="../../../../.." PreprocessorDefinitions="BOOST_ALL_NO_LIB" ExceptionHandling="2" + WarningLevel="4" /> Date: Tue, 20 Apr 2010 18:49:18 +0000 Subject: [PATCH 06/30] Fixed various issues in docs (mostly duplicate bookmarks and broken links) found by inspect tool [SVN r61437] --- doc/reference.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/reference.html b/doc/reference.html index a451c82..82ad2c8 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -53,7 +53,7 @@    Class error_code constructors
   Class error_code modifiers
   Class error_code observers
- Class error_condition
+ Class error_condition
   Class error_condition synopsis
   Class error_condition constructors
   Class error_condition modifiers
@@ -841,4 +841,4 @@ application program interfaces.

- \ No newline at end of file + From ae67c86d2b69b1284c3f0e2b0a4b829a190790c8 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 29 Apr 2010 04:58:39 +0000 Subject: [PATCH 07/30] Fix a standards-conformance problem where we default-initialize a const object of non-POD class type without a user-declared default constructor [SVN r61672] --- test/error_code_user_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/error_code_user_test.cpp b/test/error_code_user_test.cpp index e5c9e79..be9adaa 100644 --- a/test/error_code_user_test.cpp +++ b/test/error_code_user_test.cpp @@ -108,6 +108,8 @@ namespace boost class lib3_error_category_imp : public boost::system::error_category { public: + lib3_error_category_imp() : boost::system::error_category() { } + const char * name() const { return "lib3"; @@ -168,6 +170,8 @@ namespace lib4 class lib4_error_category_imp : public boost::system::error_category { public: + lib4_error_category_imp() : boost::system::error_category() { } + const char * name() const { return "lib4"; From 2bb0075e3fd7d57aec92b6b88538fe17892a52a9 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 22 May 2010 12:12:00 +0000 Subject: [PATCH 08/30] =?UTF-8?q?Major=20upgrade=20to=20Boost.Config=20sym?= =?UTF-8?q?bol=20visibility=20macros=20for=20shared=20libraries,=20based?= =?UTF-8?q?=20on=20patches=20from=20J=C3=BCrgen=20Hunold=20with=20mods=20b?= =?UTF-8?q?y=20Beman=20Dawes.=20=20Upgrade=20Boost.System=20to=20use=20the?= =?UTF-8?q?=20new=20visibility=20macros.=20Fixes=20#3697=20and=20provides?= =?UTF-8?q?=20foundation=20for=20fixing=202114,=202309,=20etc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [SVN r62140] --- include/boost/system/config.hpp | 37 +++++-------- include/boost/system/system_error.hpp | 6 +- test/Jamfile.v2 | 16 +++++- test/dynamic_link_test.cpp | 55 +++++++++++++++++++ test/error_code_test.cpp | 6 ++ test/error_code_user_test.cpp | 48 ++++++++-------- test/header_only_test.cpp | 5 +- test/initialization_test.cpp | 4 +- test/system_error_test.cpp | 10 ++-- test/system_msvc/common.vsprops | 6 +- .../error_code_test/error_code_test.vcproj | 8 +-- test/system_msvc/system_msvc.sln | 31 +++++++++++ test/throw_test.cpp | 31 +++++++++++ 13 files changed, 193 insertions(+), 70 deletions(-) create mode 100644 test/dynamic_link_test.cpp create mode 100644 test/throw_test.cpp diff --git a/include/boost/system/config.hpp b/include/boost/system/config.hpp index fa09099..6bc217a 100644 --- a/include/boost/system/config.hpp +++ b/include/boost/system/config.hpp @@ -1,4 +1,4 @@ -// boost/system/config.hpp -------------------------------------------------// +// boost/system/config.hpp -----------------------------------------------------------// // Copyright Beman Dawes 2003, 2006 @@ -18,40 +18,29 @@ # if defined( BOOST_WINDOWS_API ) && defined( BOOST_POSIX_API ) # error both BOOST_WINDOWS_API and BOOST_POSIX_API are defined # elif !defined( BOOST_WINDOWS_API ) && !defined( BOOST_POSIX_API ) -# if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) +# if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) + // All Win32 development environments, including 64-bit Windows and MinGW, define + // _WIN32 or one of its variant spellings. Note that Cygwin is a POSIX environment, + // so does not define _WIN32 or its variants. # define BOOST_WINDOWS_API # else # define BOOST_POSIX_API # endif # endif -// enable dynamic linking on Windows ---------------------------------------// +// enable dynamic or static linking as requested --------------------------------------// -//# if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK)) && defined(__BORLANDC__) && defined(__WIN32__) -//# error Dynamic linking Boost.System does not work for Borland; use static linking instead -//# endif - -#ifdef BOOST_HAS_DECLSPEC // defined in config system -// we need to import/export our code only if the user has specifically -// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost -// libraries to be dynamically linked, or BOOST_SYSTEM_DYN_LINK -// if they want just this one to be dynamically liked: #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) -// export if this is our own source, otherwise import: -#ifdef BOOST_SYSTEM_SOURCE -# define BOOST_SYSTEM_DECL __declspec(dllexport) +# if defined(BOOST_SYSTEM_SOURCE) +# define BOOST_SYSTEM_DECL BOOST_SYMBOL_EXPORT +# else +# define BOOST_SYSTEM_DECL BOOST_SYMBOL_IMPORT +# endif #else -# define BOOST_SYSTEM_DECL __declspec(dllimport) -#endif // BOOST_SYSTEM_SOURCE -#endif // DYN_LINK -#endif // BOOST_HAS_DECLSPEC -// -// if BOOST_SYSTEM_DECL isn't defined yet define it now: -#ifndef BOOST_SYSTEM_DECL -#define BOOST_SYSTEM_DECL +# define BOOST_SYSTEM_DECL #endif -// enable automatic library variant selection ------------------------------// +// enable automatic library variant selection ----------------------------------------// #if !defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SYSTEM_NO_LIB) // diff --git a/include/boost/system/system_error.hpp b/include/boost/system/system_error.hpp index 3e83500..065d365 100644 --- a/include/boost/system/system_error.hpp +++ b/include/boost/system/system_error.hpp @@ -17,9 +17,11 @@ namespace boost { namespace system { - // class system_error --------------------------------------------------// + // class system_error ------------------------------------------------------------// - class system_error : public std::runtime_error + class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error + // BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared + // library can be caught. See svn.boost.org/trac/boost/ticket/3697 { public: system_error( error_code ec ) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7b14c76..043a36f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -12,6 +12,12 @@ project /boost/system//boost_system msvc:on ; + + lib throw_test + : throw_test.cpp + : shared:BOOST_SYSTEM_DYN_LINK=1 + ; + test-suite "system" : [ run error_code_test.cpp @@ -21,21 +27,25 @@ project static ] [ run error_code_test.cpp - : : : : error_code_test_dll + : : : shared : error_code_test_shared ] [ run error_code_user_test.cpp : : : static ] [ run error_code_user_test.cpp - : : : : error_code_user_test_dll + : : : shared : error_code_user_test_shared ] [ run system_error_test.cpp : : : static ] [ run system_error_test.cpp - : : : : system_error_test_dll + : : : shared : system_error_test_shared + ] + [ run dynamic_link_test.cpp throw_test + : : : shared : throw_test_shared ] [ run initialization_test.cpp + : : : shared : initialization_test_shared ] [ run header_only_test.cpp : : : static diff --git a/test/dynamic_link_test.cpp b/test/dynamic_link_test.cpp new file mode 100644 index 0000000..87f37c2 --- /dev/null +++ b/test/dynamic_link_test.cpp @@ -0,0 +1,55 @@ +// dynamic_link_test.cpp -------------------------------------------------------------// + +// Copyright Beman Dawes 2010 + +// Distributed under the Boost Software License, Version 1.0. +// See www.boost.org/LICENSE_1_0.txt + +// Library home page is www.boost.org/libs/system + +//--------------------------------------------------------------------------------------// + +// Dynamic link libraries (DLL's), also know as dynamic shared objects (DSO's), +// can cause symbol visability problems unless carefully configured. One of the +// manifestations, particularly with GCC, is that a system_error exception thrown from +// a DLL or DSO is not caught. +// +// The purpose of this program is to test for that error. + +//--------------------------------------------------------------------------------------// + +#include + +#include + +namespace boost +{ + namespace system + { + BOOST_SYSTEM_DECL void throw_test(); + } +} + +int main() +{ + try + { + boost::system::throw_test(); + } + catch (const boost::system::system_error& ex) + { + std::cout << " caught boost::system::system_error as expected\n"; + std::cout << " what() reports " << ex.what() << '\n'; + return 0; + } + + catch (const std::runtime_error& ex) + { + std::cout << " error: caught std::runtime_error instead of boost::system::system_error\n"; + std::cout << " what() reports " << ex.what() << '\n'; + return 1; + } + + std::cout << " error: failed to catch boost::system::system_error\n"; + return 1; +} \ No newline at end of file diff --git a/test/error_code_test.cpp b/test/error_code_test.cpp index 4870b2d..8c0e7c7 100644 --- a/test/error_code_test.cpp +++ b/test/error_code_test.cpp @@ -59,6 +59,12 @@ namespace int main( int, char ** ) { + std::cout << "Conversion use cases...\n"; + error_condition x1( errc::file_exists ); + //error_code x2( errc::file_exists ); // should fail to compile + make_error_code(errc::file_exists); + make_error_condition(errc::file_exists); + std::cout << "General tests...\n"; // unit tests: diff --git a/test/error_code_user_test.cpp b/test/error_code_user_test.cpp index be9adaa..be1a43e 100644 --- a/test/error_code_user_test.cpp +++ b/test/error_code_user_test.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #ifdef BOOST_POSIX_API # include @@ -264,7 +264,7 @@ namespace lib4 // // void check_success(const boost::system::error_code& ec, bool expect) // { -// BOOST_CHECK( (ec == boost::system::posix::success) == expect ); +// BOOST_TEST( (ec == boost::system::posix::success) == expect ); // if (ec == boost::system::posix::success) // std::cout << "yes... " << (expect ? "ok" : "fail") << '\n'; // else @@ -273,7 +273,7 @@ namespace lib4 // // void check_permission_denied(const boost::system::error_code& ec, bool expect) // { -// BOOST_CHECK( (ec == boost::system::posix::permission_denied) == expect ); +// BOOST_TEST( (ec == boost::system::posix::permission_denied) == expect ); // if (ec == boost::system::posix::permission_denied) // std::cout << "yes... " << (expect ? "ok" : "fail") << '\n'; // else @@ -282,7 +282,7 @@ namespace lib4 // // void check_out_of_memory(const boost::system::error_code& ec, bool expect) // { -// BOOST_CHECK( (ec == boost::system::posix::not_enough_memory) == expect ); +// BOOST_TEST( (ec == boost::system::posix::not_enough_memory) == expect ); // if (ec == boost::system::posix::not_enough_memory) // std::cout << "yes... " << (expect ? "ok" : "fail") << '\n'; // else @@ -337,7 +337,7 @@ namespace lib4 // ------------------------------------------------------------------------ // -int test_main( int, char *[] ) +int main( int, char *[] ) { boost::system::error_code ec; @@ -346,35 +346,35 @@ int test_main( int, char *[] ) ec = my_mkdir( "/no-such-file-or-directory/will-not-succeed" ); std::cout << "ec.value() is " << ec.value() << '\n'; - BOOST_CHECK( ec ); - BOOST_CHECK( ec == boost::system::posix::no_such_file_or_directory ); - BOOST_CHECK( ec.category() == boost::system::system_category ); + BOOST_TEST( ec ); + BOOST_TEST( ec == boost::system::posix::no_such_file_or_directory ); + BOOST_TEST( ec.category() == boost::system::system_category ); // Library 2 tests: ec = my_remove( "/no-such-file-or-directory" ); std::cout << "ec.value() is " << ec.value() << '\n'; - BOOST_CHECK( ec ); - BOOST_CHECK( ec == boost::system::posix::no_such_file_or_directory ); - BOOST_CHECK( ec.category() == boost::system::posix_category ); + BOOST_TEST( ec ); + BOOST_TEST( ec == boost::system::posix::no_such_file_or_directory ); + BOOST_TEST( ec.category() == boost::system::posix_category ); // Library 3 tests: ec = boost::lib3::boo_boo; std::cout << "ec.value() is " << ec.value() << '\n'; - BOOST_CHECK( ec ); - BOOST_CHECK( ec == boost::lib3::boo_boo ); - BOOST_CHECK( ec.value() == boost::lib3::boo_boo ); - BOOST_CHECK( ec.category() == boost::lib3::lib3_error_category ); + BOOST_TEST( ec ); + BOOST_TEST( ec == boost::lib3::boo_boo ); + BOOST_TEST( ec.value() == boost::lib3::boo_boo ); + BOOST_TEST( ec.category() == boost::lib3::lib3_error_category ); - BOOST_CHECK( ec == boost::system::posix::io_error ); + BOOST_TEST( ec == boost::system::posix::io_error ); boost::system::error_code ec3( boost::lib3::boo_boo+100, boost::lib3::lib3_error_category ); - BOOST_CHECK( ec3.category() == boost::lib3::lib3_error_category ); - BOOST_CHECK( ec3.default_error_condition().category() + BOOST_TEST( ec3.category() == boost::lib3::lib3_error_category ); + BOOST_TEST( ec3.default_error_condition().category() == boost::lib3::lib3_error_category ); // Library 4 tests: @@ -382,16 +382,16 @@ int test_main( int, char *[] ) ec = lib4::boo_boo; std::cout << "ec.value() is " << ec.value() << '\n'; - BOOST_CHECK( ec ); - BOOST_CHECK( ec == lib4::boo_boo ); - BOOST_CHECK( ec.value() == lib4::boo_boo.value() ); - BOOST_CHECK( ec.category() == lib4::lib4_error_category ); + BOOST_TEST( ec ); + BOOST_TEST( ec == lib4::boo_boo ); + BOOST_TEST( ec.value() == lib4::boo_boo.value() ); + BOOST_TEST( ec.category() == lib4::lib4_error_category ); - BOOST_CHECK( ec == boost::system::posix::io_error ); + BOOST_TEST( ec == boost::system::posix::io_error ); boost::system::error_code ec4( lib4::boo_boo.value()+100, lib4::lib4_error_category ); - BOOST_CHECK( ec4.default_error_condition().category() + BOOST_TEST( ec4.default_error_condition().category() == lib4::lib4_error_category ); // Test 3 diff --git a/test/header_only_test.cpp b/test/header_only_test.cpp index 20d6179..7c74793 100644 --- a/test/header_only_test.cpp +++ b/test/header_only_test.cpp @@ -13,11 +13,10 @@ #define BOOST_ERROR_CODE_HEADER_ONLY -#include - +#include #include -int test_main( int, char*[] ) +int main( int, char*[] ) { boost::system::error_code ec( 0, boost::system::system_category ); return 0; diff --git a/test/initialization_test.cpp b/test/initialization_test.cpp index 7ccd594..c481e5a 100644 --- a/test/initialization_test.cpp +++ b/test/initialization_test.cpp @@ -10,7 +10,7 @@ // This test verifiies that the error_category vtable does not suffer from // order-of-initialization problems. -#include +#include #include struct foo @@ -22,7 +22,7 @@ struct foo } } f; -int test_main( int, char ** ) +int main( int, char ** ) { return 0; } diff --git a/test/system_error_test.cpp b/test/system_error_test.cpp index 0f3dbe4..67c27a1 100644 --- a/test/system_error_test.cpp +++ b/test/system_error_test.cpp @@ -14,7 +14,7 @@ #include -#include +#include #include #include #include @@ -36,8 +36,8 @@ namespace int v, const char * str ) { std::cout << "test " << desc << "\n what() returns \"" << ex.what() << "\"\n"; - BOOST_CHECK( ex.code().value() == v ); - BOOST_CHECK( ex.code().category() == system_category ); + BOOST_TEST( ex.code().value() == v ); + BOOST_TEST( ex.code().category() == system_category ); # ifdef BOOST_WINDOWS_API LANGID language_id; # if !defined(__MINGW32__) && !defined(__CYGWIN__) @@ -48,7 +48,7 @@ namespace // std::cout << "GetUserDefaultUILanguage() returns " << language_id << '\n'; if ( language_id == 0x0409 ) // English (United States) { - BOOST_CHECK( std::string( ex.what() ) == str ); + BOOST_TEST( std::string( ex.what() ) == str ); if ( std::string( ex.what() ) != str ) std::cout << "expected \"" << str << "\", but what() returned \"" << ex.what() << "\"\n"; @@ -59,7 +59,7 @@ namespace const boost::uint_least32_t uvalue = 2u; } -int test_main( int, char *[] ) +int main( int, char *[] ) { // all constructors, in the same order as they appear in the header: diff --git a/test/system_msvc/common.vsprops b/test/system_msvc/common.vsprops index 4dce1d5..e4cc705 100644 --- a/test/system_msvc/common.vsprops +++ b/test/system_msvc/common.vsprops @@ -7,13 +7,13 @@ diff --git a/test/system_msvc/error_code_test/error_code_test.vcproj b/test/system_msvc/error_code_test/error_code_test.vcproj index d59cd21..f69ff01 100644 --- a/test/system_msvc/error_code_test/error_code_test.vcproj +++ b/test/system_msvc/error_code_test/error_code_test.vcproj @@ -86,6 +86,8 @@ /> @@ -172,10 +176,6 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > - - diff --git a/test/system_msvc/system_msvc.sln b/test/system_msvc/system_msvc.sln index f26e95f..d3d2746 100644 --- a/test/system_msvc/system_msvc.sln +++ b/test/system_msvc/system_msvc.sln @@ -2,8 +2,27 @@ Microsoft Visual Studio Solution File, Format Version 10.00 # Visual C++ Express 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "error_code_test", "error_code_test\error_code_test.vcproj", "{81960557-E9A9-4E81-AC96-9E11C33CB058}" + ProjectSection(ProjectDependencies) = postProject + {22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system_error_test", "system_error_test\system_error_test.vcproj", "{CBD12E59-99E5-4F35-9B66-0554D0FBDB76}" + ProjectSection(ProjectDependencies) = postProject + {22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dynamic_link_test", "dynamic_link_test\dynamic_link_test.vcproj", "{AD186B11-9132-48A9-9F24-3522C2310B0D}" + ProjectSection(ProjectDependencies) = postProject + {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7} = {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7} + {22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system_dll", "system_dll\system_dll.vcproj", "{22892211-A1F3-435B-8B97-A12E8772599E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "throw_test_dll", "throw_test_dll\throw_test_dll.vcproj", "{F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}" + ProjectSection(ProjectDependencies) = postProject + {22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -19,6 +38,18 @@ Global {CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Debug|Win32.Build.0 = Debug|Win32 {CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Release|Win32.ActiveCfg = Release|Win32 {CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Release|Win32.Build.0 = Release|Win32 + {AD186B11-9132-48A9-9F24-3522C2310B0D}.Debug|Win32.ActiveCfg = Debug|Win32 + {AD186B11-9132-48A9-9F24-3522C2310B0D}.Debug|Win32.Build.0 = Debug|Win32 + {AD186B11-9132-48A9-9F24-3522C2310B0D}.Release|Win32.ActiveCfg = Release|Win32 + {AD186B11-9132-48A9-9F24-3522C2310B0D}.Release|Win32.Build.0 = Release|Win32 + {22892211-A1F3-435B-8B97-A12E8772599E}.Debug|Win32.ActiveCfg = Debug|Win32 + {22892211-A1F3-435B-8B97-A12E8772599E}.Debug|Win32.Build.0 = Debug|Win32 + {22892211-A1F3-435B-8B97-A12E8772599E}.Release|Win32.ActiveCfg = Release|Win32 + {22892211-A1F3-435B-8B97-A12E8772599E}.Release|Win32.Build.0 = Release|Win32 + {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Debug|Win32.ActiveCfg = Debug|Win32 + {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Debug|Win32.Build.0 = Debug|Win32 + {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Release|Win32.ActiveCfg = Release|Win32 + {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/throw_test.cpp b/test/throw_test.cpp new file mode 100644 index 0000000..998fc20 --- /dev/null +++ b/test/throw_test.cpp @@ -0,0 +1,31 @@ +// throw_test.cpp --------------------------------------------------------===========-// + +// Copyright Beman Dawes 2010 + +// Distributed under the Boost Software License, Version 1.0. +// See www.boost.org/LICENSE_1_0.txt + +// Library home page is www.boost.org/libs/system + +//--------------------------------------------------------------------------------------// + +// See dynamic_link_test.cpp comments for use case. + +//--------------------------------------------------------------------------------------// + +// define BOOST_SYSTEM_SOURCE so that knows +// the library is being built (possibly exporting rather than importing code) +#define BOOST_SYSTEM_SOURCE + +#include + +namespace boost +{ + namespace system + { + BOOST_SYSTEM_DECL void throw_test() + { + throw system_error(9999, get_system_category(), "boo boo"); + } + } +} From 6e8039cb2db93f6c440594c7972589258d39b408 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 22 May 2010 16:10:49 +0000 Subject: [PATCH 09/30] fix lightweight test boo boo (Thanks to Peter Dimov) [SVN r62149] --- test/error_code_user_test.cpp | 2 +- test/header_only_test.cpp | 2 +- test/system_error_test.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/error_code_user_test.cpp b/test/error_code_user_test.cpp index be1a43e..a8e418b 100644 --- a/test/error_code_user_test.cpp +++ b/test/error_code_user_test.cpp @@ -398,5 +398,5 @@ int main( int, char *[] ) //test3::run(); - return 0; + return ::boost::report_errors(); } diff --git a/test/header_only_test.cpp b/test/header_only_test.cpp index 7c74793..12f22c0 100644 --- a/test/header_only_test.cpp +++ b/test/header_only_test.cpp @@ -19,5 +19,5 @@ int main( int, char*[] ) { boost::system::error_code ec( 0, boost::system::system_category ); - return 0; + return ::boost::report_errors(); } diff --git a/test/system_error_test.cpp b/test/system_error_test.cpp index 67c27a1..47f3c2e 100644 --- a/test/system_error_test.cpp +++ b/test/system_error_test.cpp @@ -103,7 +103,7 @@ int main( int, char *[] ) TEST( c6_0, 0, "c6_0: The operation completed successfully" ); TEST( c6_1, 1, "c6_1: Incorrect function" ); - return 0; + return ::boost::report_errors(); } From 2565e5307b0d75d01abe4b7d6f2393f8f25a2778 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 26 May 2010 00:38:07 +0000 Subject: [PATCH 10/30] Fix #3994, error values on some Broadcom chips [SVN r62222] --- src/error_code.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/error_code.cpp b/src/error_code.cpp index fa2cb0b..c40eec3 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -221,7 +221,9 @@ namespace # if ENOTEMPTY != EEXIST // AIX treats ENOTEMPTY and EEXIST as the same value case ENOTEMPTY: return make_error_condition( directory_not_empty ); # endif // ENOTEMPTY != EEXIST - case ENOTRECOVERABLE: return make_error_condition( state_not_recoverable ); + # if ENOTRECOVERABLE != ECONNRESET // the same on some Broadcom chips + case ENOTRECOVERABLE: return make_error_condition( state_not_recoverable ); + # endif // ENOTRECOVERABLE != ECONNRESET case ENOTSOCK: return make_error_condition( not_a_socket ); case ENOTSUP: return make_error_condition( not_supported ); case ENOTTY: return make_error_condition( inappropriate_io_control_operation ); @@ -230,7 +232,9 @@ namespace case EOPNOTSUPP: return make_error_condition( operation_not_supported ); # endif // EOPNOTSUPP != ENOTSUP case EOVERFLOW: return make_error_condition( value_too_large ); - case EOWNERDEAD: return make_error_condition( owner_dead ); + # if EOWNERDEAD != ECONNABORTED // the same on some Broadcom chips + case EOWNERDEAD: return make_error_condition( owner_dead ); + # endif // EOWNERDEAD != ECONNABORTED case EPERM: return make_error_condition( operation_not_permitted ); case EPIPE: return make_error_condition( broken_pipe ); case EPROTO: return make_error_condition( protocol_error ); From baae3a392aabe2790a65b76e1ad82ca495a0315c Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 30 May 2010 15:38:32 +0000 Subject: [PATCH 11/30] Upgrade system and filesystem to conform system_category and generic_category interface to N3090, the current C++0x working paper, section 19.5, System error support. Refactor API macros into a new header, boost/system/api_config.hpp. Prohibit user definition of API macros. Rationale: ensure all translation units use same definitions, cut number of environments that need to be tested. [SVN r62313] --- doc/index.html | 14 +++- doc/reference.html | 104 +++++++++++++----------- include/boost/system/api_config.hpp | 42 ++++++++++ include/boost/system/config.hpp | 18 +---- include/boost/system/cygwin_error.hpp | 4 +- include/boost/system/error_code.hpp | 32 ++++---- include/boost/system/linux_error.hpp | 4 +- include/boost/system/windows_error.hpp | 4 +- src/error_code.cpp | 10 +-- test/error_code_test.cpp | 108 ++++++++++++------------- test/error_code_user_test.cpp | 68 ++++++++-------- test/header_only_test.cpp | 2 +- test/initialization_test.cpp | 2 +- test/system_error_test.cpp | 30 +++---- test/throw_test.cpp | 2 +- 15 files changed, 248 insertions(+), 196 deletions(-) create mode 100644 include/boost/system/api_config.hpp diff --git a/doc/index.html b/doc/index.html index 50a6267..bbc331a 100644 --- a/doc/index.html +++ b/doc/index.html @@ -93,6 +93,18 @@ supports both error reporting by exception and by error code.

error_code.hpp header, system-specific headers support the Cygwin, Linux, and Windows platforms. These headers are effectively no-ops if included for platforms other than their intended target.

+ + + + +
The Boost System Library will become part of the C++0x Standard Library. + A number of changes, particularly to names, were made by the C++ committee + during standardization. The Boost implementation is tracking those changes. + See Deprecated names for + synonyms provided to prevent breakage of existing user code. See + Breaking changes for changes + that unavoidably break existing user code. All breaking changes are noisy + and will cause compile-time errors.

Design Rationale

Class error_code  and error_condition are designed as a value types so they can be copied @@ -133,7 +145,7 @@ paper. Johan Nilsson's comments led to several of the refinements in N2066 .


Revised -February 23, 2008 +May 28, 2010

© Copyright Beman Dawes, 1999

diff --git a/doc/reference.html b/doc/reference.html index 82ad2c8..174653b 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -40,6 +40,7 @@ Introduction
Macros
Deprecated names
+ Breaking changes
Header <boost/system/error_code.hpp>
Class error_category
   Class error_category synopsis
@@ -77,55 +78,50 @@ errno.

Macros

Users may defined the following macros if desired. Sensible defaults are provided, so users may ignore these macros if they prefer.

- +
- - - + + + - - - - - - - - - - - - + - - - + - - - - + + + -
Macro NameDefaultEffect if definedMacro NameDefaultEffect if defined
BOOST_WINDOWS_APIDefined if Windows is detected by Boost.System's automatic configuration - code, otherwise not defined.Implementation uses the Microsoft Windows native - application program interface (API).
BOOST_POSIX_APIDefined if Windows is not detected by Boost.System's automatic configuration - code.Implementation uses the POSIX native - application program interface (API).
BOOST_SYSTEM_DYN_LINKDefined if BOOST_ALL_DYN_LINK is defined, + BOOST_SYSTEM_DYN_LINKDefined if BOOST_ALL_DYN_LINK is defined, otherwise not defined.Boost.System library is dynamically linked. If not defined, + Boost.System library is dynamically linked. If not defined, static linking is assumed.
BOOST_SYSTEM_NO_LIBDefined if BOOST_ALL_NO_LIB is defined, + BOOST_SYSTEM_NO_LIBDefined if BOOST_ALL_NO_LIB is defined, otherwise not defined.Boost.System library does not use the Boost auto-link + Boost.System library does not use the Boost auto-link facility.
BOOST_SYSTEM_NO_DEPRECATEDNot defined.Deprecated features are excluded.BOOST_SYSTEM_NO_DEPRECATEDNot defined.Deprecated features are excluded.
+

Deprecated names

-

In the process of adding Boost.System to C++0x standard library, some of the -names are being changed. To ease transition, Boost.System deprecates the old +

In the process of adding Boost.System to C++0x standard library, the C++ +committee changed some +names. To ease transition, Boost.System deprecates the old names, but continues to provide them unless macro BOOST_SYSTEM_NO_DEPRECATED is defined.

- - + + + + + + + + + + @@ -141,21 +137,39 @@ is defined.

- + - + - + - +
Old name, now deprecatedNew nameOld usage, now deprecatedReplacement
get_generic_category()generic_category()
get_system_category()system_category()
namespace posix
get_posix_category()get_generic_category()generic_category()
posix_categorygeneric_categorygeneric_category()
errno_ecatgeneric_categorygeneric_category()
native_ecatsystem_categorysystem_category()
+

Breaking changes

+

Two static consts are replaced by functions. These are breaking changes best +fixed by globally adding () to these names to turn them into function calls.

+ + + + + + + + + + + + + +
Old usage, now brokenReplacement
generic_categorygeneric_category()
system_categorysystem_category()
+

User-defined BOOST_POSIX_API and BOOST_WINDOWS_API are no longer supported.

Header <boost/system/error_code.hpp>

<boost/system/error_code.hpp> synopsis

@@ -265,9 +279,6 @@ is defined.

template<> struct is_error_condition_enum<errc::errc_t> { static const bool value = true; }; - // predefined error_code object used as "throw on error" tag - extern error_code throws; - // non-member functions bool operator==( const error_code & lhs, const error_code & rhs ); @@ -336,11 +347,8 @@ types should create a single object of each such type. bool operator< ( const error_category & rhs ) const; }; - const error_category & get_system_category(); - const error_category & get_generic_category(); - - static const error_category & system_category = get_system_category(); - static const error_category & generic_category = get_generic_category(); + const error_category & system_category(); + const error_category & generic_category(); } }
@@ -402,13 +410,13 @@ const;

Class error_category non-member functions

-
const error_category & get_system_category();
+
const error_category & system_category();

Returns: A reference to a error_category object identifying errors originating from the operating system.

Throws: Nothing.

-
const error_category & get_generic_category();
+
const error_category & generic_category();

Returns: A reference to a error_category object identifying portable error conditions.

@@ -831,7 +839,7 @@ application program interfaces.


Revised -October 11, 2008 +May 29, 2010

© Copyright Beman Dawes, 2006, 2007, 2008

@@ -841,4 +849,4 @@ application program interfaces.

- + \ No newline at end of file diff --git a/include/boost/system/api_config.hpp b/include/boost/system/api_config.hpp new file mode 100644 index 0000000..28b8bec --- /dev/null +++ b/include/boost/system/api_config.hpp @@ -0,0 +1,42 @@ +// boost/system/api_config.hpp -------------------------------------------------------// + +// Copyright Beman Dawes 2003, 2006, 2010 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See http://www.boost.org/libs/system for documentation. + +//--------------------------------------------------------------------------------------// + +// Boost.System calls operating system API functions to implement system error category +// functions. Usually there is no question as to which API is to be used. +// +// In the case of MinGW or Cygwin/MinGW, however, both POSIX and Windows API's are +// available. Chaos ensues if other code thinks one is in use when Boost.System was +// actually built with the other. This header centralizes the API choice and prevents +// user definition of API macros, thus elminating the possibility of mismatches and the +// need to test configurations with little or no practical value. +// + +//--------------------------------------------------------------------------------------// + +#ifndef BOOST_SYSTEM_API_CONFIG_HPP +#define BOOST_SYSTEM_API_CONFIG_HPP + +# if defined(BOOST_POSIX_API) || defined(BOOST_WINDOWS_API) +# error user defined BOOST_POSIX_API or BOOST_WINDOWS_API not supported +# endif + +// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use +// Cygwin/MinGW does not predefine _WIN32. +// Standalone MinGW and all other known Windows compilers do predefine _WIN32 +// Compilers that predefine _WIN32 or __MINGW32__ do so for Windows 64-bit builds too. + +# if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin +# define BOOST_WINDOWS_API +# else +# define BOOST_POSIX_API +# endif + +#endif // BOOST_SYSTEM_API_CONFIG_HPP diff --git a/include/boost/system/config.hpp b/include/boost/system/config.hpp index 6bc217a..bf78051 100644 --- a/include/boost/system/config.hpp +++ b/include/boost/system/config.hpp @@ -11,22 +11,10 @@ #define BOOST_SYSTEM_CONFIG_HPP #include +#include // for BOOST_POSIX_API or BOOST_WINDOWS_API -// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use. -// If not specified, a sensible default will be applied. - -# if defined( BOOST_WINDOWS_API ) && defined( BOOST_POSIX_API ) -# error both BOOST_WINDOWS_API and BOOST_POSIX_API are defined -# elif !defined( BOOST_WINDOWS_API ) && !defined( BOOST_POSIX_API ) -# if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) - // All Win32 development environments, including 64-bit Windows and MinGW, define - // _WIN32 or one of its variant spellings. Note that Cygwin is a POSIX environment, - // so does not define _WIN32 or its variants. -# define BOOST_WINDOWS_API -# else -# define BOOST_POSIX_API -# endif -# endif +// This header implements separate compilation features as described in +// http://www.boost.org/more/separate_compilation.html // enable dynamic or static linking as requested --------------------------------------// diff --git a/include/boost/system/cygwin_error.hpp b/include/boost/system/cygwin_error.hpp index 4955be9..ea3528b 100644 --- a/include/boost/system/cygwin_error.hpp +++ b/include/boost/system/cygwin_error.hpp @@ -23,7 +23,7 @@ namespace boost { // To construct an error_code after a API error: // - // error_code( errno, system_category ) + // error_code( errno, system_category() ) // User code should use the portable "posix" enums for POSIX errors; this // allows such code to be portable to non-POSIX systems. For the non-POSIX @@ -46,7 +46,7 @@ namespace boost namespace cygwin_error { inline error_code make_error_code( cygwin_errno e ) - { return error_code( e, get_system_category() ); } + { return error_code( e, system_category() ); } } } } diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index d0eb6c5..b22775f 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -202,18 +202,18 @@ namespace boost // predefined error categories -----------------------------------------// - BOOST_SYSTEM_DECL const error_category & get_system_category(); - BOOST_SYSTEM_DECL const error_category & get_generic_category(); + BOOST_SYSTEM_DECL const error_category & system_category(); + BOOST_SYSTEM_DECL const error_category & generic_category(); + + // deprecated synonyms --------------------------------------------------// - static const error_category & system_category = get_system_category(); - static const error_category & generic_category = get_generic_category(); - # ifndef BOOST_SYSTEM_NO_DEPRECATED - // deprecated synonyms - inline const error_category & get_posix_category() { return get_generic_category(); } - static const error_category & posix_category = get_generic_category(); - static const error_category & errno_ecat = get_generic_category(); - static const error_category & native_ecat = get_system_category(); + inline const error_category & get_system_category() { return system_category(); } + inline const error_category & get_generic_category() { return generic_category(); } + inline const error_category & get_posix_category() { return generic_category(); } + static const error_category & posix_category = generic_category(); + static const error_category & errno_ecat = generic_category(); + static const error_category & native_ecat = system_category(); # endif // class error_condition -----------------------------------------------// @@ -225,7 +225,7 @@ namespace boost public: // constructors: - error_condition() : m_val(0), m_cat(&get_generic_category()) {} + error_condition() : m_val(0), m_cat(&generic_category()) {} error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} template @@ -254,7 +254,7 @@ namespace boost void clear() { m_val = 0; - m_cat = &get_generic_category(); + m_cat = &generic_category(); } // observers: @@ -312,7 +312,7 @@ namespace boost public: // constructors: - error_code() : m_val(0), m_cat(&get_system_category()) {} + error_code() : m_val(0), m_cat(&system_category()) {} error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} template @@ -340,7 +340,7 @@ namespace boost void clear() { m_val = 0; - m_cat = &get_system_category(); + m_cat = &system_category(); } // observers: @@ -473,11 +473,11 @@ namespace boost { // explicit conversion: inline error_code make_error_code( errc_t e ) - { return error_code( e, get_generic_category() ); } + { return error_code( e, generic_category() ); } // implicit conversion: inline error_condition make_error_condition( errc_t e ) - { return error_condition( e, get_generic_category() ); } + { return error_condition( e, generic_category() ); } } // error_category default implementation -------------------------------// diff --git a/include/boost/system/linux_error.hpp b/include/boost/system/linux_error.hpp index 2998253..0eb22bf 100644 --- a/include/boost/system/linux_error.hpp +++ b/include/boost/system/linux_error.hpp @@ -23,7 +23,7 @@ namespace boost { // To construct an error_code after a API error: // - // error_code( errno, system_category ) + // error_code( errno, system_category() ) // User code should use the portable "posix" enums for POSIX errors; this // allows such code to be portable to non-POSIX systems. For the non-POSIX @@ -99,7 +99,7 @@ namespace boost namespace linux_error { inline error_code make_error_code( linux_errno e ) - { return error_code( e, get_system_category() ); } + { return error_code( e, system_category() ); } } } // namespace system diff --git a/include/boost/system/windows_error.hpp b/include/boost/system/windows_error.hpp index b6d2f0f..fff3a98 100644 --- a/include/boost/system/windows_error.hpp +++ b/include/boost/system/windows_error.hpp @@ -29,7 +29,7 @@ namespace boost // To construct an error_code after a API error: // - // error_code( ::GetLastError(), system_category ) + // error_code( ::GetLastError(), system_category() ) namespace windows_error { @@ -107,7 +107,7 @@ namespace boost namespace windows_error { inline error_code make_error_code( windows_error_code e ) - { return error_code( e, get_system_category() ); } + { return error_code( e, system_category() ); } } } // namespace system diff --git a/src/error_code.cpp b/src/error_code.cpp index c40eec3..dfd4a0e 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -159,7 +159,7 @@ namespace switch ( ev ) { case 0: return make_error_condition( success ); - # if defined(BOOST_POSIX_API) +# if defined(BOOST_POSIX_API) // POSIX-like O/S -> posix_errno decode table ---------------------------// case E2BIG: return make_error_condition( argument_list_too_long ); case EACCES: return make_error_condition( permission_denied ); @@ -329,7 +329,7 @@ namespace case WSAETIMEDOUT: return make_error_condition( timed_out ); case WSAEWOULDBLOCK: return make_error_condition( operation_would_block ); #endif - default: return error_condition( ev, system_category ); + default: return error_condition( ev, system_category() ); } } @@ -337,7 +337,7 @@ namespace std::string system_error_category::message( int ev ) const { - return generic_category.message( ev ); + return generic_category().message( ev ); } # else // TODO: @@ -423,13 +423,13 @@ namespace boost // address for comparison purposes # endif - BOOST_SYSTEM_DECL const error_category & get_system_category() + BOOST_SYSTEM_DECL const error_category & system_category() { static const system_error_category system_category_const; return system_category_const; } - BOOST_SYSTEM_DECL const error_category & get_generic_category() + BOOST_SYSTEM_DECL const error_category & generic_category() { static const generic_error_category generic_category_const; return generic_category_const; diff --git a/test/error_code_test.cpp b/test/error_code_test.cpp index 8c0e7c7..a9a928e 100644 --- a/test/error_code_test.cpp +++ b/test/error_code_test.cpp @@ -68,20 +68,20 @@ int main( int, char ** ) std::cout << "General tests...\n"; // unit tests: - BOOST_TEST( generic_category == generic_category ); - BOOST_TEST( system_category == system_category ); - BOOST_TEST( generic_category != system_category ); - BOOST_TEST( system_category != generic_category ); + BOOST_TEST( generic_category() == generic_category() ); + BOOST_TEST( system_category() == system_category() ); + BOOST_TEST( generic_category() != system_category() ); + BOOST_TEST( system_category() != generic_category() ); - if ( std::less()( &generic_category, &system_category ) ) + if ( std::less()( &generic_category(), &system_category() ) ) { - BOOST_TEST( generic_category < system_category ); - BOOST_TEST( !(system_category < generic_category) ); + BOOST_TEST( generic_category() < system_category() ); + BOOST_TEST( !(system_category() < generic_category()) ); } else { - BOOST_TEST( system_category < generic_category ); - BOOST_TEST( !(generic_category < system_category) ); + BOOST_TEST( system_category() < generic_category() ); + BOOST_TEST( !(generic_category() < system_category()) ); } @@ -91,29 +91,29 @@ int main( int, char ** ) BOOST_TEST( ec.value() == 0 ); econd = ec.default_error_condition(); BOOST_TEST( econd.value() == 0 ); - BOOST_TEST( econd.category() == generic_category ); + BOOST_TEST( econd.category() == generic_category() ); BOOST_TEST( ec == errc::success ); - BOOST_TEST( ec.category() == system_category ); + BOOST_TEST( ec.category() == system_category() ); BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 ); - BOOST_TEST( !(ec < error_code( 0, system_category )) ); - BOOST_TEST( !(error_code( 0, system_category ) < ec) ); - BOOST_TEST( ec < error_code( 1, system_category ) ); - BOOST_TEST( !(error_code( 1, system_category ) < ec) ); + BOOST_TEST( !(ec < error_code( 0, system_category() )) ); + BOOST_TEST( !(error_code( 0, system_category() ) < ec) ); + BOOST_TEST( ec < error_code( 1, system_category() ) ); + BOOST_TEST( !(error_code( 1, system_category() ) < ec) ); - error_code ec_0_system( 0, system_category ); + error_code ec_0_system( 0, system_category() ); BOOST_TEST( !ec_0_system ); BOOST_TEST( ec_0_system.value() == 0 ); econd = ec_0_system.default_error_condition(); BOOST_TEST( econd.value() == 0 ); - BOOST_TEST( econd.category() == generic_category ); + BOOST_TEST( econd.category() == generic_category() ); BOOST_TEST( ec_0_system == errc::success ); - BOOST_TEST( ec_0_system.category() == system_category ); + BOOST_TEST( ec_0_system.category() == system_category() ); BOOST_TEST( std::strcmp( ec_0_system.category().name(), "system") == 0 ); check_ostream( ec_0_system, "system:0" ); BOOST_TEST( ec_0_system == ec ); - error_code ec_1_system( 1, system_category ); + error_code ec_1_system( 1, system_category() ); BOOST_TEST( ec_1_system ); BOOST_TEST( ec_1_system.value() == 1 ); BOOST_TEST( ec_1_system.value() != 0 ); @@ -121,17 +121,17 @@ int main( int, char ** ) BOOST_TEST( ec_0_system != ec_1_system ); check_ostream( ec_1_system, "system:1" ); - ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category ); + ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category() ); BOOST_TEST( ec ); BOOST_TEST( ec.value() == BOOST_ACCESS_ERROR_MACRO ); econd = ec.default_error_condition(); BOOST_TEST( econd.value() == static_cast(errc::permission_denied) ); - BOOST_TEST( econd.category() == generic_category ); - BOOST_TEST( econd == error_condition( errc::permission_denied, generic_category ) ); + BOOST_TEST( econd.category() == generic_category() ); + BOOST_TEST( econd == error_condition( errc::permission_denied, generic_category() ) ); BOOST_TEST( econd == errc::permission_denied ); BOOST_TEST( errc::permission_denied == econd ); BOOST_TEST( ec == errc::permission_denied ); - BOOST_TEST( ec.category() == system_category ); + BOOST_TEST( ec.category() == system_category() ); BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 ); // test the explicit make_error_code conversion for errc @@ -141,17 +141,17 @@ int main( int, char ** ) BOOST_TEST( errc::bad_message == ec ); BOOST_TEST( ec != errc::permission_denied ); BOOST_TEST( errc::permission_denied != ec ); - BOOST_TEST( ec.category() == generic_category ); + BOOST_TEST( ec.category() == generic_category() ); //// test the deprecated predefined error_category synonyms - //BOOST_TEST( &system_category == &native_ecat ); - //BOOST_TEST( &generic_category == &errno_ecat ); - //BOOST_TEST( system_category == native_ecat ); - //BOOST_TEST( generic_category == errno_ecat ); + //BOOST_TEST( &system_category() == &native_ecat ); + //BOOST_TEST( &generic_category() == &errno_ecat ); + //BOOST_TEST( system_category() == native_ecat ); + //BOOST_TEST( generic_category() == errno_ecat ); // test error_code and error_condition message(); // see Boost.Filesystem operations_test for code specific message() tests - ec = error_code( -1, system_category ); + ec = error_code( -1, system_category() ); std::cout << "error_code message for -1 is \"" << ec.message() << "\"\n"; std::cout << "error_code message for 0 is \"" << ec_0_system.message() << "\"\n"; #if defined(BOOST_WINDOWS_API) @@ -169,11 +169,11 @@ int main( int, char ** ) BOOST_TEST( ec.message() == "error -1" ); #endif - ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category ); + ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category() ); BOOST_TEST( ec.message() != "" ); BOOST_TEST( ec.message().substr( 0, 13) != "Unknown error" ); - econd = error_condition( -1, generic_category ); + econd = error_condition( -1, generic_category() ); error_condition econd_ok; std::cout << "error_condition message for -1 is \"" << econd.message() << "\"\n"; std::cout << "error_condition message for 0 is \"" << econd_ok.message() << "\"\n"; @@ -192,7 +192,7 @@ int main( int, char ** ) BOOST_TEST( econd.message() == "error -1" ); #endif - econd = error_condition( BOOST_ACCESS_ERROR_MACRO, generic_category ); + econd = error_condition( BOOST_ACCESS_ERROR_MACRO, generic_category() ); BOOST_TEST( econd.message() != "" ); BOOST_TEST( econd.message().substr( 0, 13) != "Unknown error" ); @@ -200,74 +200,74 @@ int main( int, char ** ) std::cout << "Windows tests...\n"; // these tests probe the Windows errc decoder // test the first entry in the decoder table: - ec = error_code( ERROR_ACCESS_DENIED, system_category ); + ec = error_code( ERROR_ACCESS_DENIED, system_category() ); BOOST_TEST( ec.value() == ERROR_ACCESS_DENIED ); BOOST_TEST( ec == errc::permission_denied ); BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied ); - BOOST_TEST( ec.default_error_condition().category() == generic_category ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); // test the second entry in the decoder table: - ec = error_code( ERROR_ALREADY_EXISTS, system_category ); + ec = error_code( ERROR_ALREADY_EXISTS, system_category() ); BOOST_TEST( ec.value() == ERROR_ALREADY_EXISTS ); BOOST_TEST( ec == errc::file_exists ); BOOST_TEST( ec.default_error_condition().value() == errc::file_exists ); - BOOST_TEST( ec.default_error_condition().category() == generic_category ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); // test the third entry in the decoder table: - ec = error_code( ERROR_BAD_UNIT, system_category ); + ec = error_code( ERROR_BAD_UNIT, system_category() ); BOOST_TEST( ec.value() == ERROR_BAD_UNIT ); BOOST_TEST( ec == errc::no_such_device ); BOOST_TEST( ec.default_error_condition().value() == errc::no_such_device ); - BOOST_TEST( ec.default_error_condition().category() == generic_category ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); // test the last non-Winsock entry in the decoder table: - ec = error_code( ERROR_WRITE_PROTECT, system_category ); + ec = error_code( ERROR_WRITE_PROTECT, system_category() ); BOOST_TEST( ec.value() == ERROR_WRITE_PROTECT ); BOOST_TEST( ec == errc::permission_denied ); BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied ); - BOOST_TEST( ec.default_error_condition().category() == generic_category ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); // test the last Winsock entry in the decoder table: - ec = error_code( WSAEWOULDBLOCK, system_category ); + ec = error_code( WSAEWOULDBLOCK, system_category() ); BOOST_TEST( ec.value() == WSAEWOULDBLOCK ); BOOST_TEST( ec == errc::operation_would_block ); BOOST_TEST( ec.default_error_condition().value() == errc::operation_would_block ); - BOOST_TEST( ec.default_error_condition().category() == generic_category ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); // test not-in-table condition: - ec = error_code( 1234567890, system_category ); + ec = error_code( 1234567890, system_category() ); BOOST_TEST( ec.value() == 1234567890 ); BOOST_TEST( ec.default_error_condition().value() == 1234567890 ); - BOOST_TEST( ec.default_error_condition().category() == system_category ); + BOOST_TEST( ec.default_error_condition().category() == system_category() ); #else // POSIX std::cout << "POSIX tests...\n"; - ec = error_code( EACCES, system_category ); - BOOST_TEST( ec == error_code( errc::permission_denied, system_category ) ); - BOOST_TEST( error_code( errc::permission_denied, system_category ) == ec ); + ec = error_code( EACCES, system_category() ); + BOOST_TEST( ec == error_code( errc::permission_denied, system_category() ) ); + BOOST_TEST( error_code( errc::permission_denied, system_category() ) == ec ); BOOST_TEST( ec == errc::permission_denied ); BOOST_TEST( errc::permission_denied == ec ); BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied ); - BOOST_TEST( ec.default_error_condition().category() == generic_category ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); # ifdef __CYGWIN__ std::cout << "Cygwin tests...\n"; ec = cygwin_error::no_package; BOOST_TEST( ec == cygwin_error::no_package ); - BOOST_TEST( ec == error_code( ENOPKG, system_category ) ); - BOOST_TEST( ec == error_code( cygwin_error::no_package, system_category ) ); - BOOST_TEST( ec.default_error_condition().category() == system_category ); + BOOST_TEST( ec == error_code( ENOPKG, system_category() ) ); + BOOST_TEST( ec == error_code( cygwin_error::no_package, system_category() ) ); + BOOST_TEST( ec.default_error_condition().category() == system_category() ); # elif defined(linux) || defined(__linux) || defined(__linux__) std::cout << "Linux tests...\n"; ec = linux_error::dot_dot_error; BOOST_TEST( ec == linux_error::dot_dot_error ); - BOOST_TEST( ec == error_code( EDOTDOT, system_category ) ); - BOOST_TEST( ec == error_code( linux_error::dot_dot_error, system_category ) ); - BOOST_TEST( ec.default_error_condition().category() == system_category ); + BOOST_TEST( ec == error_code( EDOTDOT, system_category() ) ); + BOOST_TEST( ec == error_code( linux_error::dot_dot_error, system_category() ) ); + BOOST_TEST( ec.default_error_condition().category() == system_category() ); # endif diff --git a/test/error_code_user_test.cpp b/test/error_code_user_test.cpp index a8e418b..4f4eb30 100644 --- a/test/error_code_user_test.cpp +++ b/test/error_code_user_test.cpp @@ -14,6 +14,8 @@ // Motivation was a Boost posting by Christopher Kohlhoff on June 28, 2006. +#define BOOST_SYSTEM_NO_DEPRECATED + #include #include #include @@ -40,7 +42,7 @@ boost::system::error_code my_mkdir( const std::string & path ) # else ::CreateDirectoryA( path.c_str(), 0 ) != 0 ? 0 : ::GetLastError(), # endif - boost::system::system_category ); + boost::system::system_category() ); } // ------------------------------------------------------------------------ // @@ -53,9 +55,9 @@ boost::system::error_code my_remove( const std::string & path ) { return boost::system::error_code( std::remove( path.c_str() ) == 0 ? 0 : errno, - boost::system::posix_category ); // OK for both Windows and POSIX - // Alternatively, could use posix_category - // on Windows and system_category on + boost::system::generic_category() ); // OK for both Windows and POSIX + // Alternatively, could use generic_category() + // on Windows and system_category() on // POSIX-based systems. } @@ -118,8 +120,8 @@ namespace boost boost::system::error_condition default_error_condition( int ev ) const { return ev == boo_boo - ? boost::system::error_condition( boost::system::posix::io_error, - boost::system::posix_category ) + ? boost::system::error_condition( boost::system::errc::io_error, + boost::system::generic_category() ) : boost::system::error_condition( ev, boost::lib3::lib3_error_category ); } @@ -180,8 +182,8 @@ namespace lib4 boost::system::error_condition default_error_condition( int ev ) const { return ev == boo_boo.value() - ? boost::system::error_condition( boost::system::posix::io_error, - boost::system::posix_category ) + ? boost::system::error_condition( boost::system::errc::io_error, + boost::system::generic_category() ) : boost::system::error_condition( ev, lib4::lib4_error_category ); } @@ -237,15 +239,15 @@ namespace lib4 // switch (ev) // { // case user_success: -// return boost::system::error_code(boost::system::posix::success, boost::system::posix_category); +// return boost::system::error_code(boost::system::errc::success, boost::system::generic_category()); // case user_permission_denied: -// return boost::system::error_code(boost::system::posix::permission_denied, boost::system::posix_category); +// return boost::system::error_code(boost::system::errc::permission_denied, boost::system::generic_category()); // case user_out_of_memory: -// return boost::system::error_code(boost::system::posix::not_enough_memory, boost::system::posix_category); +// return boost::system::error_code(boost::system::errc::not_enough_memory, boost::system::generic_category()); // default: // break; // } -// return boost::system::error_code(boost::system::posix::no_posix_equivalent, boost::system::posix_category); +// return boost::system::error_code(boost::system::errc::no_posix_equivalent, boost::system::generic_category()); // } // // }; @@ -264,8 +266,8 @@ namespace lib4 // // void check_success(const boost::system::error_code& ec, bool expect) // { -// BOOST_TEST( (ec == boost::system::posix::success) == expect ); -// if (ec == boost::system::posix::success) +// BOOST_TEST( (ec == boost::system::errc::success) == expect ); +// if (ec == boost::system::errc::success) // std::cout << "yes... " << (expect ? "ok" : "fail") << '\n'; // else // std::cout << "no... " << (expect ? "fail" : "ok") << '\n'; @@ -273,8 +275,8 @@ namespace lib4 // // void check_permission_denied(const boost::system::error_code& ec, bool expect) // { -// BOOST_TEST( (ec == boost::system::posix::permission_denied) == expect ); -// if (ec == boost::system::posix::permission_denied) +// BOOST_TEST( (ec == boost::system::errc::permission_denied) == expect ); +// if (ec == boost::system::errc::permission_denied) // std::cout << "yes... " << (expect ? "ok" : "fail") << '\n'; // else // std::cout << "no... " << (expect ? "fail" : "ok") << '\n'; @@ -282,8 +284,8 @@ namespace lib4 // // void check_out_of_memory(const boost::system::error_code& ec, bool expect) // { -// BOOST_TEST( (ec == boost::system::posix::not_enough_memory) == expect ); -// if (ec == boost::system::posix::not_enough_memory) +// BOOST_TEST( (ec == boost::system::errc::not_enough_memory) == expect ); +// if (ec == boost::system::errc::not_enough_memory) // std::cout << "yes... " << (expect ? "ok" : "fail") << '\n'; // else // std::cout << "no... " << (expect ? "fail" : "ok") << '\n'; @@ -295,23 +297,23 @@ namespace lib4 // printf("=====\n"); // boost::system::error_code ec; // check_success(ec, true); -// check_success(boost::system::posix::success, true); -// check_success(boost::system::posix::permission_denied, false); -// check_success(boost::system::posix::not_enough_memory, false); +// check_success(boost::system::errc::success, true); +// check_success(boost::system::errc::permission_denied, false); +// check_success(boost::system::errc::not_enough_memory, false); // check_success(user_success, true); // check_success(user_permission_denied, false); // check_success(user_out_of_memory, false); // check_permission_denied(ec, false); -// check_permission_denied(boost::system::posix::success, false); -// check_permission_denied(boost::system::posix::permission_denied, true); -// check_permission_denied(boost::system::posix::not_enough_memory, false); +// check_permission_denied(boost::system::errc::success, false); +// check_permission_denied(boost::system::errc::permission_denied, true); +// check_permission_denied(boost::system::errc::not_enough_memory, false); // check_permission_denied(user_success, false); // check_permission_denied(user_permission_denied, true); // check_permission_denied(user_out_of_memory, false); // check_out_of_memory(ec, false); -// check_out_of_memory(boost::system::posix::success, false); -// check_out_of_memory(boost::system::posix::permission_denied, false); -// check_out_of_memory(boost::system::posix::not_enough_memory, true); +// check_out_of_memory(boost::system::errc::success, false); +// check_out_of_memory(boost::system::errc::permission_denied, false); +// check_out_of_memory(boost::system::errc::not_enough_memory, true); // check_out_of_memory(user_success, false); // check_out_of_memory(user_permission_denied, false); // check_out_of_memory(user_out_of_memory, true); @@ -347,8 +349,8 @@ int main( int, char *[] ) std::cout << "ec.value() is " << ec.value() << '\n'; BOOST_TEST( ec ); - BOOST_TEST( ec == boost::system::posix::no_such_file_or_directory ); - BOOST_TEST( ec.category() == boost::system::system_category ); + BOOST_TEST( ec == boost::system::errc::no_such_file_or_directory ); + BOOST_TEST( ec.category() == boost::system::system_category() ); // Library 2 tests: @@ -356,8 +358,8 @@ int main( int, char *[] ) std::cout << "ec.value() is " << ec.value() << '\n'; BOOST_TEST( ec ); - BOOST_TEST( ec == boost::system::posix::no_such_file_or_directory ); - BOOST_TEST( ec.category() == boost::system::posix_category ); + BOOST_TEST( ec == boost::system::errc::no_such_file_or_directory ); + BOOST_TEST( ec.category() == boost::system::generic_category() ); // Library 3 tests: @@ -369,7 +371,7 @@ int main( int, char *[] ) BOOST_TEST( ec.value() == boost::lib3::boo_boo ); BOOST_TEST( ec.category() == boost::lib3::lib3_error_category ); - BOOST_TEST( ec == boost::system::posix::io_error ); + BOOST_TEST( ec == boost::system::errc::io_error ); boost::system::error_code ec3( boost::lib3::boo_boo+100, boost::lib3::lib3_error_category ); @@ -387,7 +389,7 @@ int main( int, char *[] ) BOOST_TEST( ec.value() == lib4::boo_boo.value() ); BOOST_TEST( ec.category() == lib4::lib4_error_category ); - BOOST_TEST( ec == boost::system::posix::io_error ); + BOOST_TEST( ec == boost::system::errc::io_error ); boost::system::error_code ec4( lib4::boo_boo.value()+100, lib4::lib4_error_category ); diff --git a/test/header_only_test.cpp b/test/header_only_test.cpp index 12f22c0..6f0943d 100644 --- a/test/header_only_test.cpp +++ b/test/header_only_test.cpp @@ -18,6 +18,6 @@ int main( int, char*[] ) { - boost::system::error_code ec( 0, boost::system::system_category ); + boost::system::error_code ec( 0, boost::system::system_category() ); return ::boost::report_errors(); } diff --git a/test/initialization_test.cpp b/test/initialization_test.cpp index c481e5a..8c7c988 100644 --- a/test/initialization_test.cpp +++ b/test/initialization_test.cpp @@ -24,5 +24,5 @@ struct foo int main( int, char ** ) { - return 0; + return ::boost::report_errors(); } diff --git a/test/system_error_test.cpp b/test/system_error_test.cpp index 47f3c2e..9f7c996 100644 --- a/test/system_error_test.cpp +++ b/test/system_error_test.cpp @@ -37,7 +37,7 @@ namespace { std::cout << "test " << desc << "\n what() returns \"" << ex.what() << "\"\n"; BOOST_TEST( ex.code().value() == v ); - BOOST_TEST( ex.code().category() == system_category ); + BOOST_TEST( ex.code().category() == system_category() ); # ifdef BOOST_WINDOWS_API LANGID language_id; # if !defined(__MINGW32__) && !defined(__CYGWIN__) @@ -63,25 +63,25 @@ int main( int, char *[] ) { // all constructors, in the same order as they appear in the header: - system_error c1_0( error_code(0, system_category) ); - system_error c1_1( error_code(1, system_category) ); - system_error c1_2u( error_code(uvalue, system_category) ); + system_error c1_0( error_code(0, system_category()) ); + system_error c1_1( error_code(1, system_category()) ); + system_error c1_2u( error_code(uvalue, system_category()) ); - system_error c2_0( error_code(0, system_category), string("c2_0") ); - system_error c2_1( error_code(1, system_category), string("c2_1") ); + system_error c2_0( error_code(0, system_category()), string("c2_0") ); + system_error c2_1( error_code(1, system_category()), string("c2_1") ); - system_error c3_0( error_code(0, system_category), "c3_0" ); - system_error c3_1( error_code(1, system_category), "c3_1" ); + system_error c3_0( error_code(0, system_category()), "c3_0" ); + system_error c3_1( error_code(1, system_category()), "c3_1" ); - system_error c4_0( 0, system_category ); - system_error c4_1( 1, system_category ); - system_error c4_2u( uvalue, system_category ); + system_error c4_0( 0, system_category() ); + system_error c4_1( 1, system_category() ); + system_error c4_2u( uvalue, system_category() ); - system_error c5_0( 0, system_category, string("c5_0") ); - system_error c5_1( 1, system_category, string("c5_1") ); + system_error c5_0( 0, system_category(), string("c5_0") ); + system_error c5_1( 1, system_category(), string("c5_1") ); - system_error c6_0( 0, system_category, "c6_0" ); - system_error c6_1( 1, system_category, "c6_1" ); + system_error c6_0( 0, system_category(), "c6_0" ); + system_error c6_1( 1, system_category(), "c6_1" ); TEST( c1_0, 0, "The operation completed successfully" ); TEST( c1_1, 1, "Incorrect function" ); diff --git a/test/throw_test.cpp b/test/throw_test.cpp index 998fc20..c42f422 100644 --- a/test/throw_test.cpp +++ b/test/throw_test.cpp @@ -25,7 +25,7 @@ namespace boost { BOOST_SYSTEM_DECL void throw_test() { - throw system_error(9999, get_system_category(), "boo boo"); + throw system_error(9999, system_category(), "boo boo"); } } } From 05a6666107167c32fe5cdc34c1c9dc7a4b4aec56 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 31 May 2010 11:57:01 +0000 Subject: [PATCH 12/30] Fix typo [SVN r62342] --- doc/reference.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/reference.html b/doc/reference.html index 174653b..19b4519 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -169,7 +169,7 @@ fixed by globally adding () to these names to turn them into function calls.

system_category() -

User-defined BOOST_POSIX_API and BOOST_WINDOWS_API are no longer supported.

+

User-defined BOOST_POSIX_API and BOOST_WINDOWS_API macros are no longer supported.

Header <boost/system/error_code.hpp>

<boost/system/error_code.hpp> synopsis

@@ -839,7 +839,7 @@ application program interfaces.


Revised -May 29, 2010 +May 31, 2010

© Copyright Beman Dawes, 2006, 2007, 2008

From 5dc1c47d217297926605c7a9ede270ad4241fe6b Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 20 Jun 2010 18:02:14 +0000 Subject: [PATCH 13/30] Move minimal.css to doc/src. [SVN r63148] --- doc/index.html | 2 +- doc/reference.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/index.html b/doc/index.html index bbc331a..38ab455 100644 --- a/doc/index.html +++ b/doc/index.html @@ -6,7 +6,7 @@ Boost System Library - + diff --git a/doc/reference.html b/doc/reference.html index 19b4519..7b592e1 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -6,7 +6,7 @@ System Library Reference - + From f1b9778af48869f1909ab2d1ddff0087e1903575 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 21 Jun 2010 12:25:40 +0000 Subject: [PATCH 14/30] Fix #3474, memory leak on exception. First reported by Chis Kohlhoff. [SVN r63184] --- src/error_code.cpp | 27 ++++++--------------- src/local_free_on_destruction.hpp | 40 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 src/local_free_on_destruction.hpp diff --git a/src/error_code.cpp b/src/error_code.cpp index dfd4a0e..bd87403 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -29,8 +29,9 @@ using namespace boost::system::errc; # if defined( BOOST_WINDOWS_API ) # include +# include "local_free_on_destruction.hpp" # ifndef ERROR_INCORRECT_SIZE -# define ERROR_INCORRECT_SIZE ERROR_BAD_ARGUMENTS +# define ERROR_INCORRECT_SIZE ERROR_BAD_ARGUMENTS # endif # endif @@ -340,25 +341,11 @@ namespace return generic_category().message( ev ); } # else -// TODO: - -//Some quick notes on the implementation (sorry for the noise if -//someone has already mentioned them): -// -//- The ::LocalFree() usage isn't exception safe. -// -//See: -// -// -// -//in the implementation of what() for an example. -// -//Cheers, -//Chris + std::string system_error_category::message( int ev ) const { # ifndef BOOST_NO_ANSI_APIS - LPVOID lpMsgBuf; + LPVOID lpMsgBuf = 0; DWORD retval = ::FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | @@ -370,13 +357,13 @@ namespace 0, NULL ); + detail::local_free_on_destruction lfod(lpMsgBuf); if (retval == 0) return std::string("Unknown error"); std::string str( static_cast(lpMsgBuf) ); - ::LocalFree( lpMsgBuf ); // free the buffer # else // WinCE workaround - LPVOID lpMsgBuf; + LPVOID lpMsgBuf = 0; DWORD retval = ::FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | @@ -388,6 +375,7 @@ namespace 0, NULL ); + detail::local_free_on_destruction lfod(lpMsgBuf); if (retval == 0) return std::string("Unknown error"); @@ -397,7 +385,6 @@ namespace return std::string("Unknown error"); std::string str( narrow_buffer ); - ::LocalFree( lpMsgBuf ); // free the buffer # endif while ( str.size() && (str[str.size()-1] == '\n' || str[str.size()-1] == '\r') ) diff --git a/src/local_free_on_destruction.hpp b/src/local_free_on_destruction.hpp new file mode 100644 index 0000000..110024f --- /dev/null +++ b/src/local_free_on_destruction.hpp @@ -0,0 +1,40 @@ +// local_free_on_exit.hpp ------------------------------------------------------------// + +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2010 Beman Dawes + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// This is derived from boost/asio/detail/local_free_on_block_exit.hpp to avoid +// a dependency on asio. Thanks to Chris Kohlhoff for pointing it out. + +#ifndef BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP +#define BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP + +namespace boost { +namespace system { +namespace detail { + +class local_free_on_destruction +{ +public: + explicit local_free_on_destruction(void* p) + : p_(p) {} + + ~local_free_on_destruction() + { + ::LocalFree(p_); + } + +private: + void* p_; + local_free_on_destruction(const local_free_on_destruction&); // = deleted + local_free_on_destruction& operator=(const local_free_on_destruction&); // = deleted +}; + +} // namespace detail +} // namespace system +} // namespace boost + +#endif // BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP From 9415b8c12ed6e7585abed34af62aa6881d89397a Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 29 Jun 2010 12:33:26 +0000 Subject: [PATCH 15/30] Fix #4254 and other documentation mistakes and bring into closer conformance with the C++ standard library working paper. [SVN r63426] --- doc/reference.html | 63 +++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/doc/reference.html b/doc/reference.html index 7b592e1..05c2102 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -370,8 +370,8 @@ this subclause.

Returns:  error_condition( ev, *this ).

-

 [--Note: Derived classes will typically convert ev - to some portable error_category, such as generic_category, +

 [--Note: Derived classes will typically convert ev + to some portable error_category, such as generic_category(), and return it as an error_condition for that category. --end note]

@@ -422,10 +422,6 @@ non-member functions identifying portable error conditions.

Throws: Nothing.

-

Class error_category -predefined objects

-

Predefined objects system_category -and generic_category identify system specific error codes and portable error conditions, respectively.

Class error_code

The class error_code describes an object used to hold error code @@ -447,14 +443,12 @@ error_code synopsis error_code(); error_code( val, const error_category & cat ); template <class ErrorCodeEnum> - error_code( ErrorCodeEnum e, - typename enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0); + error_code( ErrorCodeEnum e ); // modifiers: void assign( int val, const error_category & cat ); template<typename ErrorCodeEnum> - typename enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type & - operator=( ErrorCodeEnum val );; + error_code & operator=( ErrorCodeEnum val );; void clear(); // observers: @@ -476,7 +470,7 @@ error_code constructors

error_code();

Effects: Constructs an object of type error_code.

-

Postconditions: val_ == 0 && cat_ == &system_category.

+

Postconditions: val_ == 0 && cat_ == &system_category().

Throws: Nothing.

error_code( int val, const error_category & cat );
@@ -486,12 +480,14 @@ error_code constructors

Throws: Nothing.

template <class ErrorCodeEnum>
-  error_code( errorCodeEnum val,
-    typename enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0);
+ error_code( ErrorCodeEnum val );

Effects: Constructs an object of type error_code.

Postconditions: *this == make_error_code( val ).

Throws: Nothing.

+

Remarks: This constructor shall not participate in overload + resolution unless is_error_code_enum<ErrorCodeEnum>::value is + true.

Class error_code modifiers

@@ -501,15 +497,17 @@ error_code modifiers

Throws: Nothing.

template<typename ErrorCodeEnum>
-  typename enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type &
-    operator=( ErrorCodeEnum val );
+ error_code & operator=( ErrorCodeEnum val );

Postconditions: *this == make_error_code( val ).

Throws: Nothing.

+

Remarks: This operator shall not participate in overload resolution + unless is_error_code_enum<ErrorCodeEnum>::value is true.

void clear();

-

postcondition: value() == 0 && category() == generic_category

+

postcondition: value() == 0 && category() == + system_category()

Class error_code observers

@@ -565,14 +563,12 @@ implementation specific. --end note ]

error_condition(); error_condition( int val, const error_category & cat ); template <class ErrorConditionEnum> - error_condition( errorConditionEnum val, - typename enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0 ); + error_condition( errorConditionEnum val ); // modifiers: void assign( int val, const error_category & cat ); template<typename ErrorConditionEnum> - typename enable_if<is_error_condition_enum<ErrorConditionEnum>, error_code>::type & - operator=( ErrorConditionEnum val ); + error_condition & operator=( ErrorConditionEnum val ); void clear(); // observers: @@ -593,7 +589,7 @@ constructors
error_condition(); 

Effects: Constructs an object of type error_condition.

-

Postconditions: val_ == 0 and cat_ == &generic_category.

+

Postconditions: val_ == 0 and cat_ == &generic_category().

Throws: Nothing.

error_condition( int val, const error_category & cat );
@@ -603,12 +599,14 @@ constructors

Throws: Nothing.

template <class ErrorConditionEnum>
-  error_condition( errorConditionEnum val,
-    typename enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0 );
+ error_condition( ErrorConditionEnum e );

Effects: Constructs an object of type error_condition.

-

Postconditions: *this == make_error_condition( val ).

+

Postconditions: *this == make_error_condition(e).

Throws: Nothing.

+

Remarks: This constructor shall not participate in overload + resolution unless is_error_condition_enum<ErrorConditionEnum>::value + is true.

Class error_condition modifiers

@@ -618,15 +616,18 @@ modifiers

Throws: Nothing.

template<typename ErrorConditionEnum>
-  typename enable_if<is_error_condition_enum<ErrorConditionEnum>, error_code>::type &
-    operator=( ErrorConditionEnum val );
+ error_condition & operator=( ErrorConditionEnum e );
-

Postconditions: *this == make_error_condition( val ).

+

Postconditions: *this == make_error_condition( e ).

+

Returns: *this.

Throws: Nothing.

+

Remarks: This operator shall not participate in overload resolution + unless is_error_condition_enum<ErrorConditionEnum>::value is + true.

void clear();

-

postcondition: value() == 0 && category() == generic_category

+

postcondition: value() == 0 && category() == generic_category()

Class error_condition observers

@@ -738,11 +739,11 @@ bool operator!=( const error_condition & condition, const error_code & c
error_code make_error_code( errc::errc_t e );
-

Returns: error_code( e, generic_category).

+

Returns: error_code( e, generic_category()).

error_condition make_error_condition( errc::errc_t e );
-

Returns: error_condition( static_cast<int>( e ), generic_category).

+

Returns: error_condition( static_cast<int>( e ), generic_category()).

template <class charT, class traits>
@@ -839,7 +840,7 @@ application program interfaces.


Revised -May 31, 2010 +June 29, 2010

© Copyright Beman Dawes, 2006, 2007, 2008

From 2e93f04826648a7d8119050d03c18b9bd11b2d2d Mon Sep 17 00:00:00 2001 From: "K. Noel Belcourt" Date: Wed, 1 Dec 2010 05:29:24 +0000 Subject: [PATCH 16/30] Fix PGI non-compliance (portability issue). Patch supplied by William Bohnhoff at Sandia. [SVN r66940] --- src/error_code.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/error_code.cpp b/src/error_code.cpp index bd87403..bcdbea9 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -39,6 +39,9 @@ using namespace boost::system::errc; namespace { +#if defined(__PGI) + using boost::system::errc::invalid_argument; +#endif // standard error categories ---------------------------------------------// class generic_error_category : public error_category From 322e46fc4921a75f27642897fe1f8fd4683adaed Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 16 Jan 2011 12:07:26 +0000 Subject: [PATCH 17/30] Boost.Ratio/Chrono: Added boost/ratio/include.hpp file and make use of boost/ratio/ratio.hpp when all the files are not needed [SVN r68183] --- include/boost/system/api_config.hpp | 21 ++++++++++++++------- include/boost/system/config.hpp | 22 ++++++++++++++++++---- include/boost/system/cygwin_error.hpp | 8 ++++---- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/include/boost/system/api_config.hpp b/include/boost/system/api_config.hpp index 28b8bec..f294c92 100644 --- a/include/boost/system/api_config.hpp +++ b/include/boost/system/api_config.hpp @@ -21,22 +21,29 @@ //--------------------------------------------------------------------------------------// -#ifndef BOOST_SYSTEM_API_CONFIG_HPP +#ifndef BOOST_SYSTEM_API_CONFIG_HPP #define BOOST_SYSTEM_API_CONFIG_HPP -# if defined(BOOST_POSIX_API) || defined(BOOST_WINDOWS_API) -# error user defined BOOST_POSIX_API or BOOST_WINDOWS_API not supported +# if defined(BOOST_SYSTEM_POSIX_API) || defined(BOOST_SYSTEM_WINDOWS_API) +# error user defined BOOST_SYSTEM_POSIX_API or BOOST_SYSTEM_WINDOWS_API not supported # endif -// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use +// BOOST_SYSTEM_POSIX_API or BOOST_SYSTEM_WINDOWS_API specify which API to use // Cygwin/MinGW does not predefine _WIN32. // Standalone MinGW and all other known Windows compilers do predefine _WIN32 // Compilers that predefine _WIN32 or __MINGW32__ do so for Windows 64-bit builds too. +# if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) ) +# define BOOST_SYSTEM_WINDOWS_API +# else +# define BOOST_SYSTEM_POSIX_API +# endif + +//# if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)) # if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin # define BOOST_WINDOWS_API # else -# define BOOST_POSIX_API +# define BOOST_POSIX_API # endif - -#endif // BOOST_SYSTEM_API_CONFIG_HPP + +#endif // BOOST_SYSTEM_API_CONFIG_HPP diff --git a/include/boost/system/config.hpp b/include/boost/system/config.hpp index bf78051..0b19da8 100644 --- a/include/boost/system/config.hpp +++ b/include/boost/system/config.hpp @@ -7,11 +7,23 @@ // See http://www.boost.org/libs/system for documentation. -#ifndef BOOST_SYSTEM_CONFIG_HPP +#ifndef BOOST_SYSTEM_CONFIG_HPP #define BOOST_SYSTEM_CONFIG_HPP #include -#include // for BOOST_POSIX_API or BOOST_WINDOWS_API + +#if defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_USE_WINDOWS_H) +#define BOOST_USE_WINDOWS_H +#endif + +#include // for BOOST_SYSTEM_POSIX_API or BOOST_SYSTEM_WINDOWS_API + +#ifdef BOOST_SYSTEM_INLINED +#define BOOST_SYSTEM_INLINE inline +#define BOOST_SYSTEM_DECL + +#else +#define BOOST_SYSTEM_INLINE // This header implements separate compilation features as described in // http://www.boost.org/more/separate_compilation.html @@ -21,14 +33,14 @@ #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) # if defined(BOOST_SYSTEM_SOURCE) # define BOOST_SYSTEM_DECL BOOST_SYMBOL_EXPORT -# else +# else # define BOOST_SYSTEM_DECL BOOST_SYMBOL_IMPORT # endif #else # define BOOST_SYSTEM_DECL #endif -// enable automatic library variant selection ----------------------------------------// +// enable automatic library variant selection ----------------------------------------// #if !defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SYSTEM_NO_LIB) // @@ -48,5 +60,7 @@ #include #endif // auto-linking disabled +#endif // BOOST_SYSTEM_INLINED + #endif // BOOST_SYSTEM_CONFIG_HPP diff --git a/include/boost/system/cygwin_error.hpp b/include/boost/system/cygwin_error.hpp index ea3528b..a042db2 100644 --- a/include/boost/system/cygwin_error.hpp +++ b/include/boost/system/cygwin_error.hpp @@ -7,8 +7,8 @@ // See library home page at http://www.boost.org/libs/system -#ifndef BOOST_CYGWIN_ERROR_HPP -#define BOOST_CYGWIN_ERROR_HPP +#ifndef BOOST_SYSTEM_CYGWIN_ERROR_HPP +#define BOOST_SYSTEM_CYGWIN_ERROR_HPP // This header is effectively empty for compiles on operating systems where // it is not applicable. @@ -27,7 +27,7 @@ namespace boost // User code should use the portable "posix" enums for POSIX errors; this // allows such code to be portable to non-POSIX systems. For the non-POSIX - // errno values that POSIX-based systems typically provide in addition to + // errno values that POSIX-based systems typically provide in addition to // POSIX values, use the system specific enums below. namespace cygwin_error @@ -53,4 +53,4 @@ namespace boost #endif // __CYGWIN__ -#endif // BOOST_CYGWIN_ERROR_HPP +#endif // BOOST_SYSTEM_CYGWIN_ERROR_HPP From 5c3a2b0481e9b5b7bbaa05b9eb95c651eac0d42f Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 15 Aug 2011 14:34:04 +0000 Subject: [PATCH 18/30] Fix #5778 for INTEGRITY operating system [SVN r73775] --- src/error_code.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/error_code.cpp b/src/error_code.cpp index bcdbea9..8f4fc9e 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -84,6 +84,7 @@ namespace # if defined(BOOST_WINDOWS_API) || defined(__hpux) || defined(__sun)\ || (defined(__linux) && (!defined(__USE_XOPEN2K) || defined(BOOST_SYSTEM_USE_STRERROR)))\ || (defined(__osf__) && !defined(_REENTRANT))\ + || (defined(__INTEGRITY))\ || (defined(__vms))\ || (defined(__QNXNTO__)) const char * c_str = std::strerror( ev ); From 46d95f807c4776adbd09bd15c361b07f12f0563f Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 28 Sep 2011 15:57:44 +0000 Subject: [PATCH 19/30] Fix comment typo (Rob Stewart) [SVN r74599] --- src/error_code.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error_code.cpp b/src/error_code.cpp index 8f4fc9e..6772d15 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -74,7 +74,7 @@ namespace // strerror_r is preferred because it is always thread safe, // however, we fallback to strerror in certain cases because: // -- Windows doesn't provide strerror_r. - // -- HP and Sundo provide strerror_r on newer systems, but there is + // -- HP and Sun do provide strerror_r on newer systems, but there is // no way to tell if is available at runtime and in any case their // versions of strerror are thread safe anyhow. // -- Linux only sometimes provides strerror_r. From 7671b1291c874c739d57082bb3f46f31bdfa90a7 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 15 Apr 2012 19:16:49 +0000 Subject: [PATCH 20/30] Tighten config.hpp and Jamfile logic before attaching static build problems. [SVN r77997] --- include/boost/system/config.hpp | 17 +++++++++++++++++ test/Jamfile.v2 | 1 + 2 files changed, 18 insertions(+) diff --git a/include/boost/system/config.hpp b/include/boost/system/config.hpp index 0b19da8..728bd81 100644 --- a/include/boost/system/config.hpp +++ b/include/boost/system/config.hpp @@ -28,6 +28,23 @@ // This header implements separate compilation features as described in // http://www.boost.org/more/separate_compilation.html +// normalize macros ------------------------------------------------------------------// + +#if !defined(BOOST_SYSTEM_DYN_LINK) && !defined(BOOST_SYSTEM_STATIC_LINK) \ + && !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK) +# error Must define BOOST_ALL_DYN_LINK, BOOST_ALL_DYN_LINK, BOOST_SYSTEM_DYN_LINK, or BOOST_SYSTEM_STATIC_LINK +#endif + +#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_SYSTEM_DYN_LINK) +# define BOOST_SYSTEM_DYN_LINK +#elif defined(BOOST_ALL_STATIC_LINK) && !defined(BOOST_SYSTEM_STATIC_LINK) +# define BOOST_SYSTEM_STATIC_LINK +#endif + +#if defined(BOOST_SYSTEM_DYN_LINK) && defined(BOOST_SYSTEM_STATIC_LINK) +# error Must not define both BOOST_SYSTEM_DYN_LINK and BOOST_SYSTEM_STATIC_LINK +#endif + // enable dynamic or static linking as requested --------------------------------------// #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 043a36f..1ab7442 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -16,6 +16,7 @@ project lib throw_test : throw_test.cpp : shared:BOOST_SYSTEM_DYN_LINK=1 + static:BOOST_SYSTEM_STATIC_LINK=1 ; From af17253f907a0ab9bb0a1f9d1e706255768273ba Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 15 Apr 2012 20:16:18 +0000 Subject: [PATCH 21/30] Make BOOST_x_DYN_LINK tbe default [SVN r77999] --- include/boost/system/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/system/config.hpp b/include/boost/system/config.hpp index 728bd81..51e104c 100644 --- a/include/boost/system/config.hpp +++ b/include/boost/system/config.hpp @@ -32,7 +32,7 @@ #if !defined(BOOST_SYSTEM_DYN_LINK) && !defined(BOOST_SYSTEM_STATIC_LINK) \ && !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK) -# error Must define BOOST_ALL_DYN_LINK, BOOST_ALL_DYN_LINK, BOOST_SYSTEM_DYN_LINK, or BOOST_SYSTEM_STATIC_LINK +# define BOOST_SYSTEM_DYN_LINK #endif #if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_SYSTEM_DYN_LINK) From 5183a336c2b88359c08a8311727dd684770c1a7a Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 30 Apr 2012 14:01:34 +0000 Subject: [PATCH 22/30] Revert to BOOST_SYSTEM_STATIC_LINK as the default if no linkage macros supplied. See http://www.boost.org/doc/libs/1_49_0/libs/config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_for_libraries_with_separate_source_code [SVN r78267] --- include/boost/system/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/system/config.hpp b/include/boost/system/config.hpp index 51e104c..a0bd874 100644 --- a/include/boost/system/config.hpp +++ b/include/boost/system/config.hpp @@ -32,7 +32,7 @@ #if !defined(BOOST_SYSTEM_DYN_LINK) && !defined(BOOST_SYSTEM_STATIC_LINK) \ && !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK) -# define BOOST_SYSTEM_DYN_LINK +# define BOOST_SYSTEM_STATIC_LINK #endif #if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_SYSTEM_DYN_LINK) From bdcfe6142916fa45ceae6c1787f7fa7129df3530 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 4 May 2012 20:12:58 +0000 Subject: [PATCH 23/30] Revert portion of 68183. This changeset was aimed at other libraries, but inadvertently modified three boost/system headers. [SVN r78325] --- include/boost/system/api_config.hpp | 21 +++++++-------------- include/boost/system/config.hpp | 22 ++++------------------ include/boost/system/cygwin_error.hpp | 8 ++++---- 3 files changed, 15 insertions(+), 36 deletions(-) diff --git a/include/boost/system/api_config.hpp b/include/boost/system/api_config.hpp index f294c92..28b8bec 100644 --- a/include/boost/system/api_config.hpp +++ b/include/boost/system/api_config.hpp @@ -21,29 +21,22 @@ //--------------------------------------------------------------------------------------// -#ifndef BOOST_SYSTEM_API_CONFIG_HPP +#ifndef BOOST_SYSTEM_API_CONFIG_HPP #define BOOST_SYSTEM_API_CONFIG_HPP -# if defined(BOOST_SYSTEM_POSIX_API) || defined(BOOST_SYSTEM_WINDOWS_API) -# error user defined BOOST_SYSTEM_POSIX_API or BOOST_SYSTEM_WINDOWS_API not supported +# if defined(BOOST_POSIX_API) || defined(BOOST_WINDOWS_API) +# error user defined BOOST_POSIX_API or BOOST_WINDOWS_API not supported # endif -// BOOST_SYSTEM_POSIX_API or BOOST_SYSTEM_WINDOWS_API specify which API to use +// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use // Cygwin/MinGW does not predefine _WIN32. // Standalone MinGW and all other known Windows compilers do predefine _WIN32 // Compilers that predefine _WIN32 or __MINGW32__ do so for Windows 64-bit builds too. -# if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) ) -# define BOOST_SYSTEM_WINDOWS_API -# else -# define BOOST_SYSTEM_POSIX_API -# endif - -//# if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)) # if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin # define BOOST_WINDOWS_API # else -# define BOOST_POSIX_API +# define BOOST_POSIX_API # endif - -#endif // BOOST_SYSTEM_API_CONFIG_HPP + +#endif // BOOST_SYSTEM_API_CONFIG_HPP diff --git a/include/boost/system/config.hpp b/include/boost/system/config.hpp index a0bd874..b128717 100644 --- a/include/boost/system/config.hpp +++ b/include/boost/system/config.hpp @@ -7,23 +7,11 @@ // See http://www.boost.org/libs/system for documentation. -#ifndef BOOST_SYSTEM_CONFIG_HPP +#ifndef BOOST_SYSTEM_CONFIG_HPP #define BOOST_SYSTEM_CONFIG_HPP #include - -#if defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_USE_WINDOWS_H) -#define BOOST_USE_WINDOWS_H -#endif - -#include // for BOOST_SYSTEM_POSIX_API or BOOST_SYSTEM_WINDOWS_API - -#ifdef BOOST_SYSTEM_INLINED -#define BOOST_SYSTEM_INLINE inline -#define BOOST_SYSTEM_DECL - -#else -#define BOOST_SYSTEM_INLINE +#include // for BOOST_POSIX_API or BOOST_WINDOWS_API // This header implements separate compilation features as described in // http://www.boost.org/more/separate_compilation.html @@ -50,14 +38,14 @@ #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) # if defined(BOOST_SYSTEM_SOURCE) # define BOOST_SYSTEM_DECL BOOST_SYMBOL_EXPORT -# else +# else # define BOOST_SYSTEM_DECL BOOST_SYMBOL_IMPORT # endif #else # define BOOST_SYSTEM_DECL #endif -// enable automatic library variant selection ----------------------------------------// +// enable automatic library variant selection ----------------------------------------// #if !defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SYSTEM_NO_LIB) // @@ -77,7 +65,5 @@ #include #endif // auto-linking disabled -#endif // BOOST_SYSTEM_INLINED - #endif // BOOST_SYSTEM_CONFIG_HPP diff --git a/include/boost/system/cygwin_error.hpp b/include/boost/system/cygwin_error.hpp index a042db2..ea3528b 100644 --- a/include/boost/system/cygwin_error.hpp +++ b/include/boost/system/cygwin_error.hpp @@ -7,8 +7,8 @@ // See library home page at http://www.boost.org/libs/system -#ifndef BOOST_SYSTEM_CYGWIN_ERROR_HPP -#define BOOST_SYSTEM_CYGWIN_ERROR_HPP +#ifndef BOOST_CYGWIN_ERROR_HPP +#define BOOST_CYGWIN_ERROR_HPP // This header is effectively empty for compiles on operating systems where // it is not applicable. @@ -27,7 +27,7 @@ namespace boost // User code should use the portable "posix" enums for POSIX errors; this // allows such code to be portable to non-POSIX systems. For the non-POSIX - // errno values that POSIX-based systems typically provide in addition to + // errno values that POSIX-based systems typically provide in addition to // POSIX values, use the system specific enums below. namespace cygwin_error @@ -53,4 +53,4 @@ namespace boost #endif // __CYGWIN__ -#endif // BOOST_SYSTEM_CYGWIN_ERROR_HPP +#endif // BOOST_CYGWIN_ERROR_HPP From dc61a075b22d850e74e219ab84dffc47b5705a43 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 28 Aug 2012 14:51:55 +0000 Subject: [PATCH 24/30] Add some infrastructure [SVN r80280] --- .../system_msvc/system_dll/system_dll.vcxproj | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 test/system_msvc/system_dll/system_dll.vcxproj diff --git a/test/system_msvc/system_dll/system_dll.vcxproj b/test/system_msvc/system_dll/system_dll.vcxproj new file mode 100644 index 0000000..e4092a3 --- /dev/null +++ b/test/system_msvc/system_dll/system_dll.vcxproj @@ -0,0 +1,100 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {35E7326A-90AB-471A-AB2A-C5BCDA0AFD38} + Win32Proj + system_dll + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;SYSTEM_DLL_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + + + + + + + + + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;SYSTEM_DLL_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + + + + + + + + + + + + + \ No newline at end of file From 8fbde538f30574abd95530138ea75249552b58cf Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 28 Aug 2012 14:53:18 +0000 Subject: [PATCH 25/30] Add some infrastructure [SVN r80281] --- .../system_error_test.vcxproj | 89 +++++++++++++++++++ test/system_msvc/system_msvc.sln | 49 ++++------ 2 files changed, 104 insertions(+), 34 deletions(-) create mode 100644 test/system_msvc/system_error_test/system_error_test.vcxproj diff --git a/test/system_msvc/system_error_test/system_error_test.vcxproj b/test/system_msvc/system_error_test/system_error_test.vcxproj new file mode 100644 index 0000000..0d083cb --- /dev/null +++ b/test/system_msvc/system_error_test/system_error_test.vcxproj @@ -0,0 +1,89 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {ADFCC237-53E3-47D8-949B-C520C332D9CB} + Win32Proj + system_error_test + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + {35e7326a-90ab-471a-ab2a-c5bcda0afd38} + + + + + + \ No newline at end of file diff --git a/test/system_msvc/system_msvc.sln b/test/system_msvc/system_msvc.sln index d3d2746..f47a4c1 100644 --- a/test/system_msvc/system_msvc.sln +++ b/test/system_msvc/system_msvc.sln @@ -1,27 +1,16 @@  -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "error_code_test", "error_code_test\error_code_test.vcproj", "{81960557-E9A9-4E81-AC96-9E11C33CB058}" +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "error_code_test", "error_code_test\error_code_test.vcxproj", "{81960557-E9A9-4E81-AC96-9E11C33CB058}" ProjectSection(ProjectDependencies) = postProject - {22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E} + {35E7326A-90AB-471A-AB2A-C5BCDA0AFD38} = {35E7326A-90AB-471A-AB2A-C5BCDA0AFD38} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system_error_test", "system_error_test\system_error_test.vcproj", "{CBD12E59-99E5-4F35-9B66-0554D0FBDB76}" - ProjectSection(ProjectDependencies) = postProject - {22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system_dll", "system_dll\system_dll.vcxproj", "{35E7326A-90AB-471A-AB2A-C5BCDA0AFD38}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dynamic_link_test", "dynamic_link_test\dynamic_link_test.vcproj", "{AD186B11-9132-48A9-9F24-3522C2310B0D}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system_error_test", "system_error_test\system_error_test.vcxproj", "{ADFCC237-53E3-47D8-949B-C520C332D9CB}" ProjectSection(ProjectDependencies) = postProject - {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7} = {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7} - {22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system_dll", "system_dll\system_dll.vcproj", "{22892211-A1F3-435B-8B97-A12E8772599E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "throw_test_dll", "throw_test_dll\throw_test_dll.vcproj", "{F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}" - ProjectSection(ProjectDependencies) = postProject - {22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E} + {35E7326A-90AB-471A-AB2A-C5BCDA0AFD38} = {35E7326A-90AB-471A-AB2A-C5BCDA0AFD38} EndProjectSection EndProject Global @@ -34,22 +23,14 @@ Global {81960557-E9A9-4E81-AC96-9E11C33CB058}.Debug|Win32.Build.0 = Debug|Win32 {81960557-E9A9-4E81-AC96-9E11C33CB058}.Release|Win32.ActiveCfg = Release|Win32 {81960557-E9A9-4E81-AC96-9E11C33CB058}.Release|Win32.Build.0 = Release|Win32 - {CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Debug|Win32.ActiveCfg = Debug|Win32 - {CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Debug|Win32.Build.0 = Debug|Win32 - {CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Release|Win32.ActiveCfg = Release|Win32 - {CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Release|Win32.Build.0 = Release|Win32 - {AD186B11-9132-48A9-9F24-3522C2310B0D}.Debug|Win32.ActiveCfg = Debug|Win32 - {AD186B11-9132-48A9-9F24-3522C2310B0D}.Debug|Win32.Build.0 = Debug|Win32 - {AD186B11-9132-48A9-9F24-3522C2310B0D}.Release|Win32.ActiveCfg = Release|Win32 - {AD186B11-9132-48A9-9F24-3522C2310B0D}.Release|Win32.Build.0 = Release|Win32 - {22892211-A1F3-435B-8B97-A12E8772599E}.Debug|Win32.ActiveCfg = Debug|Win32 - {22892211-A1F3-435B-8B97-A12E8772599E}.Debug|Win32.Build.0 = Debug|Win32 - {22892211-A1F3-435B-8B97-A12E8772599E}.Release|Win32.ActiveCfg = Release|Win32 - {22892211-A1F3-435B-8B97-A12E8772599E}.Release|Win32.Build.0 = Release|Win32 - {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Debug|Win32.ActiveCfg = Debug|Win32 - {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Debug|Win32.Build.0 = Debug|Win32 - {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Release|Win32.ActiveCfg = Release|Win32 - {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Release|Win32.Build.0 = Release|Win32 + {35E7326A-90AB-471A-AB2A-C5BCDA0AFD38}.Debug|Win32.ActiveCfg = Debug|Win32 + {35E7326A-90AB-471A-AB2A-C5BCDA0AFD38}.Debug|Win32.Build.0 = Debug|Win32 + {35E7326A-90AB-471A-AB2A-C5BCDA0AFD38}.Release|Win32.ActiveCfg = Release|Win32 + {35E7326A-90AB-471A-AB2A-C5BCDA0AFD38}.Release|Win32.Build.0 = Release|Win32 + {ADFCC237-53E3-47D8-949B-C520C332D9CB}.Debug|Win32.ActiveCfg = Debug|Win32 + {ADFCC237-53E3-47D8-949B-C520C332D9CB}.Debug|Win32.Build.0 = Debug|Win32 + {ADFCC237-53E3-47D8-949B-C520C332D9CB}.Release|Win32.ActiveCfg = Release|Win32 + {ADFCC237-53E3-47D8-949B-C520C332D9CB}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 65e14ff1670ea4cf41fb31d989b31ce9d93a03af Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 9 Dec 2012 14:47:39 +0000 Subject: [PATCH 26/30] System/FileSystem/Asio/Thread: ref #7278 Added noexcept to Boost.System to conform with C++11 [SVN r81808] --- include/boost/system/error_code.hpp | 132 ++++++++++++++------------ include/boost/system/system_error.hpp | 6 +- src/error_code.cpp | 43 +++++---- test/error_code_user_test.cpp | 16 ++-- 4 files changed, 108 insertions(+), 89 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index b22775f..c305a25 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -23,7 +23,7 @@ #include // TODO: undef these macros if not already defined -#include +#include #if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API) # error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined @@ -31,6 +31,10 @@ #include // must be the last #include +#ifndef BOOST_SYSTEM_NOEXCEPT +#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT +#endif + namespace boost { namespace system @@ -184,17 +188,17 @@ namespace boost public: virtual ~error_category(){} - virtual const char * name() const = 0; + virtual const char * name() const BOOST_SYSTEM_NOEXCEPT = 0; virtual std::string message( int ev ) const = 0; - virtual error_condition default_error_condition( int ev ) const; - virtual bool equivalent( int code, - const error_condition & condition ) const; - virtual bool equivalent( const error_code & code, - int condition ) const; + inline virtual error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; + inline virtual bool equivalent( int code, + const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT; + inline virtual bool equivalent( const error_code & code, + int condition ) const BOOST_SYSTEM_NOEXCEPT; - bool operator==(const error_category & rhs) const { return this == &rhs; } - bool operator!=(const error_category & rhs) const { return this != &rhs; } - bool operator<( const error_category & rhs ) const + bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this == &rhs; } + bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this != &rhs; } + bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT { return std::less()( this, &rhs ); } @@ -202,9 +206,13 @@ namespace boost // predefined error categories -----------------------------------------// - BOOST_SYSTEM_DECL const error_category & system_category(); - BOOST_SYSTEM_DECL const error_category & generic_category(); - +# ifdef BOOST_ERROR_CODE_HEADER_ONLY + inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; + inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; +#else + BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; + BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; +#endif // deprecated synonyms --------------------------------------------------// # ifndef BOOST_SYSTEM_NO_DEPRECATED @@ -225,52 +233,52 @@ namespace boost public: // constructors: - error_condition() : m_val(0), m_cat(&generic_category()) {} - error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} + error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {} + error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} template error_condition(ErrorConditionEnum e, - typename boost::enable_if >::type* = 0) + typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT { *this = make_error_condition(e); } // modifiers: - void assign( int val, const error_category & cat ) - { + void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT + { m_val = val; m_cat = &cat; } - + template typename boost::enable_if, error_condition>::type & - operator=( ErrorConditionEnum val ) - { + operator=( ErrorConditionEnum val ) BOOST_SYSTEM_NOEXCEPT + { *this = make_error_condition(val); return *this; } - void clear() + void clear() BOOST_SYSTEM_NOEXCEPT { m_val = 0; m_cat = &generic_category(); } // observers: - int value() const { return m_val; } - const error_category & category() const { return *m_cat; } + int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } + const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } std::string message() const { return m_cat->message(value()); } typedef void (*unspecified_bool_type)(); static void unspecified_bool_true() {} - operator unspecified_bool_type() const // true if error - { + operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error + { return m_val == 0 ? 0 : unspecified_bool_true; } - bool operator!() const // true if no error + bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error { return m_val == 0; } @@ -279,13 +287,13 @@ namespace boost // the more symmetrical non-member syntax allows enum // conversions work for both rhs and lhs. inline friend bool operator==( const error_condition & lhs, - const error_condition & rhs ) + const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT { return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; - } + } inline friend bool operator<( const error_condition & lhs, - const error_condition & rhs ) + const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT // the more symmetrical non-member syntax allows enum // conversions work for both rhs and lhs. { @@ -312,59 +320,59 @@ namespace boost public: // constructors: - error_code() : m_val(0), m_cat(&system_category()) {} - error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} + error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {} + error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} template error_code(ErrorCodeEnum e, - typename boost::enable_if >::type* = 0) + typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT { *this = make_error_code(e); } // modifiers: - void assign( int val, const error_category & cat ) - { + void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT + { m_val = val; m_cat = &cat; } - + template typename boost::enable_if, error_code>::type & - operator=( ErrorCodeEnum val ) - { + operator=( ErrorCodeEnum val ) BOOST_SYSTEM_NOEXCEPT + { *this = make_error_code(val); return *this; } - void clear() + void clear() BOOST_SYSTEM_NOEXCEPT { m_val = 0; m_cat = &system_category(); } // observers: - int value() const { return m_val; } - const error_category & category() const { return *m_cat; } - error_condition default_error_condition() const { return m_cat->default_error_condition(value()); } + int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } + const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } + error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT { return m_cat->default_error_condition(value()); } std::string message() const { return m_cat->message(value()); } typedef void (*unspecified_bool_type)(); static void unspecified_bool_true() {} - operator unspecified_bool_type() const // true if error - { + operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error + { return m_val == 0 ? 0 : unspecified_bool_true; } - bool operator!() const // true if no error + bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error { return m_val == 0; } // relationals: inline friend bool operator==( const error_code & lhs, - const error_code & rhs ) + const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT // the more symmetrical non-member syntax allows enum // conversions work for both rhs and lhs. { @@ -372,14 +380,14 @@ namespace boost } inline friend bool operator<( const error_code & lhs, - const error_code & rhs ) + const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT // the more symmetrical non-member syntax allows enum // conversions work for both rhs and lhs. { return lhs.m_cat < rhs.m_cat || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); } - + private: int m_val; const error_category * m_cat; @@ -426,31 +434,31 @@ namespace boost } inline bool operator==( const error_code & code, - const error_condition & condition ) + const error_condition & condition ) BOOST_SYSTEM_NOEXCEPT { return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() ); } - + inline bool operator!=( const error_code & lhs, - const error_condition & rhs ) + const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT { return !(lhs == rhs); } - + inline bool operator==( const error_condition & condition, - const error_code & code ) + const error_code & code ) BOOST_SYSTEM_NOEXCEPT { return condition.category().equivalent( code, condition.value() ) || code.category().equivalent( code.value(), condition ); } - + inline bool operator!=( const error_condition & lhs, - const error_code & rhs ) + const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT { return !(lhs == rhs); } - + // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet. template @@ -482,19 +490,19 @@ namespace boost // error_category default implementation -------------------------------// - inline error_condition error_category::default_error_condition( int ev ) const - { + error_condition error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT + { return error_condition( ev, *this ); } - inline bool error_category::equivalent( int code, - const error_condition & condition ) const + bool error_category::equivalent( int code, + const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT { return default_error_condition( code ) == condition; } - inline bool error_category::equivalent( const error_code & code, - int condition ) const + bool error_category::equivalent( const error_code & code, + int condition ) const BOOST_SYSTEM_NOEXCEPT { return *this == code.category() && code.value() == condition; } diff --git a/include/boost/system/system_error.hpp b/include/boost/system/system_error.hpp index 065d365..b306aae 100644 --- a/include/boost/system/system_error.hpp +++ b/include/boost/system/system_error.hpp @@ -21,7 +21,7 @@ namespace boost class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error // BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared - // library can be caught. See svn.boost.org/trac/boost/ticket/3697 + // library can be caught. See svn.boost.org/trac/boost/ticket/3697 { public: system_error( error_code ec ) @@ -61,13 +61,17 @@ namespace boost { if ( m_what.empty() ) { +#ifndef BOOST_NO_EXCEPTIONS try +#endif { m_what = this->std::runtime_error::what(); if ( !m_what.empty() ) m_what += ": "; m_what += m_error_code.message(); } +#ifndef BOOST_NO_EXCEPTIONS catch (...) { return std::runtime_error::what(); } +#endif } return m_what.c_str(); } diff --git a/src/error_code.cpp b/src/error_code.cpp index 6772d15..cb1cb80 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -22,9 +22,6 @@ #include #include -using namespace boost::system; -using namespace boost::system::errc; - #include // for strerror/strerror_r # if defined( BOOST_WINDOWS_API ) @@ -36,19 +33,21 @@ using namespace boost::system::errc; # endif //----------------------------------------------------------------------------// +namespace boost +{ + namespace system + { namespace { -#if defined(__PGI) - using boost::system::errc::invalid_argument; -#endif + // standard error categories ---------------------------------------------// class generic_error_category : public error_category { public: generic_error_category(){} - const char * name() const; + const char * name() const BOOST_SYSTEM_NOEXCEPT; std::string message( int ev ) const; }; @@ -56,20 +55,25 @@ namespace { public: system_error_category(){} - const char * name() const; + const char * name() const BOOST_SYSTEM_NOEXCEPT; std::string message( int ev ) const; - error_condition default_error_condition( int ev ) const; + error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; }; // generic_error_category implementation ---------------------------------// - const char * generic_error_category::name() const + const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "generic"; } std::string generic_error_category::message( int ev ) const { + using namespace boost::system::errc; +#if defined(__PGI) + using boost::system::errc::invalid_argument; +#endif + static std::string unknown_err( "Unknown error" ); // strerror_r is preferred because it is always thread safe, // however, we fallback to strerror in certain cases because: @@ -133,7 +137,9 @@ namespace } } std::string msg; +# ifndef BOOST_NO_EXCEPTIONS try +# endif { msg = ( ( result == invalid_argument ) ? "Unknown error" : bp ); } @@ -154,13 +160,18 @@ namespace } // system_error_category implementation --------------------------------// - const char * system_error_category::name() const + const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "system"; } - error_condition system_error_category::default_error_condition( int ev ) const + error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT { + using namespace boost::system::errc; +#if defined(__PGI) + using boost::system::errc::invalid_argument; +#endif + switch ( ev ) { case 0: return make_error_condition( success ); @@ -401,10 +412,6 @@ namespace } // unnamed namespace -namespace boost -{ - namespace system - { # ifndef BOOST_SYSTEM_NO_DEPRECATED BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code; @@ -414,13 +421,13 @@ namespace boost // address for comparison purposes # endif - BOOST_SYSTEM_DECL const error_category & system_category() + BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT { static const system_error_category system_category_const; return system_category_const; } - BOOST_SYSTEM_DECL const error_category & generic_category() + BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT { static const generic_error_category generic_category_const; return generic_category_const; diff --git a/test/error_code_user_test.cpp b/test/error_code_user_test.cpp index 4f4eb30..a006a8d 100644 --- a/test/error_code_user_test.cpp +++ b/test/error_code_user_test.cpp @@ -75,7 +75,7 @@ namespace boost namespace lib3 { // lib3 has its own error_category: - const boost::system::error_category & get_lib3_error_category(); + const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT; const boost::system::error_category & lib3_error_category = get_lib3_error_category(); enum error @@ -112,12 +112,12 @@ namespace boost public: lib3_error_category_imp() : boost::system::error_category() { } - const char * name() const + const char * name() const BOOST_SYSTEM_NOEXCEPT { return "lib3"; } - boost::system::error_condition default_error_condition( int ev ) const + boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT { return ev == boo_boo ? boost::system::error_condition( boost::system::errc::io_error, @@ -135,7 +135,7 @@ namespace boost }; - const boost::system::error_category & get_lib3_error_category() + const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT { static const lib3_error_category_imp l3ecat; return l3ecat; @@ -156,7 +156,7 @@ namespace boost namespace lib4 { // lib4 has its own error_category: - const boost::system::error_category & get_lib4_error_category(); + const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT; const boost::system::error_category & lib4_error_category = get_lib4_error_category(); extern const boost::system::error_code boo_boo; @@ -174,12 +174,12 @@ namespace lib4 public: lib4_error_category_imp() : boost::system::error_category() { } - const char * name() const + const char * name() const BOOST_SYSTEM_NOEXCEPT { return "lib4"; } - boost::system::error_condition default_error_condition( int ev ) const + boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT { return ev == boo_boo.value() ? boost::system::error_condition( boost::system::errc::io_error, @@ -195,7 +195,7 @@ namespace lib4 } }; - const boost::system::error_category & get_lib4_error_category() + const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT { static const lib4_error_category_imp l4ecat; return l4ecat; From 87130d1d73523842404ddc1e36e46d0b2f097722 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Thu, 28 Feb 2013 02:13:56 +0000 Subject: [PATCH 27/30] Add BOOST_SYSTEM_NOEXCEPT to several functions previously missed. Update documentation to reflect use of noexcept with fallback to C++03 when C++11 feature not present. [SVN r83197] --- doc/reference.html | 244 ++++++++++++---------------- include/boost/system/error_code.hpp | 10 +- 2 files changed, 113 insertions(+), 141 deletions(-) diff --git a/doc/reference.html b/doc/reference.html index 05c2102..24efd4e 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -38,6 +38,7 @@ Introduction
+ C++11
Macros
Deprecated names
Breaking changes
@@ -70,11 +71,15 @@

Introduction

-

This reference documentation describes components that  -programs may use to report error conditions originating from the operating +

This reference documentation describes components that programs may use to report error conditions originating from the operating system or other low-level application program interfaces.

Boost.System library components never change the value of errno.

+

C++11

+

The library is documented to use several C++11 features, including +noexcept and explicit conversion operators. The actual implementation +uses C++11 features only when they are available, and otherwise falls back on +C++03 features.

Macros

Users may defined the following macros if desired. Sensible defaults are provided, so users may ignore these macros if they prefer.

@@ -178,6 +183,9 @@ fixed by globally adding () to these names to turn them into function calls.

namespace system { class error_category; + const error_category & system_category() noexcept; + const error_category & generic_category() noexcept; + class error_code; class error_condition; @@ -281,21 +289,21 @@ fixed by globally adding () to these names to turn them into function calls.

// non-member functions - bool operator==( const error_code & lhs, const error_code & rhs ); - bool operator==( const error_code & code, const error_condition & condition ); - bool operator==( const error_condition & condition, const error_code & code ); - bool operator==( const error_condition & lhs, const error_condition & rhs ); + bool operator==( const error_code & lhs, const error_code & rhs ) noexcept; + bool operator==( const error_code & code, const error_condition & condition ) noexcept; + bool operator==( const error_condition & condition, const error_code & code ) noexcept; + bool operator==( const error_condition & lhs, const error_condition & rhs ) noexcept; - bool operator!=( const error_code & lhs, const error_code & rhs ); - bool operator!=( const error_code & code, const error_condition & condition ); - bool operator!=( const error_condition & condition, const error_code & code ); - bool operator!=( const error_condition & lhs, const error_condition & rhs ); + bool operator!=( const error_code & lhs, const error_code & rhs ) noexcept; + bool operator!=( const error_code & code, const error_condition & condition ) noexcept; + bool operator!=( const error_condition & condition, const error_code & code ) noexcept; + bool operator!=( const error_condition & lhs, const error_condition & rhs ) noexcept; - bool operator<( const error_code & lhs, const error_code & rhs ); - bool operator<( const error_condition & lhs, const error_condition & rhs ); + bool operator<( const error_code & lhs, const error_code & rhs ) noexcept; + bool operator<( const error_condition & lhs, const error_condition & rhs ) noexcept; - error_code make_error_code( errc::errc_t e ); - error_condition make_error_condition( errc::errc_t e ); + error_code make_error_code( errc::errc_t e ) noexcept; + error_condition make_error_condition( errc::errc_t e ) noexcept; template <class charT, class traits> std::basic_ostream<charT,traits>& @@ -312,6 +320,17 @@ is_error_condition_enum templates to indicate that a type is eligible for class error_code and error_condition automatic conversions respectively.

+
const error_category & system_category();
+
+

Returns: A reference to a error_category object + identifying errors originating from the operating system.

+
+
const error_category & generic_category();
+
+

Returns: A reference to a error_category object + identifying portable error conditions.

+
+

Class error_category

The class error_category defines the base class for types used to identify the source and encoding of a particular category of error code.

@@ -336,37 +355,33 @@ types should create a single object of each such type. public: virtual ~error_category(); - virtual const char * name() const = 0; + virtual const char * name() const noexcept = 0; virtual string message( int ev ) const = 0; - virtual error_condition default_error_condition( int ev ) const; - virtual bool equivalent( int code, const error_condition & condition ) const; - virtual bool equivalent( const error_code & code, int condition ) const; + virtual error_condition default_error_condition( int ev ) const noexcept; + virtual bool equivalent( int code, const error_condition & condition ) + const noexcept; + virtual bool equivalent( const error_code & code, int condition ) const noexcept; - bool operator==( const error_category & rhs ) const; - bool operator!=( const error_category & rhs ) const; - bool operator< ( const error_category & rhs ) const; + bool operator==( const error_category & rhs ) const noexcept; + bool operator!=( const error_category & rhs ) const noexcept; + bool operator< ( const error_category & rhs ) const noexcept; }; - - const error_category & system_category(); - const error_category & generic_category(); } }

Class error_category virtual members

Classes derived from error_category shall behave as specified in this subclause.

-
virtual const char * name() const=0;
+
virtual const char * name() const noexcept =0;

Returns: a string naming the error category.

-

Throws: Nothing.

-
virtual string message( int ev ) const=0;
+
virtual string message( int ev ) const noexcept =0;

Returns: A string that describes the error denoted by ev.

-

Throws: Nothing.

-

virtual error_condition default_error_condition( int ev ) const;

+
virtual error_condition default_error_condition( int ev ) const noexcept;

Returns:  error_condition( ev, *this ).

@@ -375,52 +390,33 @@ this subclause.

and return it as an error_condition for that category. --end note]

-

Throws: Nothing.

-
-

virtual bool equivalent( int code, const error_condition & -condition ) -const;

+ +
virtual bool equivalent( int code, const error_condition & condition ) const noexcept;

Returns: default_error_condition( code ) == condition.

-

Throws: Nothing.

-
-

virtual bool equivalent( const error_code & code, int condition ) const;

+ +
virtual bool equivalent( const error_code & code, int condition ) const noexcept;

Returns: *this == code.category() && code.value() == condition.

-

Throws: Nothing.

-
+

Class error_category non-virtual members

-

bool operator==( const error_category & rhs ) const;

+
bool operator==( const error_category & rhs ) const noexcept;

Returns: this == &rhs.

-

bool operator!=( const error_category & rhs ) const;

+
bool operator!=( const error_category & rhs ) const noexcept;

Returns: this != &rhs.

-
bool operator<( const error_category & rhs ) const;
+
bool operator<( const error_category & rhs ) const noexcept;
-

Returns: std::less<const error_category*>()( this, &rhs ).

+

Returns: std::less<const error_category*>()( this, &rhs  + noexcept).

[Note: std::less provides a total ordering for pointers. --end note]

-

Throws: Nothing.

-
-

Class error_category -non-member functions

-
const error_category & system_category();
-
-

Returns: A reference to a error_category object - identifying errors originating from the operating system.

-

Throws: Nothing.

-
-
const error_category & generic_category();
-
-

Returns: A reference to a error_category object - identifying portable error conditions.

-

Throws: Nothing.

Class error_code

@@ -440,21 +436,21 @@ error_code synopsis public: // constructors: - error_code(); - error_code( val, const error_category & cat ); + error_code() noexcept; + error_code( val, const error_category & cat ) noexcept; template <class ErrorCodeEnum> - error_code( ErrorCodeEnum e ); + error_code( ErrorCodeEnum e ) noexcept; // modifiers: - void assign( int val, const error_category & cat ); + void assign( int val, const error_category & cat ) noexcept; template<typename ErrorCodeEnum> - error_code & operator=( ErrorCodeEnum val );; - void clear(); + error_code & operator=( ErrorCodeEnum val ) noexcept; + void clear() noexcept; // observers: - int value() const; - cont error_category & category() const; - error_condition default_error_condition() const; + int value() const noexcept; + cont error_category & category() const noexcept; + error_condition default_error_condition() const noexcept; string message() const; operator unspecified-bool-type() const; @@ -467,71 +463,63 @@ error_code synopsis

Class error_code constructors

-
error_code();
+
error_code() noexcept;

Effects: Constructs an object of type error_code.

Postconditions: val_ == 0 && cat_ == &system_category().

-

Throws: Nothing.

-
error_code( int val, const error_category & cat );
+
error_code( int val, const error_category & cat ) noexcept;

Effects: Constructs an object of type error_code.

Postconditions: val_ == val && cat_ == &cat.

-

Throws: Nothing.

template <class ErrorCodeEnum>
-  error_code( ErrorCodeEnum val );
+ error_code( ErrorCodeEnum val ) noexcept;

Effects: Constructs an object of type error_code.

Postconditions: *this == make_error_code( val ).

-

Throws: Nothing.

Remarks: This constructor shall not participate in overload resolution unless is_error_code_enum<ErrorCodeEnum>::value is true.

Class error_code modifiers

-
void assign( int val, const error_category & cat );
+
void assign( int val, const error_category & cat ) noexcept;

Postconditions: val_ == val && cat_ == &cat.

-

Throws: Nothing.

template<typename ErrorCodeEnum>
-  error_code & operator=( ErrorCodeEnum val );
+ error_code & operator=( ErrorCodeEnum val ) noexcept;

Postconditions: *this == make_error_code( val ).

-

Throws: Nothing.

Remarks: This operator shall not participate in overload resolution unless is_error_code_enum<ErrorCodeEnum>::value is true.

-

void clear();

+
void clear() noexcept;

postcondition: value() == 0 && category() == system_category()

Class error_code observers

-

int value() const;

+
int value() const noexcept;

Returns: val_.

-

Throws: Nothing.

-
-

const error_category & category() const;

+ +
const error_category & category() const noexcept;

Returns: *cat_.

-

Throws: Nothing.

-
-
error_condition default_error_condition() const;
+ +
error_condition default_error_condition() const noexcept;

Returns:  category().default_error_condition( value()).

-

Throws: Nothing.

-

string message() const;

+
string message() const;

Returns:  category().message( value()).

Throws: Nothing.

-

operator unspecified-bool-type() const;

+
operator unspecified-bool-type() const;

Returns: if value() != 0, returns a value that will evaluate true in a boolean context; otherwise, returns a value that will @@ -560,22 +548,22 @@ implementation specific. --end note ]

public: // constructors: - error_condition(); - error_condition( int val, const error_category & cat ); + error_condition() noexcept; + error_condition( int val, const error_category & cat ) noexcept; template <class ErrorConditionEnum> - error_condition( errorConditionEnum val ); + error_condition( errorConditionEnum val ) noexcept; // modifiers: - void assign( int val, const error_category & cat ); + void assign( int val, const error_category & cat ) noexcept; template<typename ErrorConditionEnum> - error_condition & operator=( ErrorConditionEnum val ); - void clear(); + error_condition & operator=( ErrorConditionEnum val ) noexcept; + void clear() noexcept; // observers: - int value() const; - const error_category & category() const; + int value() const noexcept; + const error_category & category() const noexcept; string message() const; - operator unspecified-bool-type () const; + operator unspecified-bool-type () const noexcept; private: int val_; // exposition only @@ -586,65 +574,57 @@ implementation specific. --end note ]

Class error_condition constructors

-
error_condition(); 
+
error_condition() noexcept; 

Effects: Constructs an object of type error_condition.

Postconditions: val_ == 0 and cat_ == &generic_category().

-

Throws: Nothing.

-
error_condition( int val, const error_category & cat );
+
error_condition( int val, const error_category & cat ) noexcept;

Effects: Constructs an object of type error_condition.

Postconditions: val_ == val and cat_ == &cat.

-

Throws: Nothing.

template <class ErrorConditionEnum>
-  error_condition( ErrorConditionEnum e );
+ error_condition( ErrorConditionEnum e ) noexcept;

Effects: Constructs an object of type error_condition.

Postconditions: *this == make_error_condition(e).

-

Throws: Nothing.

Remarks: This constructor shall not participate in overload resolution unless is_error_condition_enum<ErrorConditionEnum>::value is true.

Class error_condition modifiers

-
void assign( int val, const error_category & cat ); 
+
void assign( int val, const error_category & cat ) noexcept; 

Postconditions: val_ == val and cat_ == &cat.

-

Throws: Nothing.

template<typename ErrorConditionEnum>
-  error_condition & operator=( ErrorConditionEnum e );
+ error_condition & operator=( ErrorConditionEnum e ) noexcept;

Postconditions: *this == make_error_condition( e ).

Returns: *this.

-

Throws: Nothing.

Remarks: This operator shall not participate in overload resolution unless is_error_condition_enum<ErrorConditionEnum>::value is true.

-

void clear();

+
void clear() noexcept;
-

postcondition: value() == 0 && category() == generic_category()

+

Postcondition: value() == 0 && category() == generic_category()

Class error_condition observers

-
int value() const;
+
int value() const noexcept;

Returns: val_.

-

Throws: Nothing

-
const error_category & category() const;
+
const error_category & category() const noexcept;

Returns: *cat_.

-

Throws: Nothing.

string message() const;

Returns: category().message( value() ).

-

Throws: Nothing.

operator unspecified-bool-type () const;
@@ -690,58 +670,50 @@ semantics:

Non-member functions

-
bool operator==( const error_code & lhs, const error_code & rhs );
+
bool operator==( const error_code & lhs, const error_code & rhs ) noexcept;

Returns: lhs.category() == rhs.category() && lhs.value() == rhs.value().

-

Throws: Nothing.

-
bool operator==( const error_code & code, const error_condition & condition );
-bool operator==( const error_condition & condition, const error_code & code );
+
bool operator==( const error_code & code, const error_condition & condition ) noexcept;
+bool operator==( const error_condition & condition, const error_code & code ) noexcept;

Returns: code.category().equivalent( code.value(), condition )
|| condition.category().equivalent( code, condition.value() )
.

-

Throws: Nothing.

-
bool operator==( const error_condition & lhs, const error_condition & rhs );
+
bool operator==( const error_condition & lhs, const error_condition & rhs ) noexcept;

Returns: lhs.category() == rhs.category() && lhs.value() == rhs.value().

-

Throws: Nothing.

-
bool operator!=( const error_code & lhs, const error_code & rhs );
+
bool operator!=( const error_code & lhs, const error_code & rhs ) noexcept;

Returns: !(lhs == rhs ).

-

Throws: Nothing.

-
bool operator!=( const error_code & code, const error_condition & condition );
-bool operator!=( const error_condition & condition, const error_code & code );
+
bool operator!=( const error_code & code, const error_condition & condition ) noexcept;
+bool operator!=( const error_condition & condition, const error_code & code ) noexcept;

Returns: !( code ==  condition ).

-

Throws: Nothing.

-
bool operator!=( const error_condition & lhs, const error_condition & rhs );
+
bool operator!=( const error_condition & lhs, const error_condition & rhs ) noexcept;

Returns: !(lhs == rhs ).

-

Throws: Nothing.

-
bool operator<( const error_code & lhs, const error_code & rhs );
+
bool operator<( const error_code & lhs, const error_code & rhs ) noexcept;

Returns: lhs.category() < rhs.category()
  || (lhs.category() == rhs.category() && lhs.value() < rhs.value())
.

-

Throws: Nothing.

-
bool operator<( const error_condition & lhs, const error_condition & rhs );
+
bool operator<( const error_condition & lhs, const error_condition & rhs ) noexcept;

Returns: lhs.category() < rhs.category()
  || (lhs.category() == rhs.category() && lhs.value() < rhs.value())
.

-

Throws: Nothing.

-
error_code make_error_code( errc::errc_t e );
+
error_code make_error_code( errc::errc_t e ) noexcept;

Returns: error_code( e, generic_category()).

-
error_condition make_error_condition( errc::errc_t e );
+
error_condition make_error_condition( errc::errc_t e ) noexcept;

Returns: error_condition( static_cast<int>( e ), generic_category()).

@@ -840,10 +812,10 @@ application program interfaces.


Revised -June 29, 2010 +February 27, 2013

-

© Copyright Beman Dawes, 2006, 2007, 2008

+

© Copyright Beman Dawes, 2006, 2007, 2008, 2013

Distributed under the Boost Software License, Version 1.0. See www.boost.org/LICENSE_1_0.txt

diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index c305a25..3e7689c 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -388,7 +388,7 @@ namespace boost || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); } - private: + private: int m_val; const error_category * m_cat; @@ -422,13 +422,13 @@ namespace boost // non-member functions ------------------------------------------------// inline bool operator!=( const error_code & lhs, - const error_code & rhs ) + const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT { return !(lhs == rhs); } inline bool operator!=( const error_condition & lhs, - const error_condition & rhs ) + const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT { return !(lhs == rhs); } @@ -480,11 +480,11 @@ namespace boost namespace errc { // explicit conversion: - inline error_code make_error_code( errc_t e ) + inline error_code make_error_code( errc_t e ) BOOST_SYSTEM_NOEXCEPT { return error_code( e, generic_category() ); } // implicit conversion: - inline error_condition make_error_condition( errc_t e ) + inline error_condition make_error_condition( errc_t e ) BOOST_SYSTEM_NOEXCEPT { return error_condition( e, generic_category() ); } } From 08ea984237321c015a03705612eca910a96643f8 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Thu, 28 Feb 2013 20:55:07 +0000 Subject: [PATCH 28/30] Use C++11 explicit conversion operator if available [SVN r83210] --- doc/reference.html | 39 +++++-------------- include/boost/system/error_code.hpp | 14 +++++++ test/Jamfile.v2 | 4 +- test/error_code_test.cpp | 11 ++++++ .../system_msvc/system_dll/system_dll.vcxproj | 2 + .../system_error_test.vcxproj | 2 + 6 files changed, 41 insertions(+), 31 deletions(-) diff --git a/doc/reference.html b/doc/reference.html index 24efd4e..bf54540 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -452,7 +452,7 @@ error_code synopsis cont error_category & category() const noexcept; error_condition default_error_condition() const noexcept; string message() const; - operator unspecified-bool-type() const; + explicit operator bool() const noexcept; private: int val_; // exposition only @@ -517,20 +517,10 @@ error_code observers
string message() const;

Returns:  category().message( value()).

-

Throws: Nothing.

-
operator unspecified-bool-type() const;
+
explicit operator bool() const noexcept;
-

Returns: if value() != 0, returns a value that will evaluate -true in a boolean context; otherwise, returns a value that will -evaluate false in a boolean context. The value type returned shall -not be convertible to int.

-

Throws: nothing.

-

[Note: This conversion can be used in contexts where a bool -is expected ( e.g., an if condition ); however, implicit conversions -( e.g., to int) that can occur with bool are not -allowed, eliminating some sources of user error. One possible implementation -choice for this type is pointer-to-member. --end note ]

+

Returns: value() != 0.

Class error_condition

The class error_condition describes an object used to hold @@ -560,10 +550,10 @@ implementation specific. --end note ]

void clear() noexcept; // observers: - int value() const noexcept; - const error_category & category() const noexcept; - string message() const; - operator unspecified-bool-type () const noexcept; + int value() const noexcept; + const error_category& category() const noexcept; + string message() const; + explicit operator bool() const noexcept; private: int val_; // exposition only @@ -626,18 +616,9 @@ observers

Returns: category().message( value() ).

-
operator unspecified-bool-type () const;
+
explicit operator bool() const noexcept;
-

Returns: If value() != 0, returns a value that will - evaluate true in a boolean context; otherwise, returns a value - that will evaluate false. The return type shall not be - convertible to int.

-

Throws: Nothing.

-

 [ Note: This conversion can be used in contexts where a bool - is expected ( e.g., an if condition ); however, implicit conversions ( e.g., to - int) that can occur with bool are not allowed, - eliminating some sources of user error. One possible implementation choice for - this type is pointer to member. --end note ]

+

Returns: value() != 0.

throws object

extern error_code throws;
@@ -812,7 +793,7 @@ application program interfaces.


Revised -February 27, 2013 +February 28, 2013

© Copyright Beman Dawes, 2006, 2007, 2008, 2013

diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 3e7689c..812e779 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -270,6 +270,12 @@ namespace boost const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } std::string message() const { return m_cat->message(value()); } +# ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + explicit operator bool() const BOOST_SYSTEM_NOEXCEPT + { + return m_val != 0; + } +# else typedef void (*unspecified_bool_type)(); static void unspecified_bool_true() {} @@ -282,6 +288,7 @@ namespace boost { return m_val == 0; } +# endif // relationals: // the more symmetrical non-member syntax allows enum @@ -357,6 +364,12 @@ namespace boost error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT { return m_cat->default_error_condition(value()); } std::string message() const { return m_cat->message(value()); } +# ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + explicit operator bool() const BOOST_SYSTEM_NOEXCEPT + { + return m_val != 0; + } +# else typedef void (*unspecified_bool_type)(); static void unspecified_bool_true() {} @@ -369,6 +382,7 @@ namespace boost { return m_val == 0; } +# endif // relationals: inline friend bool operator==( const error_code & lhs, diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1ab7442..1785f55 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,10 +25,10 @@ project : # command line : # input files : # requirements - static + always_show_run_output static ] [ run error_code_test.cpp - : : : shared : error_code_test_shared + : : : always_show_run_output shared : error_code_test_shared ] [ run error_code_user_test.cpp : : : static diff --git a/test/error_code_test.cpp b/test/error_code_test.cpp index a9a928e..4065848 100644 --- a/test/error_code_test.cpp +++ b/test/error_code_test.cpp @@ -59,6 +59,17 @@ namespace int main( int, char ** ) { +#ifdef BOOST_NO_CXX11_NOEXCEPT + std::cout << "BOOST_NO_CXX11_NOEXCEPT is defined" << std::endl; +#else + std::cout << "BOOST_NO_CXX11_NOEXCEPT is not defined" << std::endl; +#endif +#ifdef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + std::cout << "BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS is defined" << std::endl; +#else + std::cout << "BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS is not defined" << std::endl; +#endif + std::cout << "Conversion use cases...\n"; error_condition x1( errc::file_exists ); //error_code x2( errc::file_exists ); // should fail to compile diff --git a/test/system_msvc/system_dll/system_dll.vcxproj b/test/system_msvc/system_dll/system_dll.vcxproj index e4092a3..92e55e0 100644 --- a/test/system_msvc/system_dll/system_dll.vcxproj +++ b/test/system_msvc/system_dll/system_dll.vcxproj @@ -20,12 +20,14 @@ DynamicLibrary true Unicode + v110 DynamicLibrary false true Unicode + v110 diff --git a/test/system_msvc/system_error_test/system_error_test.vcxproj b/test/system_msvc/system_error_test/system_error_test.vcxproj index 0d083cb..af9a57d 100644 --- a/test/system_msvc/system_error_test/system_error_test.vcxproj +++ b/test/system_msvc/system_error_test/system_error_test.vcxproj @@ -20,12 +20,14 @@ Application true Unicode + v110 Application false true Unicode + v110 From c64f27c9be4fdb26646c3b2a851404a9912d89e7 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Mon, 16 Sep 2013 13:29:47 +0000 Subject: [PATCH 29/30] Add Windows Runtime support to Boost.System. [SVN r85699] --- src/error_code.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/error_code.cpp b/src/error_code.cpp index cb1cb80..68cb6ed 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -26,7 +26,9 @@ # if defined( BOOST_WINDOWS_API ) # include -# include "local_free_on_destruction.hpp" +# if !defined(WINAPI_FAMILY) || ((WINAPI_FAMILY & WINAPI_PARTITION_APP) == 0) +# include "local_free_on_destruction.hpp" +# endif # ifndef ERROR_INCORRECT_SIZE # define ERROR_INCORRECT_SIZE ERROR_BAD_ARGUMENTS # endif @@ -172,6 +174,17 @@ namespace using boost::system::errc::invalid_argument; #endif +# if defined(BOOST_WINDOWS_API) +# if defined(WINAPI_FAMILY) && ((WINAPI_FAMILY & WINAPI_PARTITION_APP) != 0) + // When using the Windows Runtime, most system errors are reported as HRESULTs. + // We want to map the common Win32 errors to their equivalent error condition, + // whether or not they are reported via an HRESULT. + if ( ev < 0 ) // Check for failed HRESULTs only. + if ( HRESULT_FACILITY( ev ) == FACILITY_WIN32 ) + ev = HRESULT_CODE( ev ); +# endif +# endif + switch ( ev ) { case 0: return make_error_condition( success ); @@ -359,7 +372,36 @@ namespace std::string system_error_category::message( int ev ) const { -# ifndef BOOST_NO_ANSI_APIS +# if defined(WINAPI_FAMILY) && ((WINAPI_FAMILY & WINAPI_PARTITION_APP) != 0) + std::string str( 128, char() ); + for (;;) + { + DWORD retval = ::FormatMessageA( + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + ev, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + &str[0], + str.size(), + NULL + ); + + if ( retval > 0 ) + { + str.resize( retval ); + break; + } + else if ( ::GetLastError() != ERROR_INSUFFICIENT_BUFFER ) + { + return std::string("Unknown error"); + } + else + { + str.resize( str.size() + str.size()/2 ); + } + } +# elif !defined(BOOST_NO_ANSI_APIS) LPVOID lpMsgBuf = 0; DWORD retval = ::FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | From ec47972526bb8fefb489ac148601d1ebb78fb1ce Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Thu, 3 Oct 2013 23:59:54 +0000 Subject: [PATCH 30/30] Fix WinRT detection. [SVN r86152] --- src/error_code.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/error_code.cpp b/src/error_code.cpp index 68cb6ed..5e00588 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -26,7 +26,7 @@ # if defined( BOOST_WINDOWS_API ) # include -# if !defined(WINAPI_FAMILY) || ((WINAPI_FAMILY & WINAPI_PARTITION_APP) == 0) +# if !defined(WINAPI_FAMILY) || ((WINAPI_FAMILY & WINAPI_PARTITION_DESKTOP) != 0) # include "local_free_on_destruction.hpp" # endif # ifndef ERROR_INCORRECT_SIZE @@ -372,7 +372,7 @@ namespace std::string system_error_category::message( int ev ) const { -# if defined(WINAPI_FAMILY) && ((WINAPI_FAMILY & WINAPI_PARTITION_APP) != 0) +# if defined(WINAPI_FAMILY) && ((WINAPI_FAMILY & WINAPI_PARTITION_DESKTOP) == 0) std::string str( 128, char() ); for (;;) {