[libcxx-commits] [libcxx] [libc++] Optimize ranges::{for_each, for_each_n} for segmented iterators (PR #132896)

Peng Liu via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 27 08:06:15 PDT 2025


================
@@ -20,7 +20,6 @@ algorithm iterator
 algorithm limits
 algorithm memory
 algorithm new
-algorithm optional
----------------
winner245 wrote:

Thank you for the feedback! Just to clarify: does this mean I should instead add `#include <optional>` under `#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20` at the bottom of `<algorithm>` and the other affected headers (`<array>`, `<bitset>`, `<ios>`, `<locale>`, etc.) to allow transitive inclusion of `<optional>`?

Also, one thing I don't quite understand: since `<optional>` is a C++17 utility, I’m curious why it’s needed as a transitive include in C++03, C++11, and C++14. Is this due to an implementation detail in `libc++` for compatibility?

https://github.com/llvm/llvm-project/pull/132896


More information about the libcxx-commits mailing list