mirror of
https://github.com/boostorg/system.git
synced 2025-12-25 08:18:05 +01:00
Compare commits
11 Commits
boost-1.90
...
feature/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
982abbe42a | ||
|
|
56ba602d06 | ||
|
|
7ec2584789 | ||
|
|
dec785741b | ||
|
|
c8e1b9fa0b | ||
|
|
4d8f6f85cd | ||
|
|
05cb8f459c | ||
|
|
62878a6d06 | ||
|
|
8bb3ce6277 | ||
|
|
1b74658f57 | ||
|
|
6dc7819c2e |
90
.github/workflows/ci.yml
vendored
90
.github/workflows/ci.yml
vendored
@@ -59,36 +59,36 @@ jobs:
|
||||
install: g++-12
|
||||
- toolset: gcc-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: g++-13
|
||||
- toolset: gcc-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: g++-14
|
||||
- toolset: gcc-15
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:25.04
|
||||
os: ubuntu-latest
|
||||
install: g++-15
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
@@ -99,96 +99,117 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "11,14,17"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-7
|
||||
install: clang-7 libc++-7-dev libc++abi-7-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "11,14,17"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-8
|
||||
install: clang-8 libc++-8-dev libc++abi-8-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "11,14,17"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-9
|
||||
install: clang-9 libc++-9-dev libc++abi-9-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "11,14,17,2a"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-10
|
||||
install: clang-10 libc++-10-dev libc++abi-10-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "11,14,17,2a"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-11
|
||||
install: clang-11 libc++-11-dev libc++abi-11-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "11,14,17,20"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-12
|
||||
install: clang-12 libc++-12-dev libc++abi-12-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-13
|
||||
install: clang-13 libc++-13-dev libc++abi-13-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-14
|
||||
install: clang-14 libc++-14-dev libc++abi-14-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
stdlib: "native,libc++"
|
||||
os: ubuntu-latest
|
||||
install: clang-15
|
||||
install: clang-15 libc++-15-dev libc++abi-15-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-16
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-16
|
||||
install: clang-16 libc++-16-dev libc++abi-16-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-17
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-17
|
||||
install: clang-17 libc++-17-dev libc++abi-17-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-18
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-18
|
||||
install: clang-18 libc++-18-dev libc++abi-18-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-19
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-19
|
||||
install: clang-19 libc++-19-dev libc++abi-19-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-20
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
container: ubuntu:25.04
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-20
|
||||
install: clang-20 libc++-20-dev libc++abi-20-dev
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-13
|
||||
compiler: clang++-21
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
stdlib: "native,libc++"
|
||||
container: ubuntu:25.10
|
||||
os: ubuntu-latest
|
||||
install: clang-21 libc++-21-dev libc++abi-21-dev
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-14
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-15
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
os: macos-26
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -254,7 +275,7 @@ jobs:
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release ${{ matrix.stdlib && format('stdlib={0}', matrix.stdlib) }}
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
@@ -312,11 +333,8 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -360,11 +378,8 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -418,11 +433,8 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.8...3.20)
|
||||
cmake_minimum_required(VERSION 3.8...3.31)
|
||||
|
||||
project(boost_system VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
@@ -14,6 +14,7 @@ target_include_directories(boost_system INTERFACE include)
|
||||
target_link_libraries(boost_system
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::compat
|
||||
Boost::config
|
||||
Boost::throw_exception
|
||||
Boost::variant2
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
////
|
||||
Copyright 2018-2022 Peter Dimov
|
||||
Copyright 2018-2025 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://www.boost.org/LICENSE_1_0.txt
|
||||
////
|
||||
@@ -8,6 +8,10 @@ https://www.boost.org/LICENSE_1_0.txt
|
||||
# Revision History
|
||||
:idprefix:
|
||||
|
||||
## Changes in Boost 1.91
|
||||
|
||||
* The return type of `operator|(result<T&>, U)` has been changed to non-reference.
|
||||
|
||||
## Changes in Boost 1.89
|
||||
|
||||
* The stub compiled library has been removed; System has been header-only since release 1.69.
|
||||
|
||||
@@ -2518,8 +2518,8 @@ Returns: ::
|
||||
#### operator|
|
||||
|
||||
```
|
||||
template<class T, class E, class U> T operator|( result<T, E> const& r, U&& u );
|
||||
template<class T, class E, class U> T operator|( result<T, E>&& r, U&& u );
|
||||
template<class T, class E, class U> std::decay_t<T> operator|( result<T, E> const& r, U&& u );
|
||||
template<class T, class E, class U> std::decay_t<T> operator|( result<T, E>&& r, U&& u );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
@@ -2530,7 +2530,7 @@ Effects: ::
|
||||
- If `r.has_value()` is `true`, returns `*r`.
|
||||
- Otherwise, returns `u`.
|
||||
Remarks: ::
|
||||
Only enabled when `U` is convertible to `T`.
|
||||
Only enabled when `U` is convertible to `std::decay_t<T>`.
|
||||
Example: ::
|
||||
+
|
||||
```
|
||||
@@ -2545,6 +2545,7 @@ int get_port()
|
||||
```
|
||||
template<class T, class E, class F> T operator|( result<T, E> const& r, F&& f );
|
||||
template<class T, class E, class F> T operator|( result<T, E>&& r, F&& f );
|
||||
template<class T, class E, class F> std::decay_t<T> operator|( result<T&, E> const& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
@@ -2556,7 +2557,7 @@ Effects: ::
|
||||
- If `r.has_value()` is `true`, returns `*r`.
|
||||
- Otherwise, returns `f()`.
|
||||
Remarks: ::
|
||||
Only enabled when `f()` is convertible to `T`.
|
||||
Only enabled when `f()` is convertible to `T`, or, when `T` is a reference, to `std::decay_t<T>`.
|
||||
Example: ::
|
||||
+
|
||||
```
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef BOOST_SYSTEM_RESULT_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_RESULT_HPP_INCLUDED
|
||||
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Copyright 2017, 2021-2025 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <boost/system/detail/error_category_impl.hpp>
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/compat/invoke.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
@@ -919,9 +920,10 @@ template<class T, class E> struct is_result< result<T, E> >: std::true_type {};
|
||||
// result | value
|
||||
|
||||
template<class T, class E, class U,
|
||||
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
|
||||
class En = typename std::enable_if<std::is_convertible<U, typename std::decay<T>::type>::value>::type
|
||||
>
|
||||
T operator|( result<T, E> const& r, U&& u )
|
||||
typename std::decay<T>::type
|
||||
operator|( result<T, E> const& r, U&& u )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
@@ -934,9 +936,10 @@ T operator|( result<T, E> const& r, U&& u )
|
||||
}
|
||||
|
||||
template<class T, class E, class U,
|
||||
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
|
||||
class En = typename std::enable_if<std::is_convertible<U, typename std::decay<T>::type>::value>::type
|
||||
>
|
||||
T operator|( result<T, E>&& r, U&& u )
|
||||
typename std::decay<T>::type
|
||||
operator|( result<T, E>&& r, U&& u )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
@@ -982,6 +985,26 @@ T operator|( result<T, E>&& r, F&& f )
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En = typename std::enable_if<
|
||||
std::is_convertible<U, typename std::decay<T>::type>::value &&
|
||||
!detail::is_value_convertible_to<U, T&>::value
|
||||
>::type
|
||||
>
|
||||
typename std::decay<T>::type
|
||||
operator|( result<T&, E> const& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return *r;
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
// result | nullary-returning-result
|
||||
|
||||
template<class T, class E, class F,
|
||||
@@ -1108,7 +1131,24 @@ result<T, E>& operator|=( result<T, E>& r, F&& f )
|
||||
// result & unary-returning-value
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T const&>() ) ),
|
||||
class U = compat::invoke_result_t<F, T&>,
|
||||
class En1 = typename std::enable_if<!detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<!std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<T, E>& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
return compat::invoke( std::forward<F>( f ), *r );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = compat::invoke_result_t<F, T const&>,
|
||||
class En1 = typename std::enable_if<!detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<!std::is_void<U>::value>::type
|
||||
>
|
||||
@@ -1120,12 +1160,12 @@ result<U, E> operator&( result<T, E> const& r, F&& f )
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )( *r );
|
||||
return compat::invoke( std::forward<F>( f ), *r );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
|
||||
class U = typename std::decay< compat::invoke_result_t<F, T> >::type,
|
||||
class En1 = typename std::enable_if<!detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<!std::is_void<U>::value>::type
|
||||
>
|
||||
@@ -1137,12 +1177,29 @@ result<U, E> operator&( result<T, E>&& r, F&& f )
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )( *std::move( r ) );
|
||||
return compat::invoke( std::forward<F>( f ), *std::move( r ) );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T const&>() ) ),
|
||||
class U = compat::invoke_result_t<F, T&>,
|
||||
class En1 = typename std::enable_if<!detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<!std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<T&, E>&& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
return compat::invoke( std::forward<F>( f ), *std::move( r ) );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = compat::invoke_result_t<F, T const&>,
|
||||
class En = typename std::enable_if<std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<T, E> const& r, F&& f )
|
||||
@@ -1153,13 +1210,13 @@ result<U, E> operator&( result<T, E> const& r, F&& f )
|
||||
}
|
||||
else
|
||||
{
|
||||
std::forward<F>( f )( *r );
|
||||
compat::invoke( std::forward<F>( f ), *r );
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
|
||||
class U = compat::invoke_result_t<F, T>,
|
||||
class En = typename std::enable_if<std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<T, E>&& r, F&& f )
|
||||
@@ -1170,7 +1227,7 @@ result<U, E> operator&( result<T, E>&& r, F&& f )
|
||||
}
|
||||
else
|
||||
{
|
||||
std::forward<F>( f )( *std::move( r ) );
|
||||
compat::invoke( std::forward<F>( f ), *std::move( r ) );
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -1212,7 +1269,24 @@ result<U, E> operator&( result<void, E> const& r, F&& f )
|
||||
// result & unary-returning-result
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T const&>() ) ),
|
||||
class U = typename std::decay< compat::invoke_result_t<F, T&> >::type,
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_convertible<E, typename U::error_type>::value>::type
|
||||
>
|
||||
U operator&( result<T, E>& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
return compat::invoke( std::forward<F>( f ), *r );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = typename std::decay< compat::invoke_result_t<F, T const&> >::type,
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_convertible<E, typename U::error_type>::value>::type
|
||||
>
|
||||
@@ -1224,12 +1298,12 @@ U operator&( result<T, E> const& r, F&& f )
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )( *r );
|
||||
return compat::invoke( std::forward<F>( f ), *r );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
|
||||
class U = typename std::decay< compat::invoke_result_t<F, T> >::type,
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_convertible<E, typename U::error_type>::value>::type
|
||||
>
|
||||
@@ -1241,7 +1315,7 @@ U operator&( result<T, E>&& r, F&& f )
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )( *std::move( r ) );
|
||||
return compat::invoke( std::forward<F>( f ), *std::move( r ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,6 @@ boost_test(TYPE run SOURCES result_value_construct6.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct7.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_construct5.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_value.cpp)
|
||||
boost_test(TYPE compile-fail SOURCES result_or_value_fail.cpp)
|
||||
boost_test(TYPE compile-fail SOURCES result_or_value_fail2.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_fn0v.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_fn0r.cpp)
|
||||
boost_test(TYPE run SOURCES result_and_fn1v.cpp)
|
||||
@@ -177,3 +175,6 @@ boost_test(TYPE run SOURCES result_in_place_use.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_eq_value.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_eq_fn0v.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_eq_fn0r.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES result_and_mfn1v.cpp)
|
||||
boost_test(TYPE run SOURCES result_and_mfn1r.cpp)
|
||||
|
||||
@@ -198,8 +198,6 @@ run result_value_construct6.cpp ;
|
||||
run result_value_construct7.cpp ;
|
||||
run result_error_construct5.cpp ;
|
||||
run result_or_value.cpp ;
|
||||
compile-fail result_or_value_fail.cpp ;
|
||||
compile-fail result_or_value_fail2.cpp ;
|
||||
run result_or_fn0v.cpp ;
|
||||
run result_or_fn0r.cpp ;
|
||||
run result_and_fn1v.cpp ;
|
||||
@@ -210,3 +208,6 @@ run result_in_place_use.cpp ;
|
||||
run result_or_eq_value.cpp ;
|
||||
run result_or_eq_fn0v.cpp ;
|
||||
run result_or_eq_fn0r.cpp ;
|
||||
|
||||
run result_and_mfn1v.cpp ;
|
||||
run result_and_mfn1r.cpp ;
|
||||
|
||||
@@ -8,6 +8,7 @@ project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(../.. boostorg/system)
|
||||
add_subdirectory(../../../assert boostorg/assert)
|
||||
add_subdirectory(../../../compat boostorg/compat)
|
||||
add_subdirectory(../../../config boostorg/config)
|
||||
add_subdirectory(../../../core boostorg/core)
|
||||
add_subdirectory(../../../mp11 boostorg/mp11)
|
||||
|
||||
230
test/result_and_mfn1r.cpp
Normal file
230
test/result_and_mfn1r.cpp
Normal file
@@ -0,0 +1,230 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// 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>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
struct E2
|
||||
{
|
||||
E2() {}
|
||||
E2( E ) {}
|
||||
};
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_ = 0;
|
||||
mutable int g_called_ = 0;
|
||||
|
||||
X( int v ): v_( v ) {}
|
||||
|
||||
result<int, E2> f() const { return v_; }
|
||||
result<int, E2> f2() const { return E2(); }
|
||||
|
||||
result<int&, E2> g() { return v_; }
|
||||
result<int const&, E2> g2() const { return v_; }
|
||||
|
||||
result<void, E2> h() const { return {}; }
|
||||
result<void, E2> h2() const { return E2(); }
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<X, E> r( 1 );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & &X::f;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & &X::f2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r2 = r & &X::g;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
|
||||
}
|
||||
|
||||
{
|
||||
result<int const&, E2> r2 = r & &X::g2;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & &X::h;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & &X::h2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> const r( 1 );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & &X::f;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & &X::f2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int const&, E2> r2 = r & &X::g2;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & &X::h;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & &X::h2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
result<int, E2> r2 = result<X, E>( 1 ) & &X::f;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<X, E>( 1 ) & &X::f2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r2 = result<X, E>( 1 ) & &X::g;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int const&, E2> r2 = result<X, E>( 1 ) & &X::g2;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<X, E>( 1 ) & &X::h;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<X, E>( 1 ) & &X::h2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> r( in_place_error );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & &X::f;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & &X::f2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r2 = r & &X::g;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int const&, E2> r2 = r & &X::g2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & &X::h;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & &X::h2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> const r( in_place_error );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & &X::f;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & &X::f2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int const&, E2> r2 = r & &X::g2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & &X::h;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & &X::h2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
result<int, E2> r2 = result<X, E>( in_place_error ) & &X::f;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<X, E>( in_place_error ) & &X::f2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r2 = result<X, E>( in_place_error ) & &X::g;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int const&, E2> r2 = result<X, E>( in_place_error ) & &X::g2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<X, E>( in_place_error ) & &X::h;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<X, E>( in_place_error ) & &X::h2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
254
test/result_and_mfn1v.cpp
Normal file
254
test/result_and_mfn1v.cpp
Normal file
@@ -0,0 +1,254 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// 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>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_ = 0;
|
||||
mutable int g_called_ = 0;
|
||||
|
||||
X( int v ): v_( v ) {}
|
||||
|
||||
int f() const { return v_; }
|
||||
|
||||
void g() const { ++g_called_; }
|
||||
|
||||
int& h() { return v_; }
|
||||
int const& h2() const { return v_; }
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<X> r( 1 );
|
||||
result<int> r2 = r & &X::f;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> const r( 1 );
|
||||
result<int> r2 = r & &X::f;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r2 = result<X>( 1 ) & &X::f;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> r( in_place_error );
|
||||
result<int, E> r2 = r & &X::f;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> const r( in_place_error );
|
||||
result<int, E> r2 = r & &X::f;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r2 = result<X, E>( in_place_error ) & &X::f;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> r( 1 );
|
||||
result<int&> r2 = r & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> const r( 1 );
|
||||
result<int const&> r2 = r & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r2 = result<X>( 1 ) & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> r( in_place_error );
|
||||
result<int&, E> r2 = r & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> const r( in_place_error );
|
||||
result<int const&, E> r2 = r & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r2 = result<X, E>( in_place_error ) & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
X x( 1 );
|
||||
|
||||
result<X&> r( x );
|
||||
result<int&> r2 = r & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x.v_ );
|
||||
}
|
||||
|
||||
{
|
||||
X const x( 1 );
|
||||
|
||||
result<X const&> r( x );
|
||||
result<int const&> r2 = r & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x.v_ );
|
||||
}
|
||||
|
||||
{
|
||||
X x( 1 );
|
||||
|
||||
result<int&> r2 = result<X&>( x ) & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x.v_ );
|
||||
}
|
||||
|
||||
{
|
||||
X const x( 1 );
|
||||
|
||||
result<int const&> r2 = result<X const&>( x ) & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x.v_ );
|
||||
}
|
||||
|
||||
{
|
||||
result<X&, E> r( in_place_error );
|
||||
result<int&, E> r2 = r & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X const&, E> const r( in_place_error );
|
||||
result<int const&, E> r2 = r & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> r2 = result<X&, E>( in_place_error ) & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int const&, E> r2 = result<X const&, E>( in_place_error ) & &X::v_;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> r( 1 );
|
||||
result<void> r2 = r & &X::g;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST_EQ( r->g_called_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> const r( 1 );
|
||||
result<void> r2 = r & &X::g;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST_EQ( r->g_called_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r2 = result<X>( 1 ) & &X::g;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> r( in_place_error );
|
||||
result<void, E> r2 = r & &X::g;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> const r( in_place_error );
|
||||
result<void, E> r2 = r & &X::g;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r2 = result<X, E>( in_place_error ) & &X::g;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> r( 1 );
|
||||
result<int&> r2 = r & &X::h;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> const r( 1 );
|
||||
result<int const&> r2 = r & &X::h2;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r2 = result<X>( 1 ) & &X::h2;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> r( in_place_error );
|
||||
result<int&, E> r2 = r & &X::h;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> const r( in_place_error );
|
||||
result<int const&, E> r2 = r & &X::h2;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r2 = result<X, E>( in_place_error ) & &X::h2;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -191,120 +191,102 @@ int main()
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
int& x = r | fri | x3;
|
||||
auto r2 = r | fri;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
int& x = r | fri | x3;
|
||||
auto r2 = r | fri;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
int& x = result<int&>( x1 ) | fri | x3;
|
||||
auto r2 = result<int&>( x1 ) | fri;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
int& x = r | fri2 | x3;
|
||||
auto r2 = r | fri2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
int& x = r | fri2 | x3;
|
||||
auto r2 = r | fri2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
int& x = result<int&>( x1 ) | fri2 | x3;
|
||||
auto r2 = result<int&>( x1 ) | fri2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
int& x = r | fri | x3;
|
||||
auto r2 = r | fri;
|
||||
|
||||
BOOST_TEST_EQ( &x, &*fri() );
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &*fri() );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
int& x = r | fri | x3;
|
||||
auto r2 = r | fri;
|
||||
|
||||
BOOST_TEST_EQ( &x, &*fri() );
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &*fri() );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
auto r2 = result<int&, E>( in_place_error ) | fri;
|
||||
|
||||
int& x = result<int&, E>( in_place_error ) | fri | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &*fri() );
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &*fri() );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
int& x = r | fri2 | x3;
|
||||
auto r2 = r | fri2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x3 );
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
int& x = r | fri2 | x3;
|
||||
auto r2 = r | fri2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x3 );
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
auto r2 = result<int&, E>( in_place_error ) | fri2;
|
||||
|
||||
int& x = result<int&, E>( in_place_error ) | fri2 | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x3 );
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
@@ -108,6 +110,71 @@ int main()
|
||||
BOOST_TEST_EQ( y.v_, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
auto&& x2 = r | f;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
|
||||
|
||||
BOOST_TEST_EQ( x2, x1 );
|
||||
BOOST_TEST_NE( &x2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
auto&& x2 = r | f;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
|
||||
|
||||
BOOST_TEST_EQ( x2, x1 );
|
||||
BOOST_TEST_NE( &x2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
auto&& x2 = result<int&>( x1 ) | f;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
|
||||
|
||||
BOOST_TEST_EQ( x2, x1 );
|
||||
BOOST_TEST_NE( &x2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
auto&& x2 = r | f;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
|
||||
|
||||
BOOST_TEST_EQ( x2, f() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
auto&& x2 = r | f;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
|
||||
|
||||
BOOST_TEST_EQ( x2, f() );
|
||||
}
|
||||
|
||||
{
|
||||
auto&& x2 = result<int&, E>( in_place_error ) | f;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
|
||||
|
||||
BOOST_TEST_EQ( x2, f() );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
@@ -110,9 +112,22 @@ int main()
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
int& x = r | x2;
|
||||
{
|
||||
auto&& x3 = r | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
|
||||
|
||||
BOOST_TEST_EQ( x3, x1 );
|
||||
BOOST_TEST_NE( &x3, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
auto&& x4 = r | 3;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
|
||||
|
||||
BOOST_TEST_EQ( x4, x1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -121,18 +136,44 @@ int main()
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
int& x = r | x2;
|
||||
{
|
||||
auto&& x3 = r | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
|
||||
|
||||
BOOST_TEST_EQ( x3, x1 );
|
||||
BOOST_TEST_NE( &x3, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
auto&& x4 = r | 3;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
|
||||
|
||||
BOOST_TEST_EQ( x4, x1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
int& x = result<int&>( x1 ) | x2;
|
||||
{
|
||||
auto&& x3 = result<int&>( x1 ) | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
|
||||
|
||||
BOOST_TEST_EQ( x3, x1 );
|
||||
BOOST_TEST_NE( &x3, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
auto&& x4 = result<int&>( x1 ) | 3;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
|
||||
|
||||
BOOST_TEST_EQ( x4, x1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -140,9 +181,22 @@ int main()
|
||||
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
int& x = r | x2;
|
||||
{
|
||||
auto&& x3 = r | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x2 );
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
|
||||
|
||||
BOOST_TEST_EQ( x3, x2 );
|
||||
BOOST_TEST_NE( &x3, &x2 );
|
||||
}
|
||||
|
||||
{
|
||||
auto&& x4 = r | 3;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
|
||||
|
||||
BOOST_TEST_EQ( x4, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -150,17 +204,43 @@ int main()
|
||||
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
int& x = r | x2;
|
||||
{
|
||||
auto&& x3 = r | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x2 );
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
|
||||
|
||||
BOOST_TEST_EQ( x3, x2 );
|
||||
BOOST_TEST_NE( &x3, &x2 );
|
||||
}
|
||||
|
||||
{
|
||||
auto&& x4 = r | 3;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
|
||||
|
||||
BOOST_TEST_EQ( x4, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int x2 = 2;
|
||||
|
||||
int& x = result<int&, E>( in_place_error ) | x2;
|
||||
{
|
||||
auto&& x3 = result<int&, E>( in_place_error ) | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x2 );
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
|
||||
|
||||
BOOST_TEST_EQ( x3, x2 );
|
||||
BOOST_TEST_NE( &x3, &x2 );
|
||||
}
|
||||
|
||||
{
|
||||
auto&& x4 = result<int&, E>( in_place_error ) | 3;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
|
||||
|
||||
BOOST_TEST_EQ( x4, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 1;
|
||||
result<int const&> r( x );
|
||||
r | 2;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 1;
|
||||
result<int const&>( x ) | 2;
|
||||
}
|
||||
Reference in New Issue
Block a user