Skip to content

[libc++][test][NFC] Remove unused inclusions of <iostream> #134776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
// const_reverse_iterator crend() const noexcept;

#include <cassert>
#include <cstddef>
#include <deque>
#include <flat_map>
#include <functional>
#include <vector>

#include <iterator>

#include "test_macros.h"
#include <iostream>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The <vector> and <iterator> includes above seem to be unused as well. Probably also the case in the other tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somehow tricky. These files don't explicitly write vector but implicitly use vector<T> as default template arguments. Likewise, the reverse iterator types are reverse_iterator specializations, which are guaranteed to be provided in <iterator>.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to provide these things though <flat_map>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I found that these files use std::distance, which is only guaranteed to be available in <iterator> and <ranges>, although transitively introduced by several headers in libc++.

I think we should either keep includes of <iterator> or replace these std::distance calls with operator-.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When they're used we can keep them.


int main(int, char**) {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@
// const_reverse_iterator crend() const noexcept;

#include <cassert>
#include <cstddef>
#include <deque>
#include <flat_map>
#include <functional>
#include <vector>

#include <iterator>

#include "test_macros.h"
#include <iostream>

int main(int, char**) {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
// const_reverse_iterator crend() const noexcept;

#include <cassert>
#include <cstddef>
#include <deque>
#include <flat_set>
#include <functional>
#include <vector>

#include <iterator>

#include "test_macros.h"
#include <iostream>

void test() {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
// const_reverse_iterator crend() const noexcept;

#include <cassert>
#include <cstddef>
#include <deque>
#include <flat_set>
#include <functional>
#include <vector>

#include <iterator>

#include "test_macros.h"
#include <iostream>

void test() {
{
Expand Down