.. note::
.. [#note-P2273] P2273: ``make_unique_for_overwrite`` isn't done yet since `P1020` hasn't been implemented yet.
+ .. [#note-P0533R9] P0533R9: ``isfinite``, ``isinf``, ``isnan`` and ``isnormal`` are implemented.
.. _issues-status-cxx2b:
"`P2401R0 <https://wg21.link/P2401R0>`__","LWG","Add a conditional ``noexcept`` specification to ``std::exchange``","October 2021","|Complete|","14.0"
"","","","","",""
"`P0323R12 <https://wg21.link/P0323R12>`__","LWG","``std::expected``","February 2022","|Complete|","16.0"
-"`P0533R9 <https://wg21.link/P0533R9>`__","LWG","``constexpr`` for ``<cmath>`` and ``<cstdlib>``","February 2022","",""
+"`P0533R9 <https://wg21.link/P0533R9>`__","LWG","``constexpr`` for ``<cmath>`` and ``<cstdlib>``","February 2022","|In progress| [#note-P0533R9]_",""
"`P0627R6 <https://wg21.link/P0627R6>`__","LWG","Function to mark unreachable code","February 2022","|Complete|","15.0"
"`P1206R7 <https://wg21.link/P1206R7>`__","LWG","``ranges::to``: A function to convert any range to a container","February 2022","","","|ranges|"
"`P1413R3 <https://wg21.link/P1413R3>`__","LWG","Deprecate ``std::aligned_storage`` and ``std::aligned_union``","February 2022","",""
template <class _A1,
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
}
template <class _A1,
std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
return true;
}
template <class _A1,
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
return __builtin_isinf((typename std::__promote<_A1>::type)__x);
}
template <class _A1>
-inline _LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
isinf(_A1) _NOEXCEPT {
return false;
}
# ifdef _LIBCPP_PREFERRED_OVERLOAD
-inline _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __builtin_isinf(__x); }
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
+ return __builtin_isinf(__x);
+}
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { return __builtin_isinf(__x); }
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT {
+ return __builtin_isinf(__x);
+}
-inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); }
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT {
+ return __builtin_isinf(__x);
+}
# endif
// isnan
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
return __builtin_isnan(__x);
}
template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
return false;
}
# ifdef _LIBCPP_PREFERRED_OVERLOAD
-inline _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __builtin_isnan(__x); }
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
+ return __builtin_isnan(__x);
+}
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { return __builtin_isnan(__x); }
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT {
+ return __builtin_isnan(__x);
+}
-inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); }
+inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT {
+ return __builtin_isnan(__x);
+}
# endif
// isnormal
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
return __builtin_isnormal(__x);
}
template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
return __x != 0;
}
// REQUIRES: clang
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// We don't control the implementation of these functions on windows
+// UNSUPPORTED: windows
+
#include <cmath>
#include <cstdlib>
#include <cassert>
ASSERT_NOT_CONSTEXPR_CXX23(std::fpclassify(-1.0) == FP_NORMAL);
ASSERT_NOT_CONSTEXPR_CXX23(std::fpclassify(-1.0L) == FP_NORMAL);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isfinite(-1.0f) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isfinite(-1.0) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isfinite(-1.0L) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isfinite(-1.0f) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isfinite(-1.0) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isfinite(-1.0L) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isinf(-1.0f) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isinf(-1.0) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isinf(-1.0L) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isinf(-1.0f) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isinf(-1.0) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isinf(-1.0L) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnan(-1.0f) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnan(-1.0) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnan(-1.0L) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isnan(-1.0f) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isnan(-1.0) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isnan(-1.0L) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnormal(-1.0f) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnormal(-1.0) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnormal(-1.0L) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isnormal(-1.0f) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isnormal(-1.0) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isnormal(-1.0L) == 1);
ASSERT_NOT_CONSTEXPR_CXX23(std::signbit(-1.0f) == 1);
ASSERT_NOT_CONSTEXPR_CXX23(std::signbit(-1.0) == 1);
ASSERT_NOT_CONSTEXPR_CXX23(std::fpclassify(-1.0) == FP_NORMAL);
ASSERT_NOT_CONSTEXPR_CXX23(std::fpclassify(-1.0L) == FP_NORMAL);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isfinite(-1.0f) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isfinite(-1.0) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isfinite(-1.0L) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isfinite(-1.0f) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isfinite(-1.0) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isfinite(-1.0L) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isinf(-1.0f) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isinf(-1.0) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isinf(-1.0L) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isinf(-1.0f) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isinf(-1.0) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isinf(-1.0L) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnan(-1.0f) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnan(-1.0) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnan(-1.0L) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isnan(-1.0f) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isnan(-1.0) == 0);
+ ASSERT_CONSTEXPR_CXX23(std::isnan(-1.0L) == 0);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnormal(-1.0f) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnormal(-1.0) == 1);
- ASSERT_NOT_CONSTEXPR_CXX23(std::isnormal(-1.0L) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isnormal(-1.0f) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isnormal(-1.0) == 1);
+ ASSERT_CONSTEXPR_CXX23(std::isnormal(-1.0L) == 1);
ASSERT_NOT_CONSTEXPR_CXX23(std::signbit(-1.0f) == 1);
ASSERT_NOT_CONSTEXPR_CXX23(std::signbit(-1.0) == 1);
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// bool isfinite(floating-point-type x); // constexpr since C++23
+
+// We don't control the implementation on windows
+// UNSUPPORTED: windows
+
+#include <cassert>
+#include <cmath>
+#include <limits>
+
+#include "test_macros.h"
+#include "type_algorithms.h"
+
+struct TestFloat {
+ template <class T>
+ static TEST_CONSTEXPR_CXX23 bool test() {
+ assert(std::isfinite(std::numeric_limits<T>::max()));
+ assert(!std::isfinite(std::numeric_limits<T>::infinity()));
+ assert(std::isfinite(std::numeric_limits<T>::min()));
+ assert(std::isfinite(std::numeric_limits<T>::denorm_min()));
+ assert(std::isfinite(std::numeric_limits<T>::lowest()));
+ assert(!std::isfinite(-std::numeric_limits<T>::infinity()));
+ assert(std::isfinite(T(0)));
+ assert(!std::isfinite(std::numeric_limits<T>::quiet_NaN()));
+ assert(!std::isfinite(std::numeric_limits<T>::signaling_NaN()));
+
+ return true;
+ }
+
+ template <class T>
+ TEST_CONSTEXPR_CXX23 void operator()() {
+ test<T>();
+#if TEST_STD_VER >= 23
+ static_assert(test<T>());
+#endif
+ }
+};
+
+struct TestInt {
+ template <class T>
+ static TEST_CONSTEXPR_CXX23 bool test() {
+ assert(std::isfinite(std::numeric_limits<T>::max()));
+ assert(std::isfinite(std::numeric_limits<T>::lowest()));
+ assert(std::isfinite(T(0)));
+
+ return true;
+ }
+
+ template <class T>
+ TEST_CONSTEXPR_CXX23 void operator()() {
+ test<T>();
+#if TEST_STD_VER >= 23
+ static_assert(test<T>());
+#endif
+ }
+};
+
+int main(int, char**) {
+ meta::for_each(meta::floating_point_types(), TestFloat());
+ meta::for_each(meta::integral_types(), TestInt());
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// bool isfinite(floating-point-type x); // constexpr since C++23
+
+// We don't control the implementation on windows
+// UNSUPPORTED: windows
+
+#include <cassert>
+#include <cmath>
+#include <limits>
+
+#include "test_macros.h"
+#include "type_algorithms.h"
+
+struct TestFloat {
+ template <class T>
+ static TEST_CONSTEXPR_CXX23 bool test() {
+ assert(!std::isinf(std::numeric_limits<T>::max()));
+ assert(std::isinf(std::numeric_limits<T>::infinity()));
+ assert(!std::isinf(std::numeric_limits<T>::min()));
+ assert(!std::isinf(std::numeric_limits<T>::denorm_min()));
+ assert(!std::isinf(std::numeric_limits<T>::lowest()));
+ assert(std::isinf(-std::numeric_limits<T>::infinity()));
+ assert(!std::isinf(T(0)));
+ assert(!std::isinf(std::numeric_limits<T>::quiet_NaN()));
+ assert(!std::isinf(std::numeric_limits<T>::signaling_NaN()));
+
+ return true;
+ }
+
+ template <class T>
+ TEST_CONSTEXPR_CXX23 void operator()() {
+ test<T>();
+#if TEST_STD_VER >= 23
+ static_assert(test<T>());
+#endif
+ }
+};
+
+struct TestInt {
+ template <class T>
+ static TEST_CONSTEXPR_CXX23 bool test() {
+ assert(!std::isinf(std::numeric_limits<T>::max()));
+ assert(!std::isinf(std::numeric_limits<T>::lowest()));
+ assert(!std::isinf(T(0)));
+
+ return true;
+ }
+
+ template <class T>
+ TEST_CONSTEXPR_CXX23 void operator()() {
+ test<T>();
+#if TEST_STD_VER >= 23
+ static_assert(test<T>());
+#endif
+ }
+};
+
+int main(int, char**) {
+ meta::for_each(meta::floating_point_types(), TestFloat());
+ meta::for_each(meta::integral_types(), TestInt());
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// bool isfinite(floating-point-type x); // constexpr since C++23
+
+// We don't control the implementation on windows
+// UNSUPPORTED: windows
+
+#include <cassert>
+#include <cmath>
+#include <limits>
+
+#include "test_macros.h"
+#include "type_algorithms.h"
+
+struct TestFloat {
+ template <class T>
+ static TEST_CONSTEXPR_CXX23 bool test() {
+ assert(!std::isnan(std::numeric_limits<T>::max()));
+ assert(!std::isnan(std::numeric_limits<T>::infinity()));
+ assert(!std::isnan(std::numeric_limits<T>::min()));
+ assert(!std::isnan(std::numeric_limits<T>::denorm_min()));
+ assert(!std::isnan(std::numeric_limits<T>::lowest()));
+ assert(!std::isnan(-std::numeric_limits<T>::infinity()));
+ assert(!std::isnan(T(0)));
+ assert(std::isnan(std::numeric_limits<T>::quiet_NaN()));
+ assert(std::isnan(std::numeric_limits<T>::signaling_NaN()));
+
+ return true;
+ }
+
+ template <class T>
+ TEST_CONSTEXPR_CXX23 void operator()() {
+ test<T>();
+#if TEST_STD_VER >= 23
+ static_assert(test<T>());
+#endif
+ }
+};
+
+struct TestInt {
+ template <class T>
+ static TEST_CONSTEXPR_CXX23 bool test() {
+ assert(!std::isnan(std::numeric_limits<T>::max()));
+ assert(!std::isnan(std::numeric_limits<T>::lowest()));
+ assert(!std::isnan(T(0)));
+
+ return true;
+ }
+
+ template <class T>
+ TEST_CONSTEXPR_CXX23 void operator()() {
+ test<T>();
+#if TEST_STD_VER >= 23
+ static_assert(test<T>());
+#endif
+ }
+};
+
+int main(int, char**) {
+ meta::for_each(meta::floating_point_types(), TestFloat());
+ meta::for_each(meta::integral_types(), TestInt());
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// bool isfinite(floating-point-type x); // constexpr since C++23
+
+// We don't control the implementation on windows
+// UNSUPPORTED: windows
+
+#include <cassert>
+#include <cmath>
+#include <limits>
+
+#include "test_macros.h"
+#include "type_algorithms.h"
+
+struct TestFloat {
+ template <class T>
+ static TEST_CONSTEXPR_CXX23 bool test() {
+ assert(std::isnormal(std::numeric_limits<T>::max()));
+ assert(!std::isnormal(std::numeric_limits<T>::infinity()));
+ assert(std::isnormal(std::numeric_limits<T>::min()));
+ assert(!std::isnormal(std::numeric_limits<T>::denorm_min()));
+ assert(std::isnormal(std::numeric_limits<T>::lowest()));
+ assert(!std::isnormal(-std::numeric_limits<T>::infinity()));
+ assert(!std::isnormal(T(0)));
+ assert(!std::isnormal(std::numeric_limits<T>::quiet_NaN()));
+ assert(!std::isnormal(std::numeric_limits<T>::signaling_NaN()));
+
+ return true;
+ }
+
+ template <class T>
+ TEST_CONSTEXPR_CXX23 void operator()() {
+ test<T>();
+#if TEST_STD_VER >= 23
+ static_assert(test<T>());
+#endif
+ }
+};
+
+struct TestInt {
+ template <class T>
+ static TEST_CONSTEXPR_CXX23 bool test() {
+ assert(std::isnormal(std::numeric_limits<T>::max()));
+ assert(std::isnormal(std::numeric_limits<T>::lowest()) == std::is_signed<T>::value);
+ assert(!std::isnormal(T(0)));
+
+ return true;
+ }
+
+ template <class T>
+ TEST_CONSTEXPR_CXX23 void operator()() {
+ test<T>();
+#if TEST_STD_VER >= 23
+ static_assert(test<T>());
+#endif
+ }
+};
+
+int main(int, char**) {
+ meta::for_each(meta::floating_point_types(), TestFloat());
+ meta::for_each(meta::integral_types(), TestInt());
+
+ return 0;
+}