[libcxx-commits] [PATCH] D101098: [libcxx][docs] Add section for header layout and guidlines.

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 22 13:34:00 PDT 2021


zoecarver added inline comments.


================
Comment at: libcxx/docs/Contributing.rst:75-78
+* All sub-headers should be included by their parent header. To use the example above,
+  it is imperative that ``<ranges>`` includes the sub-header ``__ranges/size.h``. Or, to use
+  another example, ``<iterator>`` must include ``__iterator/iterator_traits.h``, even if it
+  doesn't use ``iterator_traits`` itself.
----------------
Quuxplusone wrote:
> Someone likes the word "imperative" lately. :)
> I suggest: All libc++ headers, both public and helper headers, should "Include What You Use." You should never rely on some other header to transitively include something that you need. If your header needs a definition of `iterator_traits`, then you should either `#include <iterator>` (exactly as user code does), or, to improve compile speed, `#include <__iterator/iterator_traits.h>`. You should never expect `iterator_traits` to be "pulled in" by any other header.
> User code, on the other hand, should never `#include` any of these helper headers directly; they are intended as unstable implementation details of libc++.
> Someone likes the word "imperative" lately. :)

:) sometimes I like a word and it gets stuck in my mind so I use it frequently.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101098/new/

https://reviews.llvm.org/D101098



More information about the libcxx-commits mailing list