Skip to content

Commit 73ef006

Browse files
jwnimmer-trijbeder
authored andcommitted
Avoid including <iostream> in library code
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>.
1 parent 7470c2d commit 73ef006

File tree

5 files changed

+4
-5
lines changed

5 files changed

+4
-5
lines changed

src/indentation.h

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#pragma once
88
#endif
99

10-
#include <iostream>
1110
#include <cstddef>
1211

1312
#include "yaml-cpp/ostream_wrapper.h"

src/ostream_wrapper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <algorithm>
44
#include <cstring>
5-
#include <iostream>
5+
#include <ostream>
66

77
namespace YAML {
88
ostream_wrapper::ostream_wrapper()

src/stream.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <iostream>
1+
#include <istream>
22

33
#include "stream.h"
44

src/stream.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <cstddef>
1212
#include <deque>
1313
#include <ios>
14-
#include <iostream>
14+
#include <istream>
1515
#include <set>
1616
#include <string>
1717

src/token.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#endif
99

1010
#include "yaml-cpp/mark.h"
11-
#include <iostream>
11+
#include <ostream>
1212
#include <string>
1313
#include <vector>
1414

0 commit comments

Comments
 (0)