FastArduino  v1.8
C++ library to build fast but small Arduino/AVR projects
streams::null_ostream Class Reference

Implements an empty formatted output that does nothing. More...

#include <fastarduino/empty_streams.h>

Detailed Description

Implements an empty formatted output that does nothing.

It can be used everywhere a streams::ostream is expected but produces no code at all. The following example shows how to add traces that can be disabled at compile time by defining a specific macro:

// Include the right header
#ifdef NO_TRACE
// Instantiate the right output
#ifdef NO_TRACE
// We use UART for tracing
static char output_buffer[64];
auto trace = uatx.out();
// Directly use trace anywhere, this won't generate any code if `NO_TRACE`
// was defined at compile time
void f(int value)
//... do something
trace << F("DEBUG") << value << streams::endl;
//... do something else

Definition at line 69 of file empty_streams.h.

The documentation for this class was generated from the following file:
Empty version of streams API, useful when you want to introduce traces that you can easily disable wi...
C++-like std::iostream facilities.
Hardware serial transmitter API.
Definition: uart.h:241
void endl(FSTREAM &stream)
Manipulator for an output stream, which will insert a new-line character and flush the stream buffer.
Definition: streams.h:722
Implements an empty formatted output that does nothing.
Definition: empty_streams.h:70
#define F(ptr)
Force string constant to be stored as flash storage.
Definition: flash.h:118