Skip to content

Commit

Permalink
Avoid including <iostream> in library code
Browse files Browse the repository at this point in the history
Including iostream means introducing the static (global) constructors
and destructors for std::cin, std::cerr, and std::cout. That extra
init and fini code is undesirable when those streams are not actually
used.

Instead, we'll use the narrower includes for exactly what's needed,
i.e., <istream> or <ostream>.
  • Loading branch information
jwnimmer-tri authored and jbeder committed Dec 30, 2024
1 parent 7470c2d commit 73ef006
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/indentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#pragma once
#endif

#include <iostream>
#include <cstddef>

#include "yaml-cpp/ostream_wrapper.h"
Expand Down
2 changes: 1 addition & 1 deletion src/ostream_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <algorithm>
#include <cstring>
#include <iostream>
#include <ostream>

namespace YAML {
ostream_wrapper::ostream_wrapper()
Expand Down
2 changes: 1 addition & 1 deletion src/stream.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <iostream>
#include <istream>

#include "stream.h"

Expand Down
2 changes: 1 addition & 1 deletion src/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <cstddef>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <set>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion src/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#endif

#include "yaml-cpp/mark.h"
#include <iostream>
#include <ostream>
#include <string>
#include <vector>

Expand Down

0 comments on commit 73ef006

Please sign in to comment.