Compare commits

...

5 Commits

Author SHA1 Message Date
Peter Dimov
2aa5d4d97f Add definitions of ::in_place_* for result specializations. Fixes #115. 2023-12-15 03:17:21 +02:00
Peter Dimov
18edbf75d0 Test ::in_place_* for result specializations. Refs #115. 2023-12-15 02:44:14 +02:00
Peter Dimov
52220a0351 Add definitions of result<T, E>::in_place_*. Refs #115. 2023-12-15 02:24:18 +02:00
Peter Dimov
ffa67ab005 Add test for ODR-use of ::in_place_* (refs #115) 2023-12-15 02:11:19 +02:00
Peter Dimov
d8399efcac Update ci.yml 2023-12-15 01:42:22 +02:00
5 changed files with 52 additions and 1 deletions

View File

@@ -131,9 +131,15 @@ jobs:
- toolset: clang
compiler: clang++-16
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:23.04
os: ubuntu-latest
install: clang-16
- toolset: clang
compiler: clang++-17
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:23.10
os: ubuntu-latest
install: clang-17
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-11

View File

@@ -450,6 +450,13 @@ public:
}
};
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
template<class T, class E> constexpr in_place_value_t result<T, E>::in_place_value;
template<class T, class E> constexpr in_place_error_t result<T, E>::in_place_error;
#endif
template<class Ch, class Tr, class T, class E> std::basic_ostream<Ch, Tr>& operator<<( std::basic_ostream<Ch, Tr>& os, result<T, E> const & r )
{
if( r.has_value() )
@@ -652,6 +659,13 @@ public:
}
};
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
template<class E> constexpr in_place_value_t result<void, E>::in_place_value;
template<class E> constexpr in_place_error_t result<void, E>::in_place_error;
#endif
template<class Ch, class Tr, class E> std::basic_ostream<Ch, Tr>& operator<<( std::basic_ostream<Ch, Tr>& os, result<void, E> const & r )
{
if( r.has_value() )
@@ -885,6 +899,13 @@ public:
}
};
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
template<class U, class E> constexpr in_place_value_t result<U&, E>::in_place_value;
template<class U, class E> constexpr in_place_error_t result<U&, E>::in_place_error;
#endif
// operator|
namespace detail

View File

@@ -176,3 +176,4 @@ boost_test(TYPE run SOURCES result_and_fn1v.cpp)
boost_test(TYPE run SOURCES result_and_fn1r.cpp)
boost_test(TYPE run SOURCES result_and_eq_fn1v.cpp)
boost_test(TYPE run SOURCES result_and_eq_fn1r.cpp)
boost_test(TYPE run SOURCES result_in_place_use.cpp)

View File

@@ -206,3 +206,4 @@ run result_and_fn1v.cpp : : : $(CPP11) ;
run result_and_fn1r.cpp : : : $(CPP11) ;
run result_and_eq_fn1v.cpp : : : $(CPP11) ;
run result_and_eq_fn1r.cpp : : : $(CPP11) ;
run result_in_place_use.cpp : : : $(CPP11) ;

View File

@@ -0,0 +1,22 @@
// Copyright 2023 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>
template<class T, class U> void test( T const& t, U const& u )
{
BOOST_TEST_NE( static_cast<void const*>( &t ), static_cast<void const*>( &u ) );
}
int main()
{
using namespace boost::system;
test( result<int>::in_place_value, result<int>::in_place_error );
test( result<void>::in_place_value, result<void>::in_place_error );
test( result<int&>::in_place_value, result<int&>::in_place_error );
return boost::report_errors();
}