[libcxx-commits] [libcxx] [libc++] Optimize ranges::{for_each, for_each_n} for segmented iterators (PR #132896)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Apr 2 08:18:39 PDT 2025
================
@@ -20,7 +20,6 @@ algorithm iterator
algorithm limits
algorithm memory
algorithm new
-algorithm optional
----------------
ldionne wrote:
> 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
Yes, exactly!
> 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?
That's a good observation. I don't think it's necessary to include the header in C++03 - 14, probably. But it would be in C++17 and C++20 for backwards compatibility.
https://github.com/llvm/llvm-project/pull/132896
More information about the libcxx-commits
mailing list