Skip to content

Commit b2714f8

Browse files
committed
FMT_NO_STREAM_LIBRARIES -> FMT_USE_IOSTREAMS
for consistency with similar macros and removed unnecessary checks.
1 parent 6049fd9 commit b2714f8

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

format.cc

-2
Original file line numberDiff line numberDiff line change
@@ -1252,13 +1252,11 @@ FMT_FUNC void fmt::print(CStringRef format_str, ArgList args) {
12521252
print(stdout, format_str, args);
12531253
}
12541254

1255-
#ifndef FMT_NO_STREAM_LIBRARIES
12561255
FMT_FUNC void fmt::print(std::ostream &os, CStringRef format_str, ArgList args) {
12571256
MemoryWriter w;
12581257
w.write(format_str, args);
12591258
os.write(w.data(), w.size());
12601259
}
1261-
#endif
12621260

12631261
FMT_FUNC void fmt::print_colored(Color c, CStringRef format, ArgList args) {
12641262
char escape[] = "\x1b[30m";

format.h

+20-20
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
#include <string>
4141
#include <map>
4242

43-
#ifndef FMT_NO_STREAM_LIBRARIES
43+
#ifndef FMT_USE_IOSTREAMS
44+
# define FMT_USE_IOSTREAMS 1
45+
#endif
46+
47+
#if FMT_USE_IOSTREAMS
4448
# include <sstream>
4549
#endif
4650

@@ -2688,20 +2692,6 @@ void print(std::FILE *f, CStringRef format_str, ArgList args);
26882692
*/
26892693
void print(CStringRef format_str, ArgList args);
26902694

2691-
2692-
#ifndef FMT_NO_STREAM_LIBRARIES
2693-
/**
2694-
\rst
2695-
Prints formatted data to the stream *os*.
2696-
2697-
**Example**::
2698-
2699-
print(cerr, "Don't {}!", "panic");
2700-
\endrst
2701-
*/
2702-
void print(std::ostream &os, CStringRef format_str, ArgList args);
2703-
#endif
2704-
27052695
template <typename Char>
27062696
void printf(BasicWriter<Char> &w, BasicCStringRef<Char> format, ArgList args) {
27072697
internal::PrintfFormatter<Char>(args).format(w, format);
@@ -3014,16 +3004,26 @@ FMT_VARIADIC_W(std::wstring, format, WCStringRef)
30143004
FMT_VARIADIC(void, print, CStringRef)
30153005
FMT_VARIADIC(void, print, std::FILE *, CStringRef)
30163006

3017-
#ifndef FMT_NO_STREAM_LIBRARIES
3018-
FMT_VARIADIC(void, print, std::ostream &, CStringRef)
3019-
#endif
3020-
30213007
FMT_VARIADIC(void, print_colored, Color, CStringRef)
30223008
FMT_VARIADIC(std::string, sprintf, CStringRef)
30233009
FMT_VARIADIC_W(std::wstring, sprintf, WCStringRef)
30243010
FMT_VARIADIC(int, printf, CStringRef)
30253011
FMT_VARIADIC(int, fprintf, std::FILE *, CStringRef)
3026-
}
3012+
3013+
#if FMT_USE_IOSTREAMS
3014+
/**
3015+
\rst
3016+
Prints formatted data to the stream *os*.
3017+
3018+
**Example**::
3019+
3020+
print(cerr, "Don't {}!", "panic");
3021+
\endrst
3022+
*/
3023+
void print(std::ostream &os, CStringRef format_str, ArgList args);
3024+
FMT_VARIADIC(void, print, std::ostream &, CStringRef)
3025+
#endif
3026+
} // namespace fmt
30273027

30283028
#if FMT_USE_USER_DEFINED_LITERALS
30293029
namespace fmt {

test/format-test.cc

-2
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,6 @@ TEST(FormatIntTest, FormatDec) {
15391539
EXPECT_EQ("42", format_decimal(42ull));
15401540
}
15411541

1542-
#ifndef FMT_NO_STREAM_LIBRARIES
15431542
TEST(FormatTest, Print) {
15441543
#if FMT_USE_FILE_DESCRIPTORS
15451544
EXPECT_WRITE(stdout, fmt::print("Don't {}!", "panic"), "Don't panic!");
@@ -1550,7 +1549,6 @@ TEST(FormatTest, Print) {
15501549
fmt::print(os, "Don't {}!", "panic");
15511550
EXPECT_EQ("Don't panic!", os.str());
15521551
}
1553-
#endif
15541552

15551553
#if FMT_USE_FILE_DESCRIPTORS
15561554
TEST(FormatTest, PrintColored) {

0 commit comments

Comments
 (0)