Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package expected-lite for openSUSE:Factory checked in at 2026-02-26 18:59:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/expected-lite (Old) and /work/SRC/openSUSE:Factory/.expected-lite.new.29461 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "expected-lite" Thu Feb 26 18:59:24 2026 rev:2 rq:1335242 version:0.10.0 Changes: -------- --- /work/SRC/openSUSE:Factory/expected-lite/expected-lite.changes 2024-07-02 18:17:35.277918210 +0200 +++ /work/SRC/openSUSE:Factory/.expected-lite.new.29461/expected-lite.changes 2026-02-26 18:59:24.756452188 +0100 @@ -1,0 +2,20 @@ +Wed Feb 11 07:34:25 UTC 2026 - Dirk Müller <[email protected]> + +- update to 0.10.0: + * This release of _expected-lite_ adds `[[nodiscard]]` also to + `expected`. +- update to 0.9.0: + * Release 0.9.0 of _expected lite_ introduces marking + `expected` and `bad_expected_access` as `[[nodiscard]]` at + default. This behaviour can be controlled via + `nsel_CONFIG_NO_NODISCARD`, see section Configuration. + * Remove unsupported C++98, C++03 from compilation script. + * Introduce `std11::addressof` (#70, thanks @DNKpp). + * In Readme, update sections 'Algorithms for `unexpected_type`' + and A.2 'Expected lite test specification' (#67). + * Update in-place version of `make_unexpected`, add it for use + with `std::expected`, add test (#67). + * Add inplace version of `make_unexpected` (#68, thanks + @Leonezz). + +------------------------------------------------------------------- Old: ---- expected-lite-0.8.0.tar.gz New: ---- expected-lite-0.10.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ expected-lite.spec ++++++ --- /var/tmp/diff_new_pack.MpPbRN/_old 2026-02-26 18:59:27.136551497 +0100 +++ /var/tmp/diff_new_pack.MpPbRN/_new 2026-02-26 18:59:27.136551497 +0100 @@ -1,7 +1,7 @@ # # spec file for package expected-lite # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: expected-lite -Version: 0.8.0 +Version: 0.10.0 Release: 0 Summary: Expected objects in C++11 and later in a single-file header-only library License: BSL-1.0 ++++++ expected-lite-0.8.0.tar.gz -> expected-lite-0.10.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/.github/workflows/ci.yml new/expected-lite-0.10.0/.github/workflows/ci.yml --- old/expected-lite-0.8.0/.github/workflows/ci.yml 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/.github/workflows/ci.yml 2025-11-17 23:31:17.000000000 +0100 @@ -47,9 +47,17 @@ strategy: fail-fast: false matrix: - version: [11, 12] + include: + - version: 11 + os: 'ubuntu-22.04' + - version: 12 + os: 'ubuntu-22.04' + - version: 16 + os: 'ubuntu-24.04' + - version: 19 + os: 'ubuntu-24.04' - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -78,7 +86,7 @@ strategy: fail-fast: false matrix: - os: [windows-2019, windows-2022] + os: [windows-2022] runs-on: ${{ matrix.os }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/CMakeLists.txt new/expected-lite-0.10.0/CMakeLists.txt --- old/expected-lite-0.8.0/CMakeLists.txt 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/CMakeLists.txt 2025-11-17 23:31:17.000000000 +0100 @@ -5,13 +5,13 @@ # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -cmake_minimum_required( VERSION 3.5 FATAL_ERROR ) +cmake_minimum_required( VERSION 3.15 FATAL_ERROR ) # expected-lite project and version, updated by script/update-version.py: project( expected_lite - VERSION 0.8.0 + VERSION 0.10.0 LANGUAGES CXX ) set(PROJECT_DESCRIPTION "Expected objects in C++11 and later in a single-file header-only library") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/README.md new/expected-lite-0.10.0/README.md --- old/expected-lite-0.8.0/README.md 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/README.md 2025-11-17 23:31:17.000000000 +0100 @@ -1,6 +1,6 @@ # expected lite: expected objects for C++11 and later -[](https://en.wikipedia.org/wiki/C%2B%2B#Standardization) [](https://opensource.org/licenses/BSL-1.0) [](https://github.com/martinmoene/expected-lite/actions/workflows/ci.yml) [](https://ci.appveyor.com/project/martinmoene/expected-lite) [](https://github.com/martinmoene/expected-lite/releases) [](https://raw.githubusercontent.com/martinmoene/expected-lite/master/include/nonstd/expected.hpp) [](https://conan.io/center/expected-lite) [](https:/ /vcpkg.link/ports/expected-lite) [](https://wandbox.org/permlink/MnnwqOtE8ZQ4rRsv) [](https://godbolt.org/z/9BuMZx) +[](https://en.wikipedia.org/wiki/C%2B%2B#Standardization) [](https://opensource.org/licenses/BSL-1.0) [](https://github.com/martinmoene/expected-lite/actions/workflows/ci.yml) [](https://github.com/martinmoene/expected-lite/releases) [](https://raw.githubusercontent.com/martinmoene/expected-lite/master/include/nonstd/expected.hpp) [](https://conan.io/center/expected-lite) [](https://vcpkg.link/ports/expected-lite) [](https://wandbox.org/permlink/MnnwqOtE8ZQ4rRsv) [](https://godbolt.org/z/9BuMZx) *expected lite* is a single-file header-only library for objects that either represent a valid value or an error that you can pass by value. It is intended for use with C++11 and later. The library is based on the [std::expected](http://wg21.link/p0323) proposal [1] . @@ -73,7 +73,7 @@ ## License -*expected lite* is distributed under the [Boost Software License](https://github.com/martinmoene/XXXX-lite/blob/master/LICENSE.txt). +*expected lite* is distributed under the [Boost Software License](LICENSE.txt). ## Dependencies @@ -112,7 +112,12 @@ Define this to `nsel_EXPECTED_STD` to select `std::expected` as `nonstd::expected`. Define this to `nsel_EXPECTED_NONSTD` to select `nonstd::expected` as `nonstd::expected`. Default is undefined, which has the same effect as defining to `nsel_EXPECTED_DEFAULT`. -D<b>nsel\_P0323R</b>=7 *(default)* -Define this to the proposal revision number to control the presence and behavior of features (see tables). Default is 7 for the latest revision. +Define this to the proposal revision number to control the presence and behavior of features (see tables). Default is 7 for the latest revision. + +#### Define `WIN32_LEAN_AND_MEAN` + +-D<b>nsel\_CONFIG\_WIN32\_LEAN\_AND\_MEAN</b>=1 +Define this to 0 if you want to omit automatic definition of `WIN32_LEAN_AND_MEAN`. Default is 1 when `_MSC_VER` is present. #### Disable C++ exceptions @@ -124,6 +129,11 @@ -D<b>nsel\_CONFIG\_NO\_EXCEPTIONS\_SEH</b>=0 Define this to 1 or 0 to control the use of SEH when C++ exceptions are disabled (see above). If not defined, the header tries and detect if SEH is available if C++ exceptions have been disabled (e.g. via `-fno-exceptions` or `/kernel`). Default determined in header. +#### Disable \[\[nodiscard\]\] + +-D<b>nsel\_CONFIG\_NO\_NODISCARD</b>=0 +Define this to 1 if you want to compile without \[\[nodiscard\]\]. Note that the default of marking `class expected` with \[\[nodiscard\]\] is not part of the C++23 standard. The rationale to use \[\[nodiscard\]\] is that unnoticed discarded expected error values may break the error handling flow. + #### Enable compilation errors \-D<b>nsel\_CONFIG\_CONFIRMS\_COMPILATION\_ERRORS</b>=0 @@ -273,7 +283,8 @@ | < > <= >= | constexpr bool operator ***op***(<br> unexpected_type<std::exception_ptr> const & x,<br> unexpected_type<std::exception_ptr> const & y ) | | Specialized algorithms | | | Make unexpected from | | -|  Error | template<typename E><br>[constexpr] auto **make_unexpected**( E && v) -><br> unexpected_type< typename std::decay<E>::type>| +|  Error | template<typename E><br>[constexpr] auto **make_unexpected**(E && v) -><br> unexpected_type< typename std::decay<E>::type>| +|  Arguments (in-place) | template<typename E, typename... Args><br>[constexpr] auto **make_unexpected**(in_place_t, Args &&... args) -><br> unexpected_type< typename std::decay<E>::type>| | Make unexpected from | nsel_P0323R <= 3 | |  Current exception | [constexpr] auto **make_unexpected_from_current_exception**() -><br> unexpected_type< std::exception_ptr>| @@ -398,6 +409,7 @@ unexpected_type: Provides relational operators unexpected_type: Provides relational operators, std::exception_ptr specialization make_unexpected(): Allows to create an unexpected_type<E> from an E +make_unexpected(): Allows to in-place create an unexpected_type<E> from an E unexpected: C++17 and later provide unexpected_type as unexpected bad_expected_access: Disallows default construction bad_expected_access: Allows construction from error_type diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/appveyor.yml new/expected-lite-0.10.0/appveyor.yml --- old/expected-lite-0.8.0/appveyor.yml 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/appveyor.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,71 +0,0 @@ -version: "{branch} #{build}" - -shallow_clone: true - -image: - - Visual Studio 2019 - - Visual Studio 2017 - - Visual Studio 2015 - -platform: - - Win32 - - x64 - -configuration: - - Debug - - Release - -build: - parallel: true - -environment: - matrix: - - generator: "Visual Studio 16 2019" - select_sv: -DEXPECTED_LITE_OPT_SELECT_STD=ON - - generator: "Visual Studio 16 2019" - select_sv: -DEXPECTED_LITE_OPT_SELECT_NONSTD=ON - - generator: "Visual Studio 15 2017" - select_sv: -DEXPECTED_LITE_OPT_SELECT_STD=ON - - generator: "Visual Studio 15 2017" - select_sv: -DEXPECTED_LITE_OPT_SELECT_NONSTD=ON - - generator: "Visual Studio 14 2015" - # - generator: "Visual Studio 12 2013" - # - generator: "Visual Studio 11 2012" - # - generator: "Visual Studio 10 2010" - -matrix: - exclude: - - image: Visual Studio 2015 - generator: "Visual Studio 16 2019" - - image: Visual Studio 2019 - generator: "Visual Studio 15 2017" - - image: Visual Studio 2019 - generator: "Visual Studio 14 2015" - - image: Visual Studio 2019 - generator: "Visual Studio 12 2013" - - image: Visual Studio 2019 - generator: "Visual Studio 11 2012" - - image: Visual Studio 2019 - generator: "Visual Studio 10 2010" - - image: Visual Studio 2015 - generator: "Visual Studio 15 2017" - - image: Visual Studio 2017 - generator: "Visual Studio 16 2019" - - image: Visual Studio 2017 - generator: "Visual Studio 14 2015" - - image: Visual Studio 2017 - generator: "Visual Studio 12 2013" - - image: Visual Studio 2017 - generator: "Visual Studio 11 2012" - - image: Visual Studio 2017 - generator: "Visual Studio 10 2010" - -before_build: - - mkdir build && cd build - - cmake -A %platform% -G "%generator%" "%select_sv%" -DEXPECTED_LITE_OPT_BUILD_TESTS=ON -DEXPECTED_LITE_OPT_BUILD_EXAMPLES=OFF .. - -build_script: - - cmake --build . --config %configuration% - -test_script: - - ctest --output-on-failure -C %configuration% diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/conanfile.py new/expected-lite-0.10.0/conanfile.py --- old/expected-lite-0.8.0/conanfile.py 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/conanfile.py 2025-11-17 23:31:17.000000000 +0100 @@ -1,7 +1,7 @@ from conans import ConanFile, CMake class ExpectedLiteConan(ConanFile): - version = "0.8.0" + version = "0.10.0" name = "expected-lite" description = "Expected objects for C++11 and later" license = "Boost Software License - Version 1.0. http://www.boost.org/LICENSE_1_0.txt" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/example/CMakeLists.txt new/expected-lite-0.10.0/example/CMakeLists.txt --- old/expected-lite-0.8.0/example/CMakeLists.txt 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/example/CMakeLists.txt 2025-11-17 23:31:17.000000000 +0100 @@ -6,7 +6,7 @@ # (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) if( NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION ) - cmake_minimum_required( VERSION 3.8 FATAL_ERROR ) + cmake_minimum_required( VERSION 3.15 FATAL_ERROR ) endif() project( example LANGUAGES CXX ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/include/nonstd/expected.hpp new/expected-lite-0.10.0/include/nonstd/expected.hpp --- old/expected-lite-0.8.0/include/nonstd/expected.hpp 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/include/nonstd/expected.hpp 2025-11-17 23:31:17.000000000 +0100 @@ -1,6 +1,6 @@ // This version targets C++11 and later. // -// Copyright (C) 2016-2020 Martin Moene. +// Copyright (C) 2016-2025 Martin Moene. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,7 +13,7 @@ #define NONSTD_EXPECTED_LITE_HPP #define expected_lite_MAJOR 0 -#define expected_lite_MINOR 8 +#define expected_lite_MINOR 10 #define expected_lite_PATCH 0 #define expected_lite_VERSION expected_STRINGIFY(expected_lite_MAJOR) "." expected_STRINGIFY(expected_lite_MINOR) "." expected_STRINGIFY(expected_lite_PATCH) @@ -81,6 +81,22 @@ # define nsel_P2505R 5 #endif +// Lean and mean inclusion of Windows.h, if applicable; default on for MSVC: + +#if !defined(nsel_CONFIG_WIN32_LEAN_AND_MEAN) && defined(_MSC_VER) +# define nsel_CONFIG_WIN32_LEAN_AND_MEAN 1 +#else +# define nsel_CONFIG_WIN32_LEAN_AND_MEAN 0 +#endif + +// Control marking class expected with [[nodiscard]]]: + +#if !defined(nsel_CONFIG_NO_NODISCARD) +# define nsel_CONFIG_NO_NODISCARD 0 +#else +# define nsel_CONFIG_NO_NODISCARD 1 +#endif + // Control presence of C++ exception handling (try and auto discover): #ifndef nsel_CONFIG_NO_EXCEPTIONS @@ -96,8 +112,10 @@ // at default use SEH with MSVC for no C++ exceptions -#ifndef nsel_CONFIG_NO_EXCEPTIONS_SEH -# define nsel_CONFIG_NO_EXCEPTIONS_SEH ( nsel_CONFIG_NO_EXCEPTIONS && _MSC_VER ) +#if !defined(nsel_CONFIG_NO_EXCEPTIONS_SEH) && defined(_MSC_VER) +# define nsel_CONFIG_NO_EXCEPTIONS_SEH nsel_CONFIG_NO_EXCEPTIONS +#else +# define nsel_CONFIG_NO_EXCEPTIONS_SEH 0 #endif // C++ language version detection (C++23 is speculative): @@ -243,11 +261,24 @@ // Unconditionally provide make_unexpected(): - template< typename E> + template< typename E > constexpr auto make_unexpected( E && value ) -> unexpected< typename std::decay<E>::type > { return unexpected< typename std::decay<E>::type >( std::forward<E>(value) ); } + + template + < + typename E, typename... Args, + typename = std::enable_if< + std::is_constructible<E, Args...>::value + > + > + constexpr auto + make_unexpected( std::in_place_t inplace, Args &&... args ) -> unexpected_type< typename std::decay<E>::type > + { + return unexpected_type< typename std::decay<E>::type >( inplace, std::forward<Args>(args)...); + } } // namespace nonstd #else // nsel_USES_STD_EXPECTED @@ -264,6 +295,12 @@ // additional includes: +#if nsel_CONFIG_WIN32_LEAN_AND_MEAN +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +#endif + #if nsel_CONFIG_NO_EXCEPTIONS # if nsel_CONFIG_NO_EXCEPTIONS_SEH # include <windows.h> // for ExceptionCodes @@ -390,11 +427,17 @@ // Presence of language and library features: +#define nsel_CPP11_000 (nsel_CPP11_OR_GREATER) #define nsel_CPP17_000 (nsel_CPP17_OR_GREATER) +// Presence of C++11 library features: + +#define nsel_HAVE_ADDRESSOF nsel_CPP11_000 + // Presence of C++17 language features: #define nsel_HAVE_DEPRECATED nsel_CPP17_000 +#define nsel_HAVE_NODISCARD nsel_CPP17_000 // C++ feature usage: @@ -404,12 +447,37 @@ # define nsel_deprecated(msg) /*[[deprecated]]*/ #endif +#if nsel_HAVE_NODISCARD && !nsel_CONFIG_NO_NODISCARD +# define nsel_NODISCARD [[nodiscard]] +#else +# define nsel_NODISCARD /*[[nodiscard]]*/ +#endif + // // expected: // namespace nonstd { namespace expected_lite { +// library features C++11: + +namespace std11 { + +// #if 0 && nsel_HAVE_ADDRESSOF +#if nsel_HAVE_ADDRESSOF + using std::addressof; +#else + template< class T > + T * addressof( T & arg ) noexcept + { + return &arg; + } + + template< class T > + const T * addressof( const T && ) = delete; +#endif +} // namespace std11 + // type traits C++17: namespace std17 { @@ -529,29 +597,29 @@ void construct_value() { - new( &m_value ) value_type(); + new( std11::addressof(m_value) ) value_type(); } // void construct_value( value_type const & e ) // { - // new( &m_value ) value_type( e ); + // new( std11::addressof(m_value) ) value_type( e ); // } // void construct_value( value_type && e ) // { - // new( &m_value ) value_type( std::move( e ) ); + // new( std11::addressof(m_value) ) value_type( std::move( e ) ); // } template< class... Args > void emplace_value( Args&&... args ) { - new( &m_value ) value_type( std::forward<Args>(args)...); + new( std11::addressof(m_value) ) value_type( std::forward<Args>(args)...); } template< class U, class... Args > void emplace_value( std::initializer_list<U> il, Args&&... args ) { - new( &m_value ) value_type( il, std::forward<Args>(args)... ); + new( std11::addressof(m_value) ) value_type( il, std::forward<Args>(args)... ); } void destruct_value() @@ -561,24 +629,24 @@ // void construct_error( error_type const & e ) // { - // // new( &m_error ) error_type( e ); + // // new( std11::addressof(m_error) ) error_type( e ); // } // void construct_error( error_type && e ) // { - // // new( &m_error ) error_type( std::move( e ) ); + // // new( std11::addressof(m_error) ) error_type( std::move( e ) ); // } template< class... Args > void emplace_error( Args&&... args ) { - new( &m_error ) error_type( std::forward<Args>(args)...); + new( std11::addressof(m_error) ) error_type( std::forward<Args>(args)...); } template< class U, class... Args > void emplace_error( std::initializer_list<U> il, Args&&... args ) { - new( &m_error ) error_type( il, std::forward<Args>(args)... ); + new( std11::addressof(m_error) ) error_type( il, std::forward<Args>(args)... ); } void destruct_error() @@ -608,12 +676,12 @@ value_type const * value_ptr() const { - return &m_value; + return std11::addressof(m_value); } value_type * value_ptr() { - return &m_value; + return std11::addressof(m_value); } error_type const & error() const & @@ -675,29 +743,29 @@ void construct_value() { - new( &m_value ) value_type(); + new( std11::addressof(m_value) ) value_type(); } void construct_value( value_type const & e ) { - new( &m_value ) value_type( e ); + new( std11::addressof(m_value) ) value_type( e ); } void construct_value( value_type && e ) { - new( &m_value ) value_type( std::move( e ) ); + new( std11::addressof(m_value) ) value_type( std::move( e ) ); } template< class... Args > void emplace_value( Args&&... args ) { - new( &m_value ) value_type( std::forward<Args>(args)...); + new( std11::addressof(m_value) ) value_type( std::forward<Args>(args)...); } template< class U, class... Args > void emplace_value( std::initializer_list<U> il, Args&&... args ) { - new( &m_value ) value_type( il, std::forward<Args>(args)... ); + new( std11::addressof(m_value) ) value_type( il, std::forward<Args>(args)... ); } void destruct_value() @@ -707,24 +775,24 @@ void construct_error( error_type const & e ) { - new( &m_error ) error_type( e ); + new( std11::addressof(m_error) ) error_type( e ); } void construct_error( error_type && e ) { - new( &m_error ) error_type( std::move( e ) ); + new( std11::addressof(m_error) ) error_type( std::move( e ) ); } template< class... Args > void emplace_error( Args&&... args ) { - new( &m_error ) error_type( std::forward<Args>(args)...); + new( std11::addressof(m_error) ) error_type( std::forward<Args>(args)...); } template< class U, class... Args > void emplace_error( std::initializer_list<U> il, Args&&... args ) { - new( &m_error ) error_type( il, std::forward<Args>(args)... ); + new( std11::addressof(m_error) ) error_type( il, std::forward<Args>(args)... ); } void destruct_error() @@ -754,12 +822,12 @@ value_type const * value_ptr() const { - return &m_value; + return std11::addressof(m_value); } value_type * value_ptr() { - return &m_value; + return std11::addressof(m_value); } error_type const & error() const & @@ -805,7 +873,7 @@ /// discriminated union to hold only 'error'. template< typename E > -struct storage_t_impl<void, E> +struct storage_t_impl< void, E > { template< typename, typename > friend class nonstd::expected_lite::expected; @@ -823,24 +891,24 @@ void construct_error( error_type const & e ) { - new( &m_error ) error_type( e ); + new( std11::addressof(m_error) ) error_type( e ); } void construct_error( error_type && e ) { - new( &m_error ) error_type( std::move( e ) ); + new( std11::addressof(m_error) ) error_type( std::move( e ) ); } template< class... Args > void emplace_error( Args&&... args ) { - new( &m_error ) error_type( std::forward<Args>(args)...); + new( std11::addressof(m_error) ) error_type( std::forward<Args>(args)...); } template< class U, class... Args > void emplace_error( std::initializer_list<U> il, Args&&... args ) { - new( &m_error ) error_type( il, std::forward<Args>(args)... ); + new( std11::addressof(m_error) ) error_type( il, std::forward<Args>(args)... ); } void destruct_error() @@ -1172,11 +1240,11 @@ } template< typename F, typename ... Args > -using invoke_result_nocvref_t = typename std20::remove_cvref< decltype( invoke( std::declval< F >(), std::declval< Args >()... ) ) >::type; +using invoke_result_nocvref_t = typename std20::remove_cvref< decltype( ::nonstd::expected_lite::detail::invoke( std::declval< F >(), std::declval< Args >()... ) ) >::type; #if nsel_P2505R >= 5 template< typename F, typename ... Args > -using transform_invoke_result_t = typename std::remove_cv< decltype( invoke( std::declval< F >(), std::declval< Args >()... ) ) >::type; +using transform_invoke_result_t = typename std::remove_cv< decltype( ::nonstd::expected_lite::detail::invoke( std::declval< F >(), std::declval< Args >()... ) ) >::type; #else template< typename F, typename ... Args > using transform_invoke_result_t = invoke_result_nocvref_t @@ -1548,10 +1616,10 @@ #if nsel_P0323R <= 3 -template< typename E> +template< typename E > struct is_unexpected : std::false_type {}; -template< typename E> +template< typename E > struct is_unexpected< unexpected_type<E> > : std::true_type {}; #endif // nsel_P0323R @@ -1560,13 +1628,26 @@ // keep make_unexpected() removed in p0323r2 for pre-C++17: -template< typename E> +template< typename E > nsel_constexpr14 auto make_unexpected( E && value ) -> unexpected_type< typename std::decay<E>::type > { return unexpected_type< typename std::decay<E>::type >( std::forward<E>(value) ); } +template +< + typename E, typename... Args, + typename = std::enable_if< + std::is_constructible<E, Args...>::value + > +> +nsel_constexpr14 auto +make_unexpected( nonstd_lite_in_place_t(E), Args &&... args ) -> unexpected_type< typename std::decay<E>::type > +{ + return std::move( unexpected_type< typename std::decay<E>::type >( nonstd_lite_in_place(E), std::forward<Args>(args)...) ); +} + #if nsel_P0323R <= 3 /*nsel_constexpr14*/ auto inline @@ -1580,12 +1661,12 @@ /// x.x.6, x.x.7 expected access error template< typename E > -class bad_expected_access; +class nsel_NODISCARD bad_expected_access; /// x.x.7 bad_expected_access<void>: expected access error template <> -class bad_expected_access< void > : public std::exception +class nsel_NODISCARD bad_expected_access< void > : public std::exception { public: explicit bad_expected_access() @@ -1598,7 +1679,7 @@ #if !nsel_CONFIG_NO_EXCEPTIONS template< typename E > -class bad_expected_access : public bad_expected_access< void > +class nsel_NODISCARD bad_expected_access : public bad_expected_access< void > { public: using error_type = E; @@ -1758,10 +1839,10 @@ #if nsel_P0323R <= 2 template< typename T, typename E = std::exception_ptr > -class expected +class nsel_NODISCARD expected #else template< typename T, typename E > -class expected +class nsel_NODISCARD expected #endif // nsel_P0323R { private: @@ -2212,7 +2293,6 @@ ? ( contained.value() ) : ( error_traits<error_type>::rethrow( contained.error() ), contained.value() ); } - nsel_RESTORE_MSVC_WARNINGS() #if !nsel_COMPILER_GNUC_VERSION || nsel_COMPILER_GNUC_VERSION >= 490 @@ -2231,6 +2311,7 @@ } #endif + nsel_RESTORE_MSVC_WARNINGS() constexpr error_type const & error() const & { @@ -2264,7 +2345,7 @@ template< typename Ex > bool has_exception() const { - using ContainedEx = typename std::remove_reference< decltype( get_unexpected().value() ) >::type; + using ContainedEx = typename std::remove_reference< decltype( get_unexpected().error() ) >::type; return ! has_value() && std::is_base_of< Ex, ContainedEx>::value; } @@ -2649,7 +2730,7 @@ /// class expected, void specialization template< typename E > -class expected<void, E> +class nsel_NODISCARD expected< void, E > { private: template< typename, typename > friend class expected; @@ -2846,7 +2927,7 @@ template< typename Ex > bool has_exception() const { - using ContainedEx = typename std::remove_reference< decltype( get_unexpected().value() ) >::type; + using ContainedEx = typename std::remove_reference< decltype( get_unexpected().error() ) >::type; return ! has_value() && std::is_base_of< Ex, ContainedEx>::value; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/test/CMakeLists.txt new/expected-lite-0.10.0/test/CMakeLists.txt --- old/expected-lite-0.8.0/test/CMakeLists.txt 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/test/CMakeLists.txt 2025-11-17 23:31:17.000000000 +0100 @@ -6,7 +6,7 @@ # (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) if( NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION ) - cmake_minimum_required( VERSION 3.5 FATAL_ERROR ) + cmake_minimum_required( VERSION 3.15 FATAL_ERROR ) endif() project( test LANGUAGES CXX ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/test/expected-main.t.cpp new/expected-lite-0.10.0/test/expected-main.t.cpp --- old/expected-lite-0.8.0/test/expected-main.t.cpp 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/test/expected-main.t.cpp 2025-11-17 23:31:17.000000000 +0100 @@ -10,6 +10,9 @@ #define expected_PRESENT( x ) \ std::cout << #x << ": " << x << "\n" +#define expected_DEFINED( x ) \ + std::cout << #x << ": (defined)\n" + #define expected_ABSENT( x ) \ std::cout << #x << ": (undefined)\n" @@ -35,7 +38,7 @@ expected_PRESENT( expected_lite_VERSION ); } -CASE( "any configuration" "[.expected][.config]" ) +CASE( "expected-lite configuration" "[.expected][.config]" ) { expected_PRESENT( nsel_HAVE_STD_EXPECTED ); expected_PRESENT( nsel_USES_STD_EXPECTED ); @@ -43,7 +46,9 @@ expected_PRESENT( nsel_EXPECTED_NONSTD ); expected_PRESENT( nsel_EXPECTED_STD ); expected_PRESENT( nsel_CONFIG_SELECT_EXPECTED ); + expected_PRESENT( nsel_CONFIG_WIN32_LEAN_AND_MEAN ); expected_PRESENT( nsel_CONFIG_NO_EXCEPTIONS ); + expected_PRESENT( nsel_CONFIG_NO_EXCEPTIONS_SEH ); expected_PRESENT( nsel_CPLUSPLUS ); } @@ -84,6 +89,12 @@ std::cout << "(Presence of C++ library features not available: using std::expected)\n"; #else +#ifdef WIN32_LEAN_AND_MEAN + expected_DEFINED( WIN32_LEAN_AND_MEAN ); +#else + expected_ABSENT( WIN32_LEAN_AND_MEAN ); +#endif + #ifdef __cpp_exceptions expected_PRESENT( __cpp_exceptions ); #else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/test/expected.t.cpp new/expected-lite-0.10.0/test/expected.t.cpp --- old/expected-lite-0.8.0/test/expected.t.cpp 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/test/expected.t.cpp 2025-11-17 23:31:17.000000000 +0100 @@ -9,12 +9,21 @@ // A proposal to add a utility class to represent expected monad // by Vicente J. Botet Escriba and Pierre Talbot, http:://wg21.link/p0323 +#include <cassert> #include "expected-main.t.hpp" #ifndef nsel_CONFIG_CONFIRMS_COMPILATION_ERRORS #define nsel_CONFIG_CONFIRMS_COMPILATION_ERRORS 0 #endif +#define nsel_HAVE_MAYBE_UNUSED nsel_CPP17_000 + +#if nsel_HAVE_MAYBE_UNUSED +# define nsel_MAYBE_UNUSED [[maybe_unused]] +#else +# define nsel_MAYBE_UNUSED /*[[maybe_unused]]*/ +#endif + // Suppress: // - unused parameter, for cases without assertions such as [.std...] #if defined(__clang__) @@ -566,6 +575,17 @@ EXPECT( u.error() == error ); } +CASE( "make_unexpected(): Allows to in-place create an unexpected_type<E> from an E" ) +{ + const auto a = 'a'; + const auto b = 7; + + auto u = make_unexpected< std::pair<char, int> >( in_place, a, b ); + + EXPECT( u.error().first == a ); + EXPECT( u.error().second == b ); +} + CASE( "make_unexpected_from_current_exception(): Allows to create an unexpected_type<std::exception_ptr> from the current exception" "[.deprecated]" ) { #if nsel_P0323R <= 2 @@ -596,7 +616,7 @@ CASE( "unexpected: C++17 and later provide unexpected_type as unexpected" ) { #if nsel_CPP17_OR_GREATER || nsel_COMPILER_MSVC_VERSION > 141 - nonstd::unexpected<int> u{7}; + nsel_MAYBE_UNUSED nonstd::unexpected<int> u{7}; #else EXPECT( !!"unexpected is not available (no C++17)." ); #endif @@ -1333,7 +1353,7 @@ } const auto fallback_throw = []( int ) -> expected<int, int> { throw std::runtime_error( "or_else" ); }; - EXPECT_THROWS_AS( (expected<int, int>{ unexpect, 42 }).or_else( fallback_throw ), std::runtime_error ); + EXPECT_THROWS_AS( (void)(expected<int, int>{ unexpect, 42 }).or_else( fallback_throw ), std::runtime_error ); const auto moveonly_fallback_to_66 = [](int) -> expected<MoveOnly, int> { return MoveOnly{ 66 }; }; EXPECT( (expected<MoveOnly, int>{ MoveOnly{ 33 } }).or_else( moveonly_fallback_to_66 ).value() == 33 ); @@ -1354,6 +1374,8 @@ EXPECT( ue.transform( mul2 ).error() == 42 ); } + expected<std::vector<int>, int>{std::vector<int>{}}.transform([](const std::vector<int>&) { }); + #if nsel_P2505R >= 5 // R5 changed remove_cvref_t to remove_cv_t in transform/transform_error, which broke data member pointer transforms, // because the result type must be a valid expected value type, but expressions with reference types are not. @@ -2215,6 +2237,23 @@ EXPECT( !unexpected.has_value() ); } +namespace issue_70 { + + struct overload_addressof + { + overload_addressof * operator & () + { + assert( 0 && "operator&() called"); + return this; + } + }; +} // namespace issue_70 + +CASE("issue-70") +{ + nonstd::expected<issue_70::overload_addressof, int> e; +} + #if !nsel_USES_STD_EXPECTED && nsel_P2505R >= 3 CASE( "invoke" ) { @@ -2253,7 +2292,7 @@ struct nullopt_t{}; -const nullopt_t nullopt{}; +nsel_MAYBE_UNUSED const nullopt_t nullopt{}; /// optional expressed in expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/expected-lite-0.8.0/test/tg-all.bat new/expected-lite-0.10.0/test/tg-all.bat --- old/expected-lite-0.8.0/test/tg-all.bat 2024-06-05 22:58:29.000000000 +0200 +++ new/expected-lite-0.10.0/test/tg-all.bat 2025-11-17 23:31:17.000000000 +0100 @@ -1,3 +1,4 @@ -@for %%s in ( c++98 c++03 c++11 c++14 c++17 ) do ( +@rem c++98 c++03 +@for %%s in ( c++11 c++14 c++17 ) do ( call tg.bat %%s )
