Skip to content

Commit 4fa2006

Browse files
committed
Update documentation per discussion
1 parent 08e02bc commit 4fa2006

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

libcxx/docs/DesignDocs/HeaderRemovalPolicy.rst

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ to port headers to platforms with reduced functionality.
2222

2323
A disadvantage is that users unknowingly depend on these transitive includes.
2424
Thus removing an include might break their build after upgrading a newer
25-
version of libc++. For example, ``<algorithm>`` is often forgotten but using
26-
algorithms will still work through those transitive includes. This problem is
27-
solved by modules, however in practice most people do not use modules (yet).
25+
version of libc++ by reducing the set of declarations provided by a header.
26+
For example, ``<algorithm>`` is often forgotten but using algorithms will
27+
still work through those transitive includes. This problem is solved by modules,
28+
however in practice most people do not use modules (yet).
2829

2930
To ease the removal of transitive includes in libc++, libc++ will remove
3031
unnecessary transitive includes in newly supported C++ versions. This means
@@ -33,8 +34,11 @@ newer version of the Standard. Libc++ also reserves the right to remove
3334
transitive includes at any other time, however new language versions will be
3435
used as a convenient way to perform bulk removals of transitive includes.
3536

36-
For libc++ developers, this means that any transitive include removal must be
37-
guarded by something of the form:
37+
However, libc++ intends not to gratuitously break users on stable versions of
38+
the Standard. Hence, we intend to maintain backwards compatibility of the
39+
declarations we provide in a header, within reason. For libc++ developers, this
40+
means that any transitive include removal of a public header must be guarded by
41+
something of the form:
3842

3943
.. code-block:: cpp
4044
@@ -44,13 +48,17 @@ guarded by something of the form:
4448
# include <utility>
4549
#endif
4650
47-
When users define ``_LIBCPP_REMOVE_TRANSITIVE_INCLUDES``, libc++ will not
48-
include transitive headers, regardless of the language version. This can be
49-
useful for users to aid the transition to a newer language version, or by users
50-
who simply want to make sure they include what they use in their code.
51+
Occasionally, private headers may also be included transitively for backwards
52+
compatibility in the same manner.
5153

52-
We currently provide transitive inclusions for backwards compatibility in all
53-
Standard modes older than C++26.
54+
When users define ``_LIBCPP_REMOVE_TRANSITIVE_INCLUDES``, libc++ will not include
55+
transitive headers, regardless of the language version. This can be useful for users
56+
to aid the transition to a newer language version, or by users who simply want to
57+
make sure they include what they use in their code.
58+
59+
We currently strive to provide backwards compatibility on the set of declarations
60+
provided by a header in all Standard modes starting with C++23. Note that this is
61+
very difficult to actually enforce, so this is done only on a best effort basis.
5462

5563

5664
Rationale

0 commit comments

Comments
 (0)