mirror of
https://github.com/boostorg/system.git
synced 2026-06-11 11:41:10 +02:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f162555a3 | |||
| 6dcde20c14 | |||
| 0333af2a72 | |||
| 971b46d038 | |||
| e74205d2a1 | |||
| d77d6460ab | |||
| 66631f95d4 | |||
| 7da0eed2fe | |||
| 6abf6c7e89 | |||
| 6b638df0c1 | |||
| 9e039cfaf9 | |||
| 084d8e119e | |||
| 0d2aeead38 | |||
| 73b2805d63 | |||
| 6a71483984 | |||
| 2b1aa524d9 | |||
| a9bb21507a | |||
| d1f3d3b349 | |||
| 35e3e22c7e | |||
| 7b94454e7c | |||
| a413220f8d | |||
| 9f5272fa61 | |||
| 19d5bf5f04 | |||
| 9f5cbe223c | |||
| a14074bafc | |||
| 587ceaf739 | |||
| 8416ba067f | |||
| 77817d8847 | |||
| fe28fa163c | |||
| 61b4d8ef24 | |||
| 3ba40116fe | |||
| d837670627 | |||
| f89fe0ea77 | |||
| d0b3f59e63 | |||
| 83ddde6b78 | |||
| fe55a4a963 | |||
| de5a0cf3ca | |||
| 7b6dcf6ac6 |
+27
-2
@@ -109,7 +109,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -117,6 +117,16 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
@@ -202,6 +212,7 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
@@ -213,6 +224,7 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
@@ -224,10 +236,23 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
@@ -264,7 +289,7 @@ install:
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on}
|
||||
- ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
@@ -14,6 +14,10 @@ branches:
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: clang-win
|
||||
CLANG_WIN: 1
|
||||
USER_CONFIG: "using clang-win : : clang-cl.exe : <compatibility>vc14 ;"
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-9.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
@@ -36,6 +40,13 @@ environment:
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
@@ -70,4 +81,5 @@ build: off
|
||||
test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%USER_CONFIG%" == "" echo %USER_CONFIG% > %HOMEDRIVE%%HOMEPATH%\user-config.jam
|
||||
- b2 -j3 libs/system/test toolset=%TOOLSET% variant=debug,release %CXXSTD%
|
||||
|
||||
@@ -35,45 +35,22 @@
|
||||
//--------------------------------------------------------------------------------------//
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// standard error categories -------------------------------------------------------//
|
||||
|
||||
class generic_error_category : public error_category
|
||||
{
|
||||
public:
|
||||
generic_error_category(){}
|
||||
const char * name() const BOOST_SYSTEM_NOEXCEPT;
|
||||
std::string message( int ev ) const;
|
||||
};
|
||||
|
||||
class system_error_category : public error_category
|
||||
{
|
||||
public:
|
||||
system_error_category(){}
|
||||
const char * name() const BOOST_SYSTEM_NOEXCEPT;
|
||||
std::string message( int ev ) const;
|
||||
error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
|
||||
};
|
||||
|
||||
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
|
||||
# define BOOST_SYSTEM_INLINE inline
|
||||
# define BOOST_SYSTEM_DECL_ inline
|
||||
#else
|
||||
# define BOOST_SYSTEM_INLINE
|
||||
# define BOOST_SYSTEM_DECL_ BOOST_SYSTEM_DECL
|
||||
#endif
|
||||
|
||||
// generic_error_category implementation ---------------------------------//
|
||||
|
||||
BOOST_SYSTEM_INLINE const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return "generic";
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_INLINE std::string generic_error_category::message( int ev ) const
|
||||
BOOST_SYSTEM_DECL_ std::string generic_error_category::message( int ev ) const
|
||||
{
|
||||
using namespace boost::system::errc;
|
||||
#if defined(__PGI)
|
||||
@@ -166,12 +143,7 @@ namespace detail
|
||||
}
|
||||
// system_error_category implementation --------------------------------------------//
|
||||
|
||||
BOOST_SYSTEM_INLINE const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return "system";
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_INLINE error_condition system_error_category::default_error_condition( int ev ) const
|
||||
BOOST_SYSTEM_DECL_ error_condition system_error_category::default_error_condition( int ev ) const
|
||||
BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
using namespace boost::system::errc;
|
||||
@@ -376,13 +348,13 @@ namespace detail
|
||||
|
||||
# if !defined( BOOST_WINDOWS_API )
|
||||
|
||||
BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const
|
||||
BOOST_SYSTEM_DECL_ std::string system_error_category::message( int ev ) const
|
||||
{
|
||||
return generic_category().message( ev );
|
||||
}
|
||||
# else
|
||||
|
||||
BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const
|
||||
BOOST_SYSTEM_DECL_ std::string system_error_category::message( int ev ) const
|
||||
{
|
||||
#if defined(UNDER_CE) || BOOST_PLAT_WINDOWS_RUNTIME || defined(BOOST_NO_ANSI_APIS)
|
||||
std::wstring buf(128, wchar_t());
|
||||
@@ -461,7 +433,7 @@ namespace detail
|
||||
}
|
||||
# endif
|
||||
|
||||
#undef BOOST_SYSTEM_INLINE
|
||||
#undef BOOST_SYSTEM_DECL_
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -474,23 +446,51 @@ namespace detail
|
||||
// address for comparison purposes
|
||||
# endif
|
||||
|
||||
# ifdef BOOST_ERROR_CODE_HEADER_ONLY
|
||||
# define BOOST_SYSTEM_LINKAGE inline
|
||||
# else
|
||||
# define BOOST_SYSTEM_LINKAGE BOOST_SYSTEM_DECL
|
||||
# endif
|
||||
#if defined(BOOST_ERROR_CODE_HEADER_ONLY)
|
||||
|
||||
BOOST_SYSTEM_LINKAGE const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
static const detail::system_error_category system_category_const;
|
||||
return system_category_const;
|
||||
}
|
||||
// defined in error_code.hpp
|
||||
|
||||
BOOST_SYSTEM_LINKAGE const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
static const detail::generic_error_category generic_category_const;
|
||||
return generic_category_const;
|
||||
}
|
||||
#elif defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_SYSTEM_REQUIRE_CONST_INIT BOOST_SYSTEM_DECL system_error_category system_category_instance;
|
||||
BOOST_SYSTEM_REQUIRE_CONST_INIT BOOST_SYSTEM_DECL generic_error_category generic_category_instance;
|
||||
|
||||
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return system_category_instance;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return generic_category_instance;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#else
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
static const detail::system_error_category system_category_instance;
|
||||
return system_category_instance;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
static const detail::generic_error_category generic_category_instance;
|
||||
return generic_category_instance;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
@@ -39,6 +39,27 @@
|
||||
#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
# define BOOST_SYSTEM_HAS_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ == 7 && __GNUC_MINOR__ < 4) && __cplusplus >= 201700L
|
||||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83835
|
||||
# undef BOOST_SYSTEM_HAS_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(_MSC_VER) && defined(_CPPLIB_VER)
|
||||
// Clang on Windows with MSVC headers, the constructor of std::error_category
|
||||
// is not constexpr at least up to VS2017 15.7.x (_MSVC_STL_UPDATE 201803)
|
||||
# undef BOOST_SYSTEM_HAS_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
# define BOOST_SYSTEM_CONSTEXPR constexpr
|
||||
#else
|
||||
# define BOOST_SYSTEM_CONSTEXPR
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
@@ -186,31 +207,6 @@ namespace boost
|
||||
|
||||
// --------------------------------------------------------------------------------//
|
||||
|
||||
class error_category;
|
||||
|
||||
// predefined error categories ---------------------------------------------------//
|
||||
|
||||
#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 ------------------------------------------------------------//
|
||||
|
||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||
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 BOOST_ATTRIBUTE_UNUSED
|
||||
= generic_category();
|
||||
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED
|
||||
= generic_category();
|
||||
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED
|
||||
= system_category();
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
// 'this' : used in base member initializer list
|
||||
@@ -233,7 +229,7 @@ namespace boost
|
||||
|
||||
public:
|
||||
|
||||
explicit std_category( boost::system::error_category const * pc ): pc_( pc )
|
||||
BOOST_SYSTEM_CONSTEXPR explicit std_category( boost::system::error_category const * pc ): pc_( pc )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -259,7 +255,7 @@ namespace boost
|
||||
|
||||
public:
|
||||
|
||||
error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
|
||||
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
|
||||
|
||||
operator std::error_category const & () const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
@@ -284,7 +280,7 @@ namespace boost
|
||||
|
||||
public:
|
||||
|
||||
explicit std_category( boost::system::error_category const * pc ): pc_( pc )
|
||||
BOOST_SYSTEM_CONSTEXPR explicit std_category( boost::system::error_category const * pc ): pc_( pc )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -310,7 +306,7 @@ namespace boost
|
||||
|
||||
public:
|
||||
|
||||
error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
|
||||
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -326,19 +322,193 @@ namespace boost
|
||||
BOOST_SYSTEM_NOEXCEPT;
|
||||
inline virtual bool equivalent( const error_code & code,
|
||||
int condition ) const BOOST_SYSTEM_NOEXCEPT;
|
||||
|
||||
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<const error_category*>()( this, &rhs ); }
|
||||
};
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline bool operator==( const error_category & lhs,
|
||||
const error_category & rhs ) BOOST_SYSTEM_NOEXCEPT
|
||||
{ return &lhs == &rhs; }
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_category & lhs,
|
||||
const error_category & rhs ) BOOST_SYSTEM_NOEXCEPT
|
||||
{ return &lhs != &rhs; }
|
||||
|
||||
inline bool operator<( const error_category & lhs,
|
||||
const error_category & rhs ) BOOST_SYSTEM_NOEXCEPT
|
||||
{ return std::less<const error_category*>()( &lhs, &rhs ); }
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// predefined error categories ---------------------------------------------------//
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
|
||||
# define BOOST_SYSTEM_DECL_
|
||||
#else
|
||||
# define BOOST_SYSTEM_DECL_ BOOST_SYSTEM_DECL
|
||||
#endif
|
||||
|
||||
class generic_error_category: public error_category
|
||||
{
|
||||
public:
|
||||
|
||||
// clang++ 3.8 and below: initialization of const object
|
||||
// requires a user-provided default constructor
|
||||
BOOST_SYSTEM_CONSTEXPR generic_error_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char * name() const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return "generic";
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_DECL_ std::string message( int ev ) const;
|
||||
};
|
||||
|
||||
class system_error_category: public error_category
|
||||
{
|
||||
public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char * name() const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return "system";
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_DECL_ std::string message( int ev ) const;
|
||||
BOOST_SYSTEM_DECL_ error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
|
||||
};
|
||||
|
||||
#undef BOOST_SYSTEM_DECL_
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#define BOOST_SYSTEM_REQUIRE_CONST_INIT
|
||||
|
||||
#if defined(__has_cpp_attribute)
|
||||
#if __has_cpp_attribute(clang::require_constant_initialization)
|
||||
# undef BOOST_SYSTEM_REQUIRE_CONST_INIT
|
||||
# define BOOST_SYSTEM_REQUIRE_CONST_INIT [[clang::require_constant_initialization]]
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_ERROR_CODE_HEADER_ONLY)
|
||||
|
||||
# if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> struct cat_holder
|
||||
{
|
||||
static system_error_category system_category_instance;
|
||||
static generic_error_category generic_category_instance;
|
||||
};
|
||||
|
||||
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT system_error_category cat_holder<T>::system_category_instance;
|
||||
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT generic_error_category cat_holder<T>::generic_category_instance;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
constexpr const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return detail::cat_holder<void>::system_category_instance;
|
||||
}
|
||||
|
||||
constexpr const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return detail::cat_holder<void>::generic_category_instance;
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
static const detail::system_error_category system_category_instance;
|
||||
return system_category_instance;
|
||||
}
|
||||
|
||||
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
static const detail::generic_error_category generic_category_instance;
|
||||
return generic_category_instance;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
#elif defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if defined(BOOST_SYSTEM_SOURCE)
|
||||
|
||||
// clang++ requires a strictly matching declaration
|
||||
BOOST_SYSTEM_DECL extern system_error_category system_category_instance;
|
||||
BOOST_SYSTEM_DECL extern generic_error_category generic_category_instance;
|
||||
|
||||
#else
|
||||
|
||||
extern system_error_category system_category_instance;
|
||||
extern generic_error_category generic_category_instance;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
constexpr const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return detail::system_category_instance;
|
||||
}
|
||||
|
||||
constexpr const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return detail::generic_category_instance;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT;
|
||||
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return detail::system_category_ncx();
|
||||
}
|
||||
|
||||
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return detail::generic_category_ncx();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// deprecated synonyms ------------------------------------------------------------//
|
||||
|
||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||
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 BOOST_ATTRIBUTE_UNUSED
|
||||
= generic_category();
|
||||
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED
|
||||
= generic_category();
|
||||
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED
|
||||
= system_category();
|
||||
#endif
|
||||
|
||||
// class error_condition ---------------------------------------------------------//
|
||||
|
||||
// error_conditions are portable, error_codes are system or library specific
|
||||
@@ -348,8 +518,8 @@ namespace boost
|
||||
public:
|
||||
|
||||
// constructors:
|
||||
error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
|
||||
error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
|
||||
: m_val(val), m_cat(&cat) {}
|
||||
|
||||
template <class ErrorConditionEnum>
|
||||
@@ -362,7 +532,7 @@ namespace boost
|
||||
|
||||
// modifiers:
|
||||
|
||||
void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
m_val = val;
|
||||
m_cat = &cat;
|
||||
@@ -377,20 +547,20 @@ namespace boost
|
||||
return *this;
|
||||
}
|
||||
|
||||
void clear() BOOST_SYSTEM_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
m_val = 0;
|
||||
m_cat = &generic_category();
|
||||
}
|
||||
|
||||
// observers:
|
||||
int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
|
||||
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
|
||||
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
|
||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
|
||||
std::string message() const { return m_cat->message(value()); }
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||
{
|
||||
return m_val != 0;
|
||||
}
|
||||
@@ -400,12 +570,12 @@ namespace boost
|
||||
typedef void (*unspecified_bool_type)();
|
||||
static void unspecified_bool_true() {}
|
||||
|
||||
operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||
{
|
||||
return m_val == 0 ? 0 : unspecified_bool_true;
|
||||
}
|
||||
|
||||
bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
|
||||
{
|
||||
return m_val == 0;
|
||||
}
|
||||
@@ -415,7 +585,7 @@ namespace boost
|
||||
// relationals:
|
||||
// the more symmetrical non-member syntax allows enum
|
||||
// conversions work for both rhs and lhs.
|
||||
inline friend bool operator==( const error_condition & lhs,
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs,
|
||||
const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val;
|
||||
@@ -458,8 +628,8 @@ namespace boost
|
||||
public:
|
||||
|
||||
// constructors:
|
||||
error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {}
|
||||
error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {}
|
||||
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
|
||||
: m_val(val), m_cat(&cat) {}
|
||||
|
||||
template <class ErrorCodeEnum>
|
||||
@@ -471,7 +641,7 @@ namespace boost
|
||||
}
|
||||
|
||||
// modifiers:
|
||||
void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
m_val = val;
|
||||
m_cat = &cat;
|
||||
@@ -485,22 +655,22 @@ namespace boost
|
||||
return *this;
|
||||
}
|
||||
|
||||
void clear() BOOST_SYSTEM_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
m_val = 0;
|
||||
m_cat = &system_category();
|
||||
}
|
||||
|
||||
// observers:
|
||||
int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
|
||||
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
|
||||
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
|
||||
BOOST_SYSTEM_CONSTEXPR 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()); }
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||
{
|
||||
return m_val != 0;
|
||||
}
|
||||
@@ -510,12 +680,12 @@ namespace boost
|
||||
typedef void (*unspecified_bool_type)();
|
||||
static void unspecified_bool_true() {}
|
||||
|
||||
operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||
{
|
||||
return m_val == 0 ? 0 : unspecified_bool_true;
|
||||
}
|
||||
|
||||
bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
|
||||
{
|
||||
return m_val == 0;
|
||||
}
|
||||
@@ -523,7 +693,7 @@ namespace boost
|
||||
#endif
|
||||
|
||||
// relationals:
|
||||
inline friend bool operator==( const error_code & lhs,
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs,
|
||||
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
|
||||
// the more symmetrical non-member syntax allows enum
|
||||
// conversions work for both rhs and lhs.
|
||||
@@ -596,13 +766,13 @@ namespace boost
|
||||
{
|
||||
// non-member functions ------------------------------------------------//
|
||||
|
||||
inline bool operator!=( const error_code & lhs,
|
||||
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_code & lhs,
|
||||
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline bool operator!=( const error_condition & lhs,
|
||||
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_condition & lhs,
|
||||
const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
|
||||
+3
-1
@@ -76,11 +76,12 @@ project
|
||||
return $(result) ;
|
||||
}
|
||||
|
||||
if [ os.environ UBSAN ]
|
||||
if [ os.environ UBSAN ] || [ os.environ CLANG_WIN ]
|
||||
{
|
||||
rule system-run ( sources + )
|
||||
{
|
||||
# The 03/11 tests are ODR violations, no point running them under -fsanitize=undefined
|
||||
# Clang on Windows uses MSVC headers, which don't parse under 03/11
|
||||
return [ system-run- $(sources) ] ;
|
||||
}
|
||||
}
|
||||
@@ -126,6 +127,7 @@ else
|
||||
[ run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>shared : single_instance_lib_shared ]
|
||||
[ system-run before_main_test.cpp ]
|
||||
[ run-fail throws_assign_fail.cpp ]
|
||||
[ system-run- constexpr_test.cpp ]
|
||||
;
|
||||
|
||||
# Quick (CI) test
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
|
||||
// Copyright 2018 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CONSTEXPR isn't defined")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
constexpr error_code e1( 1, system_category() );
|
||||
|
||||
BOOST_STATIC_ASSERT( e1.value() == 1 );
|
||||
BOOST_STATIC_ASSERT( e1.category() == system_category() );
|
||||
BOOST_STATIC_ASSERT( e1 );
|
||||
BOOST_STATIC_ASSERT( e1 == e1 );
|
||||
|
||||
constexpr error_code e2( 2, generic_category() );
|
||||
|
||||
BOOST_STATIC_ASSERT( e2.value() == 2 );
|
||||
BOOST_STATIC_ASSERT( e2.category() == generic_category() );
|
||||
BOOST_STATIC_ASSERT( e2 );
|
||||
BOOST_STATIC_ASSERT( e2 == e2 );
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 80200)
|
||||
|
||||
BOOST_STATIC_ASSERT( e1 != e2 );
|
||||
|
||||
#endif
|
||||
|
||||
constexpr error_code e3;
|
||||
|
||||
BOOST_STATIC_ASSERT( e3.value() == 0 );
|
||||
BOOST_STATIC_ASSERT( e3.category() == system_category() );
|
||||
BOOST_STATIC_ASSERT( !e3 );
|
||||
BOOST_STATIC_ASSERT( e3 == e3 );
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 80200)
|
||||
|
||||
BOOST_STATIC_ASSERT( e1 != e3 );
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
error_code e1_( 1, system_category() );
|
||||
BOOST_TEST_EQ( e1, e1_ );
|
||||
|
||||
error_code e2_( 2, generic_category() );
|
||||
BOOST_TEST_EQ( e2, e2_ );
|
||||
|
||||
error_code e3_;
|
||||
BOOST_TEST_EQ( e3, e3_ );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -38,7 +38,6 @@ static void test_generic_category()
|
||||
std::error_category const & st = bt;
|
||||
|
||||
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
|
||||
BOOST_TEST_EQ( bt.name(), st.name() );
|
||||
}
|
||||
|
||||
static void test_system_category()
|
||||
@@ -47,7 +46,6 @@ static void test_system_category()
|
||||
std::error_category const & st = bt;
|
||||
|
||||
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
|
||||
BOOST_TEST_EQ( bt.name(), st.name() );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
Reference in New Issue
Block a user