Branching from P0829R4. This "omnibus" paper is still the direction I am aiming for. However, it is too difficult to review. It needs to change with almost every meeting. Therefore, it is getting split up into smaller, more manageable chunks.
Limiting paper to the [utilities], [ranges], and [iterators] clauses.
This paper proposes adding many of the facilities in the [utilities], [ranges], and [iterators] clause to the freestanding subset of C++. The paper will only be adding complete entities, and will not tackle partial classes. In other words, classes like
tuple are being added, but trickier classes like
bitset will come in another paper.
<memory> header has a dependency on facilities in
<iterator>, so those headers (and clauses) are addressed as well.
Many existing facilities in the C++ standard library could be used without trouble in freestanding environments. This series of papers will specify the maximal subset of the C++ standard library that does not require an OS or space overhead.
For a more in depth rationale, see P0829.
<bitset> are not in this paper, as all have non-essential functions that can throw an exception.
<charconv> is not in this paper as it will require us to deal with the thorny issue of overload sets involving floating point and non-floating point types. I plan on addressing all four of these headers in later papers, so that the topics in question can be debated in relative isolation.
Modifying an overload set needs to be treated with great care. Ideally, libraries built in freestanding environments will have the same semantics (including selected overloads) when built in a hosted environment. I don't think that goal is 100% achievable, as sufficiently clever programmers will be able to detect the difference and modify behavior accordingly.
My approach will be to avoid splitting overload sets that could cause accidental freestanding / hosted differences. In future papers, I may need to lean on
= delete techniques to avoid silent behavior changes, but this paper hasn't needed that approach.
unique_ptr overloads, but this paper only marks the
unique_ptr overload as freestanding.
<memory> has many algorithms with
ExecutionPolicy overloads. This paper does not mark the
ExectuionPolicy overloads as freestanding. I was unable to come up with any compelling "accidental" way to select one
swap or algorithm overload in freestanding, but a different one in hosted.
Also note that the
swap overload set visible to a given translation unit is already indeterminate. A user may include
<memory> which guarantees the smart pointer overloads, but an implementation could expose any (or none!) of the other
swap overloads from other STL headers.
The following functions and classes rely on dynamic memory allocation and exceptions:
The following classes rely on iostreams facilities. iostreams facilities use dynamic memory allocations and rely on the operating system.
The ExecutionPolicy overloads of algorithms are of minimal utility on systems that do not support C++ threads.
The following, existing feature test macros cover some features that I am making freestanding, and some features that I am not requiring to be freestanding. These feature test macros won't be required in freestanding, as they could cause substantial confusion when the hosted parts of those features aren't available.
The entirety of the following headers are included:
ExecutionPolicyoverloads. This includes the algorithms in the
allocatorand associated comparisons
ExecutionPolicyoverloads in [specialized.algorithms]
<functional>as freestanding except for the following entities:
<iterator>as freestanding except for the following entities:
istream_iteratorand associated comparison operators
istreambuf_iteratorand associated comparison operators
Thanks to Brandon Streiff, Joshua Cannon, Phil Hindman, and Irwan Djajadi for reviewing P0829.
Thanks to Odin Holmes for providing feedback and helping publicize P0829.
Thanks to Paul Bendixen for providing feedback while prototyping P0829.
Similar work was done in the C++11 timeframe by Lawrence Crowl and Alberto Ganesh Barbati in N3256.