aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt4
-rw-r--r--include/__refstring127
-rw-r--r--include/cmath12
-rw-r--r--include/complex158
-rw-r--r--include/optional104
-rw-r--r--include/regex2
-rw-r--r--include/string16
7 files changed, 186 insertions, 237 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 1c6790ab4652..5a1b2ccdc426 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -20,7 +20,7 @@ endif()
if (LIBCXX_INSTALL_HEADERS)
install(DIRECTORY .
- DESTINATION include/c++/v1
+ DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1
COMPONENT cxx-headers
FILES_MATCHING
${LIBCXX_HEADER_PATTERN}
@@ -44,7 +44,7 @@ if (LIBCXX_INSTALL_HEADERS)
set(generated_config_deps generate_config_header)
# Install the generated header as __config.
install(FILES ${LIBCXX_BINARY_DIR}/__generated_config
- DESTINATION include/c++/v1
+ DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
RENAME __config
COMPONENT cxx-headers)
diff --git a/include/__refstring b/include/__refstring
deleted file mode 100644
index 7f417a03c491..000000000000
--- a/include/__refstring
+++ /dev/null
@@ -1,127 +0,0 @@
-//===------------------------ __refstring ---------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___REFSTRING
-#define _LIBCPP___REFSTRING
-
-#include <__config>
-#include <stdexcept>
-#include <cstddef>
-#include <cstring>
-#ifdef __APPLE__
-#include <dlfcn.h>
-#include <mach-o/dyld.h>
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-namespace __refstring_imp { namespace {
-typedef int count_t;
-
-struct _Rep_base {
- std::size_t len;
- std::size_t cap;
- count_t count;
-};
-
-inline _Rep_base* rep_from_data(const char *data_) noexcept {
- char *data = const_cast<char *>(data_);
- return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
-}
-
-inline char * data_from_rep(_Rep_base *rep) noexcept {
- char *data = reinterpret_cast<char *>(rep);
- return data + sizeof(*rep);
-}
-
-#if defined(__APPLE__)
-inline
-const char* compute_gcc_empty_string_storage() _NOEXCEPT
-{
- void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
- if (handle == nullptr)
- return nullptr;
- void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
- if (sym == nullptr)
- return nullptr;
- return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
-}
-
-inline
-const char*
-get_gcc_empty_string_storage() _NOEXCEPT
-{
- static const char* p = compute_gcc_empty_string_storage();
- return p;
-}
-#endif
-
-}} // namespace __refstring_imp
-
-using namespace __refstring_imp;
-
-inline
-__libcpp_refstring::__libcpp_refstring(const char* msg) {
- std::size_t len = strlen(msg);
- _Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + len + 1));
- rep->len = len;
- rep->cap = len;
- rep->count = 0;
- char *data = data_from_rep(rep);
- std::memcpy(data, msg, len + 1);
- __imp_ = data;
-}
-
-inline
-__libcpp_refstring::__libcpp_refstring(const __libcpp_refstring &s) _NOEXCEPT
- : __imp_(s.__imp_)
-{
- if (__uses_refcount())
- __sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
-}
-
-inline
-__libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) _NOEXCEPT {
- bool adjust_old_count = __uses_refcount();
- struct _Rep_base *old_rep = rep_from_data(__imp_);
- __imp_ = s.__imp_;
- if (__uses_refcount())
- __sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
- if (adjust_old_count)
- {
- if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0)
- {
- ::operator delete(old_rep);
- }
- }
- return *this;
-}
-
-inline
-__libcpp_refstring::~__libcpp_refstring() {
- if (__uses_refcount()) {
- _Rep_base* rep = rep_from_data(__imp_);
- if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0) {
- ::operator delete(rep);
- }
- }
-}
-
-inline
-bool __libcpp_refstring::__uses_refcount() const {
-#ifdef __APPLE__
- return __imp_ != get_gcc_empty_string_storage();
-#else
- return true;
-#endif
-}
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif //_LIBCPP___REFSTRING
diff --git a/include/cmath b/include/cmath
index b41f247af59c..917928a1f42f 100644
--- a/include/cmath
+++ b/include/cmath
@@ -549,7 +549,7 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
-__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isnan)
return __builtin_isnan(__lcpp_x);
@@ -561,7 +561,7 @@ __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
-__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
return isnan(__lcpp_x);
}
@@ -569,7 +569,7 @@ __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
-__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isinf)
return __builtin_isinf(__lcpp_x);
@@ -581,7 +581,7 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
-__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
return isinf(__lcpp_x);
}
@@ -589,7 +589,7 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
-__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isfinite)
return __builtin_isfinite(__lcpp_x);
@@ -601,7 +601,7 @@ __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
-__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
return isfinite(__lcpp_x);
}
diff --git a/include/complex b/include/complex
index d41971b3b4db..41a47cfba47c 100644
--- a/include/complex
+++ b/include/complex
@@ -599,39 +599,39 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __bc = __b * __c;
_Tp __x = __ac - __bd;
_Tp __y = __ad + __bc;
- if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
+ if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
{
bool __recalc = false;
- if (__libcpp_isinf(__a) || __libcpp_isinf(__b))
+ if (__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b))
{
- __a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
- __b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
- if (__libcpp_isnan(__c))
+ __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
+ if (__libcpp_isnan_or_builtin(__c))
__c = copysign(_Tp(0), __c);
- if (__libcpp_isnan(__d))
+ if (__libcpp_isnan_or_builtin(__d))
__d = copysign(_Tp(0), __d);
__recalc = true;
}
- if (__libcpp_isinf(__c) || __libcpp_isinf(__d))
+ if (__libcpp_isinf_or_builtin(__c) || __libcpp_isinf_or_builtin(__d))
{
- __c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
- __d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
- if (__libcpp_isnan(__a))
+ __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
+ if (__libcpp_isnan_or_builtin(__a))
__a = copysign(_Tp(0), __a);
- if (__libcpp_isnan(__b))
+ if (__libcpp_isnan_or_builtin(__b))
__b = copysign(_Tp(0), __b);
__recalc = true;
}
- if (!__recalc && (__libcpp_isinf(__ac) || __libcpp_isinf(__bd) ||
- __libcpp_isinf(__ad) || __libcpp_isinf(__bc)))
+ if (!__recalc && (__libcpp_isinf_or_builtin(__ac) || __libcpp_isinf_or_builtin(__bd) ||
+ __libcpp_isinf_or_builtin(__ad) || __libcpp_isinf_or_builtin(__bc)))
{
- if (__libcpp_isnan(__a))
+ if (__libcpp_isnan_or_builtin(__a))
__a = copysign(_Tp(0), __a);
- if (__libcpp_isnan(__b))
+ if (__libcpp_isnan_or_builtin(__b))
__b = copysign(_Tp(0), __b);
- if (__libcpp_isnan(__c))
+ if (__libcpp_isnan_or_builtin(__c))
__c = copysign(_Tp(0), __c);
- if (__libcpp_isnan(__d))
+ if (__libcpp_isnan_or_builtin(__d))
__d = copysign(_Tp(0), __d);
__recalc = true;
}
@@ -674,7 +674,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __c = __w.real();
_Tp __d = __w.imag();
_Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
- if (__libcpp_isfinite(__logbw))
+ if (__libcpp_isfinite_or_builtin(__logbw))
{
__ilogbw = static_cast<int>(__logbw);
__c = scalbn(__c, -__ilogbw);
@@ -683,24 +683,24 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __denom = __c * __c + __d * __d;
_Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
_Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
- if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
+ if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
{
- if ((__denom == _Tp(0)) && (!__libcpp_isnan(__a) || !__libcpp_isnan(__b)))
+ if ((__denom == _Tp(0)) && (!__libcpp_isnan_or_builtin(__a) || !__libcpp_isnan_or_builtin(__b)))
{
__x = copysign(_Tp(INFINITY), __c) * __a;
__y = copysign(_Tp(INFINITY), __c) * __b;
}
- else if ((__libcpp_isinf(__a) || __libcpp_isinf(__b)) && __libcpp_isfinite(__c) && __libcpp_isfinite(__d))
+ else if ((__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b)) && __libcpp_isfinite_or_builtin(__c) && __libcpp_isfinite_or_builtin(__d))
{
- __a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
- __b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
+ __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
__x = _Tp(INFINITY) * (__a * __c + __b * __d);
__y = _Tp(INFINITY) * (__b * __c - __a * __d);
}
- else if (__libcpp_isinf(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite(__a) && __libcpp_isfinite(__b))
+ else if (__libcpp_isinf_or_builtin(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite_or_builtin(__a) && __libcpp_isfinite_or_builtin(__b))
{
- __c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
- __d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
+ __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
__x = _Tp(0) * (__a * __c + __b * __d);
__y = _Tp(0) * (__b * __c - __a * __d);
}
@@ -910,9 +910,9 @@ inline _LIBCPP_INLINE_VISIBILITY
_Tp
norm(const complex<_Tp>& __c)
{
- if (__libcpp_isinf(__c.real()))
+ if (__libcpp_isinf_or_builtin(__c.real()))
return abs(__c.real());
- if (__libcpp_isinf(__c.imag()))
+ if (__libcpp_isinf_or_builtin(__c.imag()))
return abs(__c.imag());
return __c.real() * __c.real() + __c.imag() * __c.imag();
}
@@ -955,7 +955,7 @@ complex<_Tp>
proj(const complex<_Tp>& __c)
{
std::complex<_Tp> __r = __c;
- if (__libcpp_isinf(__c.real()) || __libcpp_isinf(__c.imag()))
+ if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))
__r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
return __r;
}
@@ -969,7 +969,7 @@ typename enable_if
>::type
proj(_Tp __re)
{
- if (__libcpp_isinf(__re))
+ if (__libcpp_isinf_or_builtin(__re))
__re = abs(__re);
return complex<_Tp>(__re);
}
@@ -993,25 +993,25 @@ template<class _Tp>
complex<_Tp>
polar(const _Tp& __rho, const _Tp& __theta = _Tp(0))
{
- if (__libcpp_isnan(__rho) || signbit(__rho))
+ if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
- if (__libcpp_isnan(__theta))
+ if (__libcpp_isnan_or_builtin(__theta))
{
- if (__libcpp_isinf(__rho))
+ if (__libcpp_isinf_or_builtin(__rho))
return complex<_Tp>(__rho, __theta);
return complex<_Tp>(__theta, __theta);
}
- if (__libcpp_isinf(__theta))
+ if (__libcpp_isinf_or_builtin(__theta))
{
- if (__libcpp_isinf(__rho))
+ if (__libcpp_isinf_or_builtin(__rho))
return complex<_Tp>(__rho, _Tp(NAN));
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
}
_Tp __x = __rho * cos(__theta);
- if (__libcpp_isnan(__x))
+ if (__libcpp_isnan_or_builtin(__x))
__x = 0;
_Tp __y = __rho * sin(__theta);
- if (__libcpp_isnan(__y))
+ if (__libcpp_isnan_or_builtin(__y))
__y = 0;
return complex<_Tp>(__x, __y);
}
@@ -1042,13 +1042,13 @@ template<class _Tp>
complex<_Tp>
sqrt(const complex<_Tp>& __x)
{
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(_Tp(INFINITY), __x.imag());
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
if (__x.real() > _Tp(0))
- return complex<_Tp>(__x.real(), __libcpp_isnan(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
- return complex<_Tp>(__libcpp_isnan(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
+ return complex<_Tp>(__x.real(), __libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(__libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
}
return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
}
@@ -1060,21 +1060,21 @@ complex<_Tp>
exp(const complex<_Tp>& __x)
{
_Tp __i = __x.imag();
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
if (__x.real() < _Tp(0))
{
- if (!__libcpp_isfinite(__i))
+ if (!__libcpp_isfinite_or_builtin(__i))
__i = _Tp(1);
}
- else if (__i == 0 || !__libcpp_isfinite(__i))
+ else if (__i == 0 || !__libcpp_isfinite_or_builtin(__i))
{
- if (__libcpp_isinf(__i))
+ if (__libcpp_isinf_or_builtin(__i))
__i = _Tp(NAN);
return complex<_Tp>(__x.real(), __i);
}
}
- else if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
+ else if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
return __x;
_Tp __e = exp(__x.real());
return complex<_Tp>(__e * cos(__i), __e * sin(__i));
@@ -1132,23 +1132,23 @@ complex<_Tp>
asinh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
- if (__libcpp_isnan(__x.imag()))
+ if (__libcpp_isnan_or_builtin(__x.imag()))
return __x;
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isnan(__x.real()))
+ if (__libcpp_isnan_or_builtin(__x.real()))
{
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
if (__x.imag() == 0)
return __x;
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1)));
return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
@@ -1161,11 +1161,11 @@ complex<_Tp>
acosh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
- if (__libcpp_isnan(__x.imag()))
+ if (__libcpp_isnan_or_builtin(__x.imag()))
return complex<_Tp>(abs(__x.real()), __x.imag());
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
{
if (__x.real() > 0)
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
@@ -1176,13 +1176,13 @@ acosh(const complex<_Tp>& __x)
return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isnan(__x.real()))
+ if (__libcpp_isnan_or_builtin(__x.real()))
{
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(abs(__x.imag()), __x.real());
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
@@ -1195,21 +1195,21 @@ complex<_Tp>
atanh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
{
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
}
- if (__libcpp_isnan(__x.imag()))
+ if (__libcpp_isnan_or_builtin(__x.imag()))
{
- if (__libcpp_isinf(__x.real()) || __x.real() == 0)
+ if (__libcpp_isinf_or_builtin(__x.real()) || __x.real() == 0)
return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
return complex<_Tp>(__x.imag(), __x.imag());
}
- if (__libcpp_isnan(__x.real()))
+ if (__libcpp_isnan_or_builtin(__x.real()))
{
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
}
@@ -1227,11 +1227,11 @@ template<class _Tp>
complex<_Tp>
sinh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
+ if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
+ if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
return __x;
return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
}
@@ -1242,13 +1242,13 @@ template<class _Tp>
complex<_Tp>
cosh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(abs(__x.real()), _Tp(NAN));
- if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
+ if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(_Tp(NAN), __x.real());
if (__x.real() == 0 && __x.imag() == 0)
return complex<_Tp>(_Tp(1), __x.imag());
- if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
+ if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
return complex<_Tp>(abs(__x.real()), __x.imag());
return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
}
@@ -1259,19 +1259,19 @@ template<class _Tp>
complex<_Tp>
tanh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
- if (!__libcpp_isfinite(__x.imag()))
+ if (!__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(_Tp(1), _Tp(0));
return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
}
- if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
+ if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
return __x;
_Tp __2r(_Tp(2) * __x.real());
_Tp __2i(_Tp(2) * __x.imag());
_Tp __d(cosh(__2r) + cos(__2i));
_Tp __2rsh(sinh(__2r));
- if (__libcpp_isinf(__2rsh) && __libcpp_isinf(__d))
+ if (__libcpp_isinf_or_builtin(__2rsh) && __libcpp_isinf_or_builtin(__d))
return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
__2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
return complex<_Tp>(__2rsh/__d, sin(__2i)/__d);
@@ -1294,11 +1294,11 @@ complex<_Tp>
acos(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
- if (__libcpp_isnan(__x.imag()))
+ if (__libcpp_isnan_or_builtin(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
{
if (__x.real() < _Tp(0))
return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
@@ -1308,13 +1308,13 @@ acos(const complex<_Tp>& __x)
return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
}
- if (__libcpp_isnan(__x.real()))
+ if (__libcpp_isnan_or_builtin(__x.real()))
{
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(__x.real(), -__x.imag());
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
diff --git a/include/optional b/include/optional
index c0fd0e7bc49f..1fb953bab743 100644
--- a/include/optional
+++ b/include/optional
@@ -439,46 +439,122 @@ struct __optional_storage_base<_Tp, true>
}
};
-template <class _Tp, bool = is_trivially_copyable<_Tp>::value>
-struct __optional_storage;
-
-template <class _Tp>
-struct __optional_storage<_Tp, true> : __optional_storage_base<_Tp>
+template <class _Tp, bool = is_trivially_copy_constructible<_Tp>::value>
+struct __optional_copy_base : __optional_storage_base<_Tp>
{
using __optional_storage_base<_Tp>::__optional_storage_base;
};
template <class _Tp>
-struct __optional_storage<_Tp, false> : __optional_storage_base<_Tp>
+struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
{
- using value_type = _Tp;
using __optional_storage_base<_Tp>::__optional_storage_base;
_LIBCPP_INLINE_VISIBILITY
- __optional_storage() = default;
+ __optional_copy_base() = default;
_LIBCPP_INLINE_VISIBILITY
- __optional_storage(const __optional_storage& __opt)
+ __optional_copy_base(const __optional_copy_base& __opt)
{
this->__construct_from(__opt);
}
_LIBCPP_INLINE_VISIBILITY
- __optional_storage(__optional_storage&& __opt)
+ __optional_copy_base(__optional_copy_base&&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_base& operator=(const __optional_copy_base&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_base& operator=(__optional_copy_base&&) = default;
+};
+
+template <class _Tp, bool = is_trivially_move_constructible<_Tp>::value>
+struct __optional_move_base : __optional_copy_base<_Tp>
+{
+ using __optional_copy_base<_Tp>::__optional_copy_base;
+};
+
+template <class _Tp>
+struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
+{
+ using value_type = _Tp;
+ using __optional_copy_base<_Tp>::__optional_copy_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base(const __optional_move_base&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base(__optional_move_base&& __opt)
noexcept(is_nothrow_move_constructible_v<value_type>)
{
this->__construct_from(_VSTD::move(__opt));
}
_LIBCPP_INLINE_VISIBILITY
- __optional_storage& operator=(const __optional_storage& __opt)
+ __optional_move_base& operator=(const __optional_move_base&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base& operator=(__optional_move_base&&) = default;
+};
+
+template <class _Tp, bool =
+ is_trivially_destructible<_Tp>::value &&
+ is_trivially_copy_constructible<_Tp>::value &&
+ is_trivially_copy_assignable<_Tp>::value>
+struct __optional_copy_assign_base : __optional_move_base<_Tp>
+{
+ using __optional_move_base<_Tp>::__optional_move_base;
+};
+
+template <class _Tp>
+struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>
+{
+ using __optional_move_base<_Tp>::__optional_move_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base(const __optional_copy_assign_base&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base(__optional_copy_assign_base&&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
{
this->__assign_from(__opt);
return *this;
}
_LIBCPP_INLINE_VISIBILITY
- __optional_storage& operator=(__optional_storage&& __opt)
+ __optional_copy_assign_base& operator=(__optional_copy_assign_base&&) = default;
+};
+
+template <class _Tp, bool =
+ is_trivially_destructible<_Tp>::value &&
+ is_trivially_move_constructible<_Tp>::value &&
+ is_trivially_move_assignable<_Tp>::value>
+struct __optional_move_assign_base : __optional_copy_assign_base<_Tp>
+{
+ using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
+};
+
+template <class _Tp>
+struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp>
+{
+ using value_type = _Tp;
+ using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base(const __optional_move_assign_base& __opt) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base(__optional_move_assign_base&&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base& operator=(__optional_move_assign_base&& __opt)
noexcept(is_nothrow_move_assignable_v<value_type> &&
is_nothrow_move_constructible_v<value_type>)
{
@@ -501,11 +577,11 @@ using __optional_sfinae_assign_base_t = __sfinae_assign_base<
template <class _Tp>
class optional
- : private __optional_storage<_Tp>
+ : private __optional_move_assign_base<_Tp>
, private __optional_sfinae_ctor_base_t<_Tp>
, private __optional_sfinae_assign_base_t<_Tp>
{
- using __base = __optional_storage<_Tp>;
+ using __base = __optional_move_assign_base<_Tp>;
public:
using value_type = _Tp;
diff --git a/include/regex b/include/regex
index 443c2e303465..77ca648109b2 100644
--- a/include/regex
+++ b/include/regex
@@ -6142,7 +6142,7 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
{
__flags_ |= regex_constants::__no_update_pos;
_BidirectionalIterator __start = __match_[0].second;
- if (__match_.empty())
+ if (__match_[0].first == __match_[0].second)
{
if (__start == __end_)
{
diff --git a/include/string b/include/string
index d1a3a1f8e6cc..010a4c7816ea 100644
--- a/include/string
+++ b/include/string
@@ -676,11 +676,11 @@ private:
};
#if _LIBCPP_BIG_ENDIAN
- enum {__short_mask = 0x01};
- enum {__long_mask = 0x1ul};
+ static const size_type __short_mask = 0x01;
+ static const size_type __long_mask = 0x1ul;
#else // _LIBCPP_BIG_ENDIAN
- enum {__short_mask = 0x80};
- enum {__long_mask = ~(size_type(~0) >> 1)};
+ static const size_type __short_mask = 0x80;
+ static const size_type __long_mask = ~(size_type(~0) >> 1);
#endif // _LIBCPP_BIG_ENDIAN
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
@@ -706,11 +706,11 @@ private:
};
#if _LIBCPP_BIG_ENDIAN
- enum {__short_mask = 0x80};
- enum {__long_mask = ~(size_type(~0) >> 1)};
+ static const size_type __short_mask = 0x80;
+ static const size_type __long_mask = ~(size_type(~0) >> 1);
#else // _LIBCPP_BIG_ENDIAN
- enum {__short_mask = 0x01};
- enum {__long_mask = 0x1ul};
+ static const size_type __short_mask = 0x01;
+ static const size_type __long_mask = 0x1ul;
#endif // _LIBCPP_BIG_ENDIAN
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?