mirror of
https://github.com/boostorg/system.git
synced 2025-12-25 16:28:05 +01:00
Compare commits
6 Commits
feature/gc
...
feature/is
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32dbf1b992 | ||
|
|
707b24bfa1 | ||
|
|
bb1caae0d5 | ||
|
|
c5c49894e6 | ||
|
|
ee80491cab | ||
|
|
a83319fde1 |
185
.github/workflows/ci.yml
vendored
185
.github/workflows/ci.yml
vendored
@@ -115,6 +115,11 @@ jobs:
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: clang-14
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: clang-15
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-11
|
||||
@@ -391,3 +396,183 @@ jobs:
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
windows-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Use library with add_subdirectory (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use library with add_subdirectory (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
windows-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
|
||||
- name: Install (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install --config Debug
|
||||
|
||||
- name: Install (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install --config Release
|
||||
|
||||
- name: Use the installed library (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use the installed library (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
windows-cmake-test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests --config Debug
|
||||
|
||||
- name: Run tests (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Build tests (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests --config Release
|
||||
|
||||
- name: Run tests (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
@@ -1657,7 +1657,8 @@ public:
|
||||
|
||||
// error access
|
||||
|
||||
constexpr E error() const;
|
||||
constexpr E error() const &;
|
||||
constexpr E error() &&;
|
||||
|
||||
// emplace
|
||||
|
||||
@@ -1851,7 +1852,8 @@ Returns: ::
|
||||
#### Error Access
|
||||
|
||||
```
|
||||
constexpr E error() const;
|
||||
constexpr E error() const &;
|
||||
constexpr E error() &&;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
@@ -1979,7 +1981,8 @@ public:
|
||||
|
||||
// error access
|
||||
|
||||
constexpr E error() const;
|
||||
constexpr E error() const &;
|
||||
constexpr E error() &&;
|
||||
|
||||
// emplace
|
||||
|
||||
@@ -2120,7 +2123,8 @@ Effects: ::
|
||||
#### Error Access
|
||||
|
||||
```
|
||||
constexpr E error() const;
|
||||
constexpr E error() const &;
|
||||
constexpr E error() &&;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//
|
||||
// See http://www.boost.org/libs/system for documentation.
|
||||
|
||||
#include <boost/system/detail/requires_cxx11.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ struct mutex
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#elif defined(BOOST_MSSTL_VERSION) && BOOST_MSSTL_VERSION >= 140
|
||||
#else // defined(BOOST_SYSTEM_DISABLE_THREADS)
|
||||
|
||||
#if defined(BOOST_MSSTL_VERSION) && BOOST_MSSTL_VERSION >= 140
|
||||
|
||||
// Under the MS STL, std::mutex::mutex() is not constexpr, as is
|
||||
// required by the standard, which leads to initialization order
|
||||
@@ -40,6 +42,14 @@ struct mutex
|
||||
|
||||
#include <shared_mutex>
|
||||
|
||||
#if BOOST_MSSTL_VERSION >= 142 || _HAS_SHARED_MUTEX
|
||||
# define BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
@@ -53,7 +63,7 @@ typedef std::shared_mutex mutex;
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#else
|
||||
#else // defined(BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX)
|
||||
|
||||
#include <mutex>
|
||||
|
||||
@@ -70,7 +80,8 @@ using std::mutex;
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
#endif // defined(BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX)
|
||||
#endif // defined(BOOST_SYSTEM_DISABLE_THREADS)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
21
include/boost/system/detail/requires_cxx11.hpp
Normal file
21
include/boost/system/detail/requires_cxx11.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef BOOST_SYSTEM_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_CONSTEXPR) || \
|
||||
defined(BOOST_NO_CXX11_NOEXCEPT) || \
|
||||
defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || \
|
||||
defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || \
|
||||
defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("C++03 support is deprecated in Boost.System 1.82 and will be removed in Boost.System 1.84.")
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
|
||||
@@ -401,12 +401,18 @@ public:
|
||||
|
||||
// error access
|
||||
|
||||
constexpr E error() const
|
||||
constexpr E error() const &
|
||||
noexcept( std::is_nothrow_default_constructible<E>::value && std::is_nothrow_copy_constructible<E>::value )
|
||||
{
|
||||
return has_error()? variant2::unsafe_get<1>( v_ ): E();
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR E error() &&
|
||||
noexcept( std::is_nothrow_default_constructible<E>::value && std::is_nothrow_move_constructible<E>::value )
|
||||
{
|
||||
return has_error()? std::move( variant2::unsafe_get<1>( v_ ) ): E();
|
||||
}
|
||||
|
||||
// emplace
|
||||
|
||||
template<class... A>
|
||||
@@ -581,12 +587,18 @@ public:
|
||||
|
||||
// error access
|
||||
|
||||
constexpr E error() const
|
||||
constexpr E error() const &
|
||||
noexcept( std::is_nothrow_default_constructible<E>::value && std::is_nothrow_copy_constructible<E>::value )
|
||||
{
|
||||
return has_error()? variant2::unsafe_get<1>( v_ ): E();
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR E error() &&
|
||||
noexcept( std::is_nothrow_default_constructible<E>::value && std::is_nothrow_move_constructible<E>::value )
|
||||
{
|
||||
return has_error()? std::move( variant2::unsafe_get<1>( v_ ) ): E();
|
||||
}
|
||||
|
||||
// emplace
|
||||
|
||||
BOOST_CXX14_CONSTEXPR void emplace()
|
||||
|
||||
@@ -163,3 +163,4 @@ boost_test(TYPE run SOURCES result_emplace.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_construct4.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct4.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct5.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_move.cpp)
|
||||
|
||||
@@ -193,3 +193,4 @@ run result_emplace.cpp : : : $(CPP11) ;
|
||||
run result_error_construct4.cpp : : : $(CPP11) ;
|
||||
run result_value_construct4.cpp : : : $(CPP11) ;
|
||||
run result_value_construct5.cpp : : : $(CPP11) ;
|
||||
run result_error_move.cpp : : : $(CPP11) ;
|
||||
|
||||
91
test/result_error_move.cpp
Normal file
91
test/result_error_move.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
// Copyright 2023 Klemens Morgenstern
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <string>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit X( int v = 0 ): v_( v ) {}
|
||||
|
||||
X( X const& ) = delete;
|
||||
X& operator=( X const& ) = delete;
|
||||
|
||||
X( X && ) = default;
|
||||
X& operator=( X && ) = default;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<std::string, X> r( 1 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( std::move( r ).error().v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST(( !result<std::string, X>( 1 ).has_value() ));
|
||||
BOOST_TEST(( result<std::string, X>( 1 ).has_error() ));
|
||||
|
||||
BOOST_TEST_EQ( (result<std::string, X>( 1 ).error().v_), 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<std::string, X> r( "s" );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( std::move( r ).error().v_, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST(( result<std::string, X>( "s" ).has_value() ));
|
||||
BOOST_TEST(( !result<std::string, X>( "s" ).has_error() ));
|
||||
|
||||
BOOST_TEST_EQ( (result<std::string, X>( "s" ).error().v_), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, X> r( 1 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( std::move( r ).error().v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST(( !result<void, X>( 1 ).has_value() ));
|
||||
BOOST_TEST(( result<void, X>( 1 ).has_error() ));
|
||||
|
||||
BOOST_TEST_EQ( (result<void, X>( 1 ).error().v_), 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, X> r;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( std::move( r ).error().v_, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST(( result<void, X>().has_value() ));
|
||||
BOOST_TEST(( !result<void, X>().has_error() ));
|
||||
|
||||
BOOST_TEST_EQ( (result<void, X>().error().v_), 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user