141 Commits

Author SHA1 Message Date
Hui
def50f701f
[libc++] implement std::flat_multimap (#113835)
fixes https://github.com/llvm/llvm-project/issues/105190

---------

Co-authored-by: Hui Xie <huixie@Mac.broadband>
Co-authored-by: Hui Xie <huixie@Huis-MacBook-Pro.local>
2025-01-25 18:30:00 +00:00
Jakub Mazurkiewicz
c91d805e66
[libc++] Implement std::not_fn<NTTP> (#86133)
Implement `std::not_fn<NTTP>` from "P2714R1 Bind front and back to NTTP callables".
2025-01-10 14:14:14 -05:00
A. Jiang
76b71c0bc4
[libc++] Set __cpp_lib_smart_ptr_for_overwrite (#114700)
The features were implemented in LLVM 16, but mistakenly considered
unimplemented in FTM tools.
2024-11-05 13:27:40 +08:00
A. Jiang
cae351f345
[libc++] Bump __cpp_lib_optional and __cpp_lib_variant (#113650)
In C++20 mode, `__cpp_lib_optional` and `__cpp_lib_variant` should be
`202106L` due to DR P2231R1.

In C++26 mode, `__cpp_lib_variant` should be bumped to `202306L` due to
P2637R3.
- Clang 16/17 shouldn't get this bumping (as member `visit` requires
explicit object parameters), but it's very tricky to make the bumping
conditionally enabled. I _hope_ unconditionally bumping in C++26 will be
OK for LLVM 20 when the support for Clang 17 is dropped.

Related PRs:
- https://reviews.llvm.org/D102119
- #83335
- #76447
2024-10-26 07:38:52 +08:00
Hristo Hristov
a06591b4d4
[libc++][type_traits] P2674R1: A trait for implicit lifetime types (#106870)
Implements P2674R1: https://wg21.link/P2674R1

- https://eel.is/c++draft/type.traits
  - https://eel.is/c++draft/meta.type.synop
  - https://eel.is/c++draft/meta.unary.prop
- https://eel.is/c++draft/support.limits
  - https://eel.is/c++draft/version.syn

Implementation details:
- Uses compiler intrinsic `__builtin_is_implicit_lifetime`:
  - https://github.com/llvm/llvm-project/pull/101807
- Tests based on:
-
d213981c80/clang/test/SemaCXX/type-traits.cpp (L1989)

References:
- Implicit-lifetime
- Implicit-lifetime types [basic.types.general]/9:
https://eel.is/c++draft/basic.types.general
- Implicit-lifetime class [class.prop]/9:
https://eel.is/c++draft/class.prop
- P0593R6 Implicit creation of objects for low-level object
manipulation: https://wg21.link/P0593R6
- P1010R1 Container support for implicit lifetime types:
https://wg21.link/P1010R1
- P0593R6 Implicit creation of objects for low-level object
manipulation: https://wg21.link/P0593R6

Closes: #105259

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-10-09 08:19:14 +02:00
A. Jiang
7808541fde
[libc++] P2747R2: constexpr placement new (library part) (#105768)
This patch implements https://wg21.link/P2747R2.

The library changes affect direct `operator new` and `operator new[]`
calls even when the core language changes are absent.

The changes are not available for MS ABI because the `operator new` and
`operator new[]` are from VCRuntime's `<vcruntime_new.h>`. A feature
request was submitted for that [1].

As a drive-by change, the patch reformatted the whole `new.pass.cpp` and
`new_array.pass.cpp` tests.

Closes #105427

[1]: https://developercommunity.visualstudio.com/t/constexpr-for-placement-operator-newope/10730304.
2024-08-28 09:35:57 -04:00
A. Jiang
026210e80d
[libc++][ranges] P2609R3: Relaxing Ranges Just A Smidge (#101715)
This patch implements https://wg21.link/p2609r3.
The test code was originally authored by JMazurkiewicz.

Notes:
- P2609R3 is not officially a Defect Report, but MSVC STL
  implements it in C++20 mode.

  Moreover, P2609R3 and P2997R1 touch exactly the same set of
  concepts, and MSVC STL and libc++ have already treated P2997R1
  as a DR.

- This patch also adjusted feature-test macros.
  + In C++20 mode, the value of __cpp_lib_ranges should be `202110L` because
    - `202202L` covers `range_adaptor_closure` (P2387R3), and
    - `202207L` covers move-only types in range adaptors (P2494R2).
  And all of these changes are only available since C++23 mode.

  + In C++23 mode, the value should be `202406L` because
    - `202211L` covers removing poison overloads (P2602R2),
    - `202302L` covers relaxing projected value types (P2609R3), and
    - `202406L` covers removing requirements on `iter_common_reference_t` (P2997R1).
  And all of these changes are already or being implemented.

Fixes #105253.

Co-authored-by: Jakub Mazurkiewicz <mazkuba3@gmail.com>
2024-08-28 08:55:44 -04:00
Louis Dionne
1c48c9cc43
[libc++] Implement P2985R0: std::is_virtual_base_of (#105847)
This trait is implemented in C++26 conditionally on the compiler
supporting the __builtin_is_virtual_base_of intrinsic. I believe only
tip-of-trunk Clang currently implements that builtin.

Closes #105432
2024-08-26 09:58:19 -04:00
Mark de Wever
3ce6f68ee7
[libc++][spaceship] Marks P1614 as complete. (#99375)
Implements parts of:
- P1902R1 Missing feature-test macros 2017-2019

Completes:
- P1614R2 The Mothership has Landed

Fixes #100018
2024-07-25 18:37:36 +02:00
nicole mazzuca
04760bfadb
[libc++][ranges] P1223R5: find_last (#99312)
Implements [P1223R5][] completely.

Includes an implementation of `find_last`, `find_last_if`, and
`find_last_if_not`.

[P1223R5]: https://wg21.link/p1223r5
2024-07-19 09:42:16 -07:00
Hristo Hristov
e475bb7ac3
[libc++][memory] P1132R8: out_ptr - a scalable output pointer abstraction (#73618)
Differential Revision: https://reviews.llvm.org/D150525

Implements:
- https://wg21.link/P1132R8 - `out_ptr` - a scalable output pointer
abstraction
- https://eel.is/c++draft/smartptr.adapt - 20.3.4 Smart pointer adaptors
- https://wg21.link/LWG3734 - Inconsistency in `inout_ptr` and `out_ptr`
for empty case
- https://wg21.link/LWG3897- `inout_ptr` will not update raw pointer to
0

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-07-19 06:38:02 +03:00
Hristo Hristov
4a19be5d45
[libc++][strings] P2591R5: Concatenation of strings and string views (#88389)
Implemented: https://wg21.link/P2591R5
- https://eel.is/c++draft/string.syn
- https://eel.is/c++draft/string.op.plus

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-07-18 13:26:37 +03:00
Xiaoyang Liu
4e338dce4d
[libc++] P2389R2: dextents Index Type Parameter (#97393)
This patch implements P2389R2, which was adopted at the St. Louis meeting.
It builds upon previous enhancements from P2299R3, which introduced deduction
guides and the `dextents` alias template.
2024-07-15 11:23:34 -04:00
Mark de Wever
deeb936863
[libc++][format] define __cpp_lib_format. (#98275)
In order to define the format __cpp_lib_format to its initial value
(201907) these papers need to be completed:
- P0645R10 Text Formatting
- P1652R1 Printf corner cases in std::format
- 1361R2 Integration of chrono with text formatting The first two have
been implemented for a while the latter is almost done.

The next value (202106) requires:
- P2216R3 std::format improvements which has been implemented

The next value (202110) requires:
- P2418R2 Add support for std::generator-like types to std::format
- P2372R3 Fixing locale handling in chrono formatters The first one has
been implemented for a while the latter is almost done. The latter paper
is a DR against 1361R2 and both are implemented at the same time.

We've had user feedback that the missing of the __cpp_lib_format makes
their lives harder (https://github.com/llvm/llvm-project/issues/77773).
The missing papers 1361R2 and P2372R3 are very close to completion and
might completed before LLVM-19, but it will be a close call. This has
been discussed in the monthly libc++ meeting and we decided to set the
__cpp_lib_format so it will be set in LLVM-19.

Based on the discussion and the implementation status the
__cpp_lib_format is set to 202110.

Fixes #77773
2024-07-10 17:52:43 +02:00
Louis Dionne
e42f760b65
[libc++] Define the __cpp_lib_atomic_ref feature test macro (#98081)
We forgot to enable it when we landed std::atomic_ref in 42ba740aff.
2024-07-09 11:08:29 -04:00
Mark de Wever
2dadf8d7f5
[libc++] Update status after the St. Louis meeting. (#97951)
This updates:
- The status tables
- Feature test macros
- New headers for modules
2024-07-08 19:35:31 +02:00
Mark de Wever
759fb590da
[libc++][modules] Mark as implemented. (#90091)
The feature has been implemented in LLVM 18 as an experimental feature.
This marks the paper as complete and sets the feature-test macro.

Implements
- P2465R3 Standard Library Modules std and std.compat

Fixes: https://github.com/llvm/llvm-project/issues/89579
2024-06-12 19:01:27 +02:00
Mark de Wever
c36961bd96
[libc++] Adds __cpp_lib_three_way_comparison FTM. (#91515)
The paper
  P0768R1 Library Support for the Spaceship (Comparison) Operator
did not add a feature-test macro. This omission has been corrected in
  P1353R0 Missing Feature Test Macros

This enables the FTM for P0768R1

Fixes: https://github.com/llvm/llvm-project/issues/73953

---------

Co-authored-by: S. B. Tam <cpplearner@outlook.com>
2024-06-12 18:59:21 +02:00
Stephan T. Lavavej
a4bef0ca82
[libc++] Mark P2845R8 __cpp_lib_format_path and P2587R3 __cpp_lib_to_string as C++26 (#93255)
[P2845R8](https://wg21.link/P2845R8) "Formatting of
`std::filesystem::path`" and [P2587R3](https://wg21.link/P2587R3)
"`to_string` or not `to_string`" are C++26 features, so they should be
marked accordingly in `generate_feature_test_macro_components.py`.

I verified that without my changes, running the script produced no
edits. Then with my changes, I ran the script to regenerate all files,
with no other manual edits.

Found while running libc++'s tests with MSVC's STL, which noticed this
because it's currently a C++23-only implementation.

Note that @H-G-Hristov has a draft implementation of P2587R3: #78100
2024-05-28 12:15:50 -07:00
Mital Ashok
8f711aa324
[libc++][test] __cpp_lib_within_lifetime -> __cpp_lib_is_within_lifetime (#91896)
The feature test macro was renamed when
[P2641R4](https://wg21.link/P2641R4) was adopted into the standard:
0facada4ca
https://wg21.link/version.syn#lib:__cpp_lib_is_constant_evaluated
2024-05-16 09:45:45 +02:00
Hristo Hristov
8afa6cf510
[libc++][functional] P2944R3 (partial): Comparisons for reference_wrapper (reference_wrapper operators only) (#88384)
Implements https://wg21.link/P2944R3 (partially)
Implements https://wg21.link/LWG4071 /
https://cplusplus.github.io/LWG/issue4071 (fixes build failures in the
test suite)
- https://eel.is/c++draft/refwrap.comparisons
2024-05-09 12:48:37 +03:00
krzysdz
028f1b0781
[libc++] Fix P1206R7 feature test macros (#90914)
- Add missing `__cpp_lib_containers_ranges` feature test macro
- Constrain `__cpp_lib_ranges_to_container` to the `<ranges>` header,
since the standard does not list it in containers' headers

Ref:
-
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1206r7.pdf#section.18
- https://eel.is/c++draft/support.limits#lib:__cpp_lib_containers_ranges
-
https://eel.is/c++draft/support.limits#lib:__cpp_lib_ranges_to_container
2024-05-04 18:23:49 +02:00
Jakub Mazurkiewicz
c8917048e3
[libc++] Implement bind_back (#81055)
Implement `std::bind_back` function from P2387R3 "Pipe support for
user-defined range adaptors".
2024-04-09 11:10:20 -04:00
Louis Dionne
b699a9ba11
[libc++] Update status page after the Tokyo meeting (#87395) 2024-04-03 08:21:11 -04:00
Hristo Hristov
80f9458cf3
[libc++][sstream] P2495R3: Interfacing stringstreams with string_view (#80552)
Implements P2495R3 <https://wg21.link/P2495R3>
- https://eel.is/c++draft/version.syn#headerref:%3csstream%3e
- https://eel.is/c++draft/stringbuf
- https://eel.is/c++draft/stringbuf.general
- https://eel.is/c++draft/stringbuf.cons
- https://eel.is/c++draft/stringbuf.members
- https://eel.is/c++draft/istringstream
- https://eel.is/c++draft/istringstream.general
- https://eel.is/c++draft/istringstream.cons
- https://eel.is/c++draft/istringstream.members
- https://eel.is/c++draft/ostringstream
- https://eel.is/c++draft/ostringstream.general
- https://eel.is/c++draft/ostringstream.cons
- https://eel.is/c++draft/ostringstream.members
- https://eel.is/c++draft/stringstream
- https://eel.is/c++draft/stringstream.general
- https://eel.is/c++draft/stringstream.cons
- https://eel.is/c++draft/stringstream.members

References:
- https://eel.is/c++draft/string.streams
2024-03-05 08:49:49 +02:00
ZijunZhaoCCK
7d7d4752a8
[libc++] Set feature test macros __cpp_lib_ranges_contains and__cpp_lib_ranges_starts_ends_with (#81816)
ranges::contains: fdd089b50063
ranges::starts_with: 205175578e0d
ranges::ends_with: 0218ea4aaa54

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-02-29 16:06:32 -08:00
Danny Mösch
00e80fbfb9
[NFC] Correct C++ standard names (#81421) 2024-02-11 19:43:34 +01:00
Hristo Hristov
7d78ccf7d5
[libc++][memory] P2652R2: Disallow Specialization of allocator_traits (#79978)
Implements P2652R2 <https://wg21.link/P2652R2>:
- https://eel.is/c++draft/allocator.requirements.general
- https://eel.is/c++draft/memory.syn
- https://eel.is/c++draft/allocator.traits.general
- https://eel.is/c++draft/allocator.traits.members
- https://eel.is/c++draft/diff.cpp20.concepts
- https://eel.is/c++draft/diff.cpp20.utilities

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-02-01 12:31:25 +01:00
Hristo Hristov
03c19e91e8
[libc++][numeric] P0543R3: Saturation arithmetic (#77967)
Implements: https://wg21.link/P0543R3
- https://eel.is/c++draft/numeric.sat

Additional references:
- Division: https://eel.is/c++draft/expr.mul#4
- Arithmetic conversions: https://eel.is/c++draft/expr.arith.conv#1
- Clang builtins:
https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions

Depends on: https://github.com/llvm/llvm-project/pull/78086

---------

Co-authored-by: Zingam <zingam@outlook.com>
Co-authored-by: Mark de Wever <zar-rpg@xs4all.nl>
2024-01-22 06:57:45 +02:00
Hristo Hristov
dbbeee6b83
[libc++][span] P2447R4: std::span over an initializer list (#78157)
Implements: https://wg21.link/P2447R6
- https://eel.is/c++draft/span.syn
- https://eel.is/c++draft/span.overview
- https://eel.is/c++draft/span.cons
- https://eel.is/c++draft/diff

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-20 06:09:46 +02:00
Hristo Hristov
92e243173c
Reapply "[libc++][streams] P1759R6: Native handles and file streams" (#77190)
Fixes build on Windows in C++26 mode.

Reverted in:
40c07b559a
Original PR: https://github.com/llvm/llvm-project/pull/76632

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-07 18:01:03 +02:00
Haowei Wu
40c07b559a Revert "[libc++][streams] P1759R6: Native handles and file streams (#76632)"
This reverts commit 255f95a40377677dd762df5a1aa65bcbb4f75c79, which
contains a breaking libcxx test on Windows when using C++26
2024-01-05 17:23:40 -08:00
Hristo Hristov
255f95a403
[libc++][streams] P1759R6: Native handles and file streams (#76632)
Implements: `P1759R6` https://wg21.link/P1759R6

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-05 11:42:08 +02:00
Hristo Hristov
a72ab9c14d
[libc++][span] P2821R5: span.at() (#74994)
- Implements: [P2821R5: span.at()](https://wg21.link/P2821R5)
  (https://eel.is/c++draft/views.contiguous#views.span)
- Cleaned up `span.operator[]` test

---------

Co-authored-by: Zingam <zingam@outlook.com>
2024-01-05 11:41:22 +02:00
Mark de Wever
2fd4084fca
[libc++][print] Adds ostream overloads. (#73262)
Finishes implementation of
- P2093R14 Formatted output
- P2539R4 Should the output of std::print to a terminal be synchronized
with the underlying stream?

Differential Revision: https://reviews.llvm.org/D156609
2023-12-19 19:32:17 +01:00
Mark de Wever
16b8c9608f
[libc++][format] Fixes formatting code units as integers. (#73396)
This paper was voted in as a DR, so it's retroactively enabled back to
C++20; the C++ version that introduced std::format.

Implements:
- P2909R4 Fix formatting of code units as integers (Dude, where’s my
``char``?)
2023-11-29 17:55:09 +01:00
PragmaTwice
a3f17ba3fe [libc++] Implement P2467R1: Support exclusive mode for fstreams
This patch brings std::ios_base::noreplace from P2467R1 to libc++.
This requires compiling the shared library in C++23 mode since otherwise
fstream::open(...) doesn't know about the new flag.

Differential Revision: https://reviews.llvm.org/D137640
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-11-17 17:27:30 -05:00
Mark de Wever
f49ccca86a
[libc++] Update status after the Kona meeting. (#72421)
This updates:
- The status tables
- Feature test macros (including previously missing ones)
- New headers for modules
2023-11-16 10:17:19 +01:00
Mark de Wever
7cc72a0a2e Implement syncstream (p0053)
This patch implements `std::basic_syncbuf` and `std::basic_osyncstream` as specified in paper p0053r7. ~~For ease of reviewing I am submitting this patch before submitting a patch for `std::basic_osyncstream`. ~~

~~Please note, this patch is not 100% complete. I plan on adding more tests (see comments), specifically I plan on adding tests for multithreading and synchronization.~~

Edit: I decided that it would be far easier for me to keep track of this and make changes that affect both `std::basic_syncbuf` and `std::basic_osyncstream` if both were in one patch.

The patch was originally written by @zoecarver

Implements
- P0053R7 - C++ Synchronized Buffered Ostream
- LWG-3127 basic_osyncstream::rdbuf needs a const_cast
- LWG-3334 basic_osyncstream move assignment and destruction calls basic_syncbuf::emit() twice
- LWG-3570 basic_osyncstream::emit should be an unformatted output function
- LWG-3867 Should std::basic_osyncstream's move assignment operator be noexcept?

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D67086
2023-11-08 17:45:06 +01:00
Christian Trott
639a0986f3
[libc++] mdspan - implement layout_stride (#69650)
This implements layout_stride for C++23 and with that completes the
implementation of the C++23 mdspan header. The feature test macro is
added, and the status pages updated.

Co-authored-by: Damien L-G <dalg24@gmail.com>

Differential Revision: https://reviews.llvm.org/D157171
2023-10-20 08:13:52 -06:00
Hui
4fa812bb52 [libc++] Implement std::condition_variable_any::wait[_for/until] overloads that take stop_token
- This is section 32.6.4 of P0660R10
- https://eel.is/c++draft/thread.condvarany.intwait

Differential Revision: https://reviews.llvm.org/D153441
2023-09-29 13:50:16 +01:00
Jakub Mazurkiewicz
065dc485bd [libc++][ranges] Implement P2443R1: views::chunk_by
This patch implements https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2443r1.html (`views::chunk_by`).

Reviewed By: #libc, var-const

Differential Revision: https://reviews.llvm.org/D144767
2023-09-05 16:19:49 -07:00
Mark de Wever
ea82a822d9 [libc++] Adds string_view constructor overload
Implements
- P2697R1 Interfacing bitset with string_view

Depends on D153192

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D153201
2023-08-25 17:56:27 +02:00
Mark de Wever
92ac360063 [libc++][charconv] Adds operator bool.
Implements
- P2497R0 Testing for success or failure of <charconv> functions

Depends on D153192

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D153199
2023-08-23 19:25:10 +02:00
varconst
c3648f37d0 [libc++][ranges] Implement ranges::to.
Differential Revision: https://reviews.llvm.org/D142335
2023-07-20 22:48:18 -07:00
yrong
a2160dd34d [libc++][ranges] Implement P2474R2(views::repeat).
- Implement https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2474r2.html
- Implement LWG3875(https://cplusplus.github.io/LWG/issue3875).

Depends on D151629

Reviewed By: #libc, Mordante, philnik, var-const

Differential Revision: https://reviews.llvm.org/D141699
2023-07-20 20:03:01 +08:00
Mark de Wever
3f65f71833 [libc++][print] Adds FILE functions.
Drive-by fix to make sure the __retarget_buffer works correctly whan
using a hint of 1. This was discovered in one of the new tests.

Drive-by fixes __retarget_buffer when initialized with size 1.

Implements parts of
- P2093R14 Formatted output
- P2539R4  Should the output of std::print to a terminal be
           synchronized with the underlying stream?

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D150044
2023-07-18 20:07:11 +02:00
yronglin
9f6439f1c5 [libc++][ranges] Implement P2494R2 (Relaxing range adaptors to allow for move only types)
Implement P2494R2 `Relaxing range adaptors to allow for move only types`

https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2494r2.html#wording-ftm

According to the words in P2494R2, I haven't add new test for `drop_while_view`, `take_while_view` and `filter_view`, because these views has the requirement that the predicate is an `indirect_unary_predicate`, which requires that the predicate is `copy_constructible`, so they still can't accept move only types as predicate.

```
[P2483R0] also suggests future work to relax the requirements on the predicate types stored by standard views. This paper does not perform this relaxation, as the copy constructibility requirement is enshrined in the indirect callable concepts ([indirectcallable.indirectinvocable]). Thus, while this paper modifies the views that currently use copyable-box for user provided predicates, it only does so to apply the rename of the exposition-only type to movable-box; it does not change any of the constraints on those views. It does, however, relax the requirements on invocables accepted by the transform family of views, because those are not constrained using the indirect callable concepts.
```

Reviewed By: #libc, var-const

Differential Revision: https://reviews.llvm.org/D151629
2023-06-25 08:15:52 +08:00
Mark de Wever
f805c799bf [libc++] "Implements" new SI prefixis.
Like yocto, zepto, zetta, and yotta. The new prefixes quecto, ronto,
ronna, and quetta can't be implemented in a intmax_t. So their
implementation does nothing.

Implements
- P2734R0 Adding the new SI prefixes

Depends on D153192

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153200
2023-06-19 17:04:35 +02:00
Mark de Wever
a4f0764aef [libc++] Marks __cpp_lib_bitops as implemented.
This FTM was introduced in
  P0553R4 Bit operations

Which has been implemented since libc++ 9.

This was noticed while working on D153192.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153225
2023-06-19 17:01:27 +02:00