summaryrefslogtreecommitdiff
path: root/boost/outcome/success_failure.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/outcome/success_failure.hpp')
-rw-r--r--boost/outcome/success_failure.hpp61
1 files changed, 56 insertions, 5 deletions
diff --git a/boost/outcome/success_failure.hpp b/boost/outcome/success_failure.hpp
index ed5f6cd79d..4778d9bfeb 100644
--- a/boost/outcome/success_failure.hpp
+++ b/boost/outcome/success_failure.hpp
@@ -1,5 +1,5 @@
/* Type sugar for success and failure
-(C) 2017-2021 Niall Douglas <http://www.nedproductions.biz/> (25 commits)
+(C) 2017-2023 Niall Douglas <http://www.nedproductions.biz/> (25 commits)
File Created: July 2017
@@ -82,9 +82,20 @@ inline constexpr success_type<void> success() noexcept
return success_type<void>{};
}
/*! Returns type sugar for implicitly constructing a `basic_result<T>` with a successful state.
-\effects Copies or moves the successful state supplied into the returned type sugar.
+\effects Copies the successful state supplied into the returned type sugar.
*/
-template <class T> inline constexpr success_type<std::decay_t<T>> success(T &&v, uint16_t spare_storage = 0)
+BOOST_OUTCOME_TEMPLATE(class T)
+BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_copy_constructible<T>::value))
+inline constexpr success_type<std::decay_t<T>> success(const T &v, uint16_t spare_storage = 0)
+{
+ return success_type<std::decay_t<T>>{v, spare_storage};
+}
+/*! Returns type sugar for implicitly constructing a `basic_result<T>` with a successful state.
+\effects Moves the successful state supplied into the returned type sugar.
+*/
+BOOST_OUTCOME_TEMPLATE(class T)
+BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_move_constructible<T>::value))
+inline constexpr success_type<std::decay_t<T>> success(T &&v, uint16_t spare_storage = 0)
{
return success_type<std::decay_t<T>>{static_cast<T &&>(v), spare_storage};
}
@@ -224,14 +235,54 @@ public:
/*! AWAITING HUGO JSON CONVERSION TOOL
SIGNATURE NOT RECOGNISED
*/
-template <class EC> inline constexpr failure_type<std::decay_t<EC>> failure(EC &&v, uint16_t spare_storage = 0)
+BOOST_OUTCOME_TEMPLATE(class EC)
+BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_copy_constructible<EC>::value))
+inline constexpr failure_type<std::decay_t<EC>> failure(const EC &v, uint16_t spare_storage = 0)
+{
+ return failure_type<std::decay_t<EC>>{v, spare_storage};
+}
+/*! AWAITING HUGO JSON CONVERSION TOOL
+SIGNATURE NOT RECOGNISED
+*/
+BOOST_OUTCOME_TEMPLATE(class EC)
+BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_move_constructible<EC>::value))
+inline constexpr failure_type<std::decay_t<EC>> failure(EC &&v, uint16_t spare_storage = 0)
{
return failure_type<std::decay_t<EC>>{static_cast<EC &&>(v), spare_storage};
}
/*! AWAITING HUGO JSON CONVERSION TOOL
SIGNATURE NOT RECOGNISED
*/
-template <class EC, class E> inline constexpr failure_type<std::decay_t<EC>, std::decay_t<E>> failure(EC &&v, E &&w, uint16_t spare_storage = 0)
+BOOST_OUTCOME_TEMPLATE(class EC, class E)
+BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_copy_constructible<EC>::value &&std::is_copy_constructible<E>::value))
+inline constexpr failure_type<std::decay_t<EC>, std::decay_t<E>> failure(const EC &v, const E &w, uint16_t spare_storage = 0)
+{
+ return failure_type<std::decay_t<EC>, std::decay_t<E>>{v, w, spare_storage};
+}
+/*! AWAITING HUGO JSON CONVERSION TOOL
+SIGNATURE NOT RECOGNISED
+*/
+BOOST_OUTCOME_TEMPLATE(class EC, class E)
+BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_copy_constructible<EC>::value &&std::is_move_constructible<E>::value))
+inline constexpr failure_type<std::decay_t<EC>, std::decay_t<E>> failure(const EC &v, E &&w, uint16_t spare_storage = 0)
+{
+ return failure_type<std::decay_t<EC>, std::decay_t<E>>{v, static_cast<E &&>(w), spare_storage};
+}
+/*! AWAITING HUGO JSON CONVERSION TOOL
+SIGNATURE NOT RECOGNISED
+*/
+BOOST_OUTCOME_TEMPLATE(class EC, class E)
+BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_move_constructible<EC>::value &&std::is_copy_constructible<E>::value))
+inline constexpr failure_type<std::decay_t<EC>, std::decay_t<E>> failure(EC &&v, const E &w, uint16_t spare_storage = 0)
+{
+ return failure_type<std::decay_t<EC>, std::decay_t<E>>{static_cast<EC &&>(v), w, spare_storage};
+}
+/*! AWAITING HUGO JSON CONVERSION TOOL
+SIGNATURE NOT RECOGNISED
+*/
+BOOST_OUTCOME_TEMPLATE(class EC, class E)
+BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_move_constructible<EC>::value &&std::is_move_constructible<E>::value))
+inline constexpr failure_type<std::decay_t<EC>, std::decay_t<E>> failure(EC &&v, E &&w, uint16_t spare_storage = 0)
{
return failure_type<std::decay_t<EC>, std::decay_t<E>>{static_cast<EC &&>(v), static_cast<E &&>(w), spare_storage};
}