Breath
Functions
breath Namespace Reference

A convenience source file to separate out the crazy #includes required for using EOF or char_traits<...>::eof(): More...

Functions

template<typename Stream >
Stream::int_type eof_value (Stream const &)
 
template<typename Stream >
bool is_eof_value (typename Stream::int_type x, Stream const &)
 

Detailed Description

A convenience source file to separate out the crazy #includes required for using EOF or char_traits<...>::eof():

  1. the former would require including <stdio.h> or <cstdio>
  2. the latter would require <string>

Both choices are IMHO particularly annoying for maintenance and code review: any reader of the code would probably wonder, for (1), why you include <cstdio> if you are using C++ streams (and not stdio); and, for (2), why you include <string> even where there's no usage of std::string.

The root of the issue is the poor header partitioning of the standard library but we can't do anything about that. We can, however, separate things out so that the relevant #includes are insulated. Which is the only real purpose of this facility.