P1467R9 Extended Floating-Point Types (#3583)

This commit is contained in:
Stephan T. Lavavej 2023-03-23 18:42:40 -07:00 коммит произвёл GitHub
Родитель 581b4f089c
Коммит c353b688ac
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 58 добавлений и 0 удалений

Просмотреть файл

@ -201,6 +201,7 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/inc/stack
${CMAKE_CURRENT_LIST_DIR}/inc/stacktrace
${CMAKE_CURRENT_LIST_DIR}/inc/stdexcept
${CMAKE_CURRENT_LIST_DIR}/inc/stdfloat
${CMAKE_CURRENT_LIST_DIR}/inc/stop_token
${CMAKE_CURRENT_LIST_DIR}/inc/streambuf
${CMAKE_CURRENT_LIST_DIR}/inc/string

Просмотреть файл

@ -49,6 +49,7 @@
#include <numbers>
#include <ratio>
#include <source_location>
#include <stdfloat>
#include <tuple>
#include <type_traits>
#include <utility>

Просмотреть файл

@ -107,6 +107,7 @@
"stack",
"stacktrace",
"stdexcept",
"stdfloat",
"stop_token",
"streambuf",
"string",

36
stl/inc/stdfloat Normal file
Просмотреть файл

@ -0,0 +1,36 @@
// stdfloat standard header (core)
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#pragma once
#ifndef _STDFLOAT_
#define _STDFLOAT_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#if !_HAS_CXX23
_EMIT_STL_WARNING(STL4038, "The contents of <stdfloat> are available only with C++23 or later.");
#else // ^^^ !_HAS_CXX23 / _HAS_CXX23 vvv
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
// We don't support any optional extended floating-point types, but we do need to provide an empty `namespace std`.
// We don't need to `export` it for modules, as the other headers will implicitly do so (N4928 [module.interface]/2.1).
_STD_BEGIN
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // ^^^ _HAS_CXX23 ^^^
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _STDFLOAT_

Просмотреть файл

@ -319,6 +319,8 @@
// P1272R4 byteswap()
// P1328R1 constexpr type_info::operator==()
// P1425R4 Iterator Pair Constructors For stack And queue
// P1467R9 Extended Floating-Point Types
// (only the <stdfloat> header; we don't support any optional extended floating-point types)
// P1659R3 ranges::starts_with, ranges::ends_with
// P1679R3 contains() For basic_string/basic_string_view
// P1682R3 to_underlying() For Enumerations

Просмотреть файл

@ -101,6 +101,7 @@ export module std;
#include <stack>
#include <stacktrace>
#include <stdexcept>
#include <stdfloat>
#include <stop_token>
#include <streambuf>
#include <string>

Просмотреть файл

@ -782,6 +782,12 @@ void test_stdexcept() {
assert(caught_puppies);
}
void test_stdfloat() {
using namespace std;
puts("Testing <stdfloat>.");
// `namespace std` is available, so we're done.
}
void test_stop_token() {
using namespace std;
puts("Testing <stop_token>.");
@ -1120,6 +1126,7 @@ void all_cpp_header_tests() {
test_stack();
test_stacktrace();
test_stdexcept();
test_stdfloat();
test_stop_token();
test_streambuf();
test_string();

Просмотреть файл

@ -292,4 +292,10 @@ int main() {
assert((proj(-inf) == complex<double>{inf, 0.0}));
test_gh_2728();
// Also test N4928 [complex.numbers.general]/2:
// "Specializations of complex for cv-unqualified floating-point types are trivially-copyable literal types"
STATIC_ASSERT(is_trivially_copyable_v<complex<float>>);
STATIC_ASSERT(is_trivially_copyable_v<complex<double>>);
STATIC_ASSERT(is_trivially_copyable_v<complex<long double>>);
}

Просмотреть файл

@ -65,6 +65,7 @@
"stack",
"stacktrace",
"stdexcept",
"stdfloat",
"stop_token",
"streambuf",
"string",

Просмотреть файл

@ -71,6 +71,7 @@ import <sstream>;
import <stack>;
import <stacktrace>;
import <stdexcept>;
import <stdfloat>;
import <stop_token>;
import <streambuf>;
import <string>;

Просмотреть файл

@ -70,6 +70,7 @@ PM_CL="/DMEOW_HEADER=stack"
PM_CL="/DMEOW_HEADER=stacktrace"
PM_CL="/DMEOW_HEADER=stdatomic.h"
PM_CL="/DMEOW_HEADER=stdexcept"
PM_CL="/DMEOW_HEADER=stdfloat"
PM_CL="/DMEOW_HEADER=stop_token"
PM_CL="/DMEOW_HEADER=streambuf"
PM_CL="/DMEOW_HEADER=string"