From 17638ed0ebf889a09101c3bfc6714fe4a6efc212 Mon Sep 17 00:00:00 2001 From: zhuwenq Date: Thu, 20 Jun 2024 20:03:41 +0800 Subject: [PATCH] feat: add inplace `make_unexpected` --- include/nonstd/expected.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/nonstd/expected.hpp b/include/nonstd/expected.hpp index 305f3ab..33b58f9 100644 --- a/include/nonstd/expected.hpp +++ b/include/nonstd/expected.hpp @@ -1567,6 +1567,18 @@ make_unexpected( E && value ) -> unexpected_type< typename std::decay::type > return unexpected_type< typename std::decay::type >( std::forward(value) ); } +template< + typename E, typename... Args, + typename = std::enable_if< + std::is_constructible::value + > +> +nsel_constexpr14 auto +make_unexpected(in_place_t inplace, Args... args) -> unexpected_type< typename std::decay > +{ + return unexpected_type< typename std::decay::type >(inplace, std::forward(args)...); +} + #if nsel_P0323R <= 3 /*nsel_constexpr14*/ auto inline