Unusual use of << operator… not a bit shift?

Poking through the example code of SDFS, I saw the following:

1
2
3
 static ArduinoOutStream cout(Serial);
// F stores strings in flash to save RAM
cout << F("\ntype any character to start\n");


What exactly is << doing in this case? Moreover, F seems to never be defined prior to this. This seems like a useful trick, but I don't understand how it works.
Note : https://myfedloan.us/
Last edited on
The formatted output operator.

C++ Standard Library has many for std::ostream:
http://www.cplusplus.com/doc/tutorial/basic_io/
http://www.cplusplus.com/reference/ostream/basic_ostream/operator%3C%3C/
http://www.cplusplus.com/reference/ostream/basic_ostream/operator-free/
http://www.cplusplus.com/reference/string/basic_string/operator%3C%3C/

Your "stream" is a ArduinoOutStream. Probably similar to std::ostream.


By syntax the F is either a function (that returns something), a class (who has custom constructor), or a macro.

The translation unit probably includes (directly or indirectly) a header that supplies the definition of F.
Last edited on
Topic archived. No new replies allowed.