aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/__mutex_base5
-rw-r--r--include/mutex1
-rw-r--r--include/numeric71
-rw-r--r--include/optional2
-rw-r--r--include/tuple10
-rw-r--r--include/variant21
6 files changed, 94 insertions, 16 deletions
diff --git a/include/__mutex_base b/include/__mutex_base
index 159acd626618..3b2453f1ba1a 100644
--- a/include/__mutex_base
+++ b/include/__mutex_base
@@ -48,7 +48,7 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mut
public:
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_CXX03_LANG
- constexpr mutex() _NOEXCEPT = default;
+ constexpr mutex() = default;
#else
mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
#endif
@@ -67,6 +67,9 @@ public:
_LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
};
+static_assert(is_nothrow_default_constructible<mutex>::value,
+ "the default constructor for std::mutex must be nothrow");
+
struct _LIBCPP_TYPE_VIS defer_lock_t {};
struct _LIBCPP_TYPE_VIS try_to_lock_t {};
struct _LIBCPP_TYPE_VIS adopt_lock_t {};
diff --git a/include/mutex b/include/mutex
index 55380882044d..1557ed8770d7 100644
--- a/include/mutex
+++ b/include/mutex
@@ -502,7 +502,6 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit scoped_lock(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
: __m_(__m) {}
-
scoped_lock(scoped_lock const&) = delete;
scoped_lock& operator=(scoped_lock const&) = delete;
diff --git a/include/numeric b/include/numeric
index 0e53ba33c3c7..a84fb862b667 100644
--- a/include/numeric
+++ b/include/numeric
@@ -42,6 +42,23 @@ template <class InputIterator, class OutputIterator, class BinaryOperation>
OutputIterator
partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
+template<class InputIterator, class OutputIterator, class T>
+ OutputIterator
+ exclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result, T init); // C++17
+
+template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
+ OutputIterator
+ exclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result, T init, BinaryOperation binary_op); // C++17
+
+template<class InputIterator, class OutputIterator, class T,
+ class BinaryOperation, class UnaryOperation>
+ OutputIterator
+ transform_exclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result, T init,
+ BinaryOperation binary_op, UnaryOperation unary_op); // C++17
+
template <class InputIterator, class OutputIterator>
OutputIterator
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
@@ -66,6 +83,7 @@ template <class M, class N>
#include <__config>
#include <iterator>
#include <limits> // for numeric_limits
+#include <functional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -154,6 +172,59 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
return __result;
}
+#if _LIBCPP_STD_VER > 14
+template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+exclusive_scan(_InputIterator __first, _InputIterator __last,
+ _OutputIterator __result, _Tp __init, _BinaryOp __b)
+{
+ if (__first != __last)
+ {
+ _Tp __saved = __init;
+ do
+ {
+ __init = __b(__init, *__first);
+ *__result = __saved;
+ __saved = __init;
+ ++__result;
+ } while (++__first != __last);
+ }
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+exclusive_scan(_InputIterator __first, _InputIterator __last,
+ _OutputIterator __result, _Tp __init)
+{
+ return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>());
+}
+
+template <class _InputIterator, class _OutputIterator, class _Tp,
+ class _BinaryOp, class _UnaryOp>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
+ _OutputIterator __result, _Tp __init,
+ _BinaryOp __b, _UnaryOp __u)
+{
+ if (__first != __last)
+ {
+ _Tp __saved = __init;
+ do
+ {
+ __init = __b(__init, __u(*__first));
+ *__result = __saved;
+ __saved = __init;
+ ++__result;
+ } while (++__first != __last);
+ }
+ return __result;
+}
+#endif
+
template <class _InputIterator, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
diff --git a/include/optional b/include/optional
index 8c8ee76b1411..c0fd0e7bc49f 100644
--- a/include/optional
+++ b/include/optional
@@ -897,7 +897,7 @@ public:
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
- value_type value_or(_Up&& __v) &&
+ constexpr value_type value_or(_Up&& __v) &&
{
static_assert(is_move_constructible_v<value_type>,
"optional<T>::value_or: T must be move constructible");
diff --git a/include/tuple b/include/tuple
index aa4713faf06f..a52b934aaca7 100644
--- a/include/tuple
+++ b/include/tuple
@@ -929,6 +929,16 @@ public:
void swap(tuple&) _NOEXCEPT {}
};
+#ifdef __cpp_deduction_guides
+// NOTE: These are not yet standardized, but are required to simulate the
+// implicit deduction guide that should be generated had libc++ declared the
+// tuple-like constructors "correctly"
+template <class _Alloc, class ..._Args>
+tuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>;
+template <class _Alloc, class ..._Args>
+tuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>;
+#endif
+
template <class ..._Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
diff --git a/include/variant b/include/variant
index ba15ed8c4a14..8505f3262a18 100644
--- a/include/variant
+++ b/include/variant
@@ -358,7 +358,6 @@ struct __traits {
static constexpr _Trait __copy_assignable_trait = __common_trait(
{__copy_constructible_trait,
- __move_constructible_trait,
__trait<_Types, is_trivially_copy_assignable, is_copy_assignable>...});
static constexpr _Trait __move_assignable_trait = __common_trait(
@@ -877,25 +876,24 @@ public:
}
protected:
- template <bool _CopyAssign, size_t _Ip, class _Tp, class _Arg>
+ template <size_t _Ip, class _Tp, class _Arg>
inline _LIBCPP_INLINE_VISIBILITY
- void __assign_alt(__alt<_Ip, _Tp>& __a,
- _Arg&& __arg,
- bool_constant<_CopyAssign> __tag) {
+ void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) {
if (this->index() == _Ip) {
__a.__value = _VSTD::forward<_Arg>(__arg);
} else {
struct {
void operator()(true_type) const {
- __this->__emplace<_Ip>(_Tp(_VSTD::forward<_Arg>(__arg)));
+ __this->__emplace<_Ip>(_VSTD::forward<_Arg>(__arg));
}
void operator()(false_type) const {
- __this->__emplace<_Ip>(_VSTD::forward<_Arg>(__arg));
+ __this->__emplace<_Ip>(_Tp(_VSTD::forward<_Arg>(__arg)));
}
__assignment* __this;
_Arg&& __arg;
} __impl{this, _VSTD::forward<_Arg>(__arg)};
- __impl(__tag);
+ __impl(bool_constant<is_nothrow_constructible_v<_Tp, _Arg> ||
+ !is_nothrow_move_constructible_v<_Tp>>{});
}
}
@@ -912,8 +910,7 @@ protected:
[this](auto& __this_alt, auto&& __that_alt) {
this->__assign_alt(
__this_alt,
- _VSTD::forward<decltype(__that_alt)>(__that_alt).__value,
- is_lvalue_reference<_That>{});
+ _VSTD::forward<decltype(__that_alt)>(__that_alt).__value);
},
*this, _VSTD::forward<_That>(__that));
}
@@ -1013,8 +1010,7 @@ public:
inline _LIBCPP_INLINE_VISIBILITY
void __assign(_Arg&& __arg) {
this->__assign_alt(__access::__base::__get_alt<_Ip>(*this),
- _VSTD::forward<_Arg>(__arg),
- false_type{});
+ _VSTD::forward<_Arg>(__arg));
}
inline _LIBCPP_INLINE_VISIBILITY
@@ -1088,7 +1084,6 @@ class _LIBCPP_TEMPLATE_VIS variant
__all<is_move_constructible_v<_Types>...>::value>,
private __sfinae_assign_base<
__all<(is_copy_constructible_v<_Types> &&
- is_move_constructible_v<_Types> &&
is_copy_assignable_v<_Types>)...>::value,
__all<(is_move_constructible_v<_Types> &&
is_move_assignable_v<_Types>)...>::value> {