better-enums/example/5-iostreams.cc
Anton Bachin faf3676fec Made it easier to generate offline documentation.
Documentation can be generated by going to doc/ and running "make".
This requires Python. Before this change, the user had to install the
mistune library, which is used by the generator. The mistune library is
now included in the Better Enums distribution.

The generated docs are available at doc/html/index.html. Note that some
links won't be local (the GitHub repo, the download link, outgoing
links to MSDN, tutorial source in the GitHub repo, and so on). All the
pages belonging to the actual docs will be local, however.

The online version of the docs can be generated by running "make web".
The only difference between the online and offline versions is that the
former includes Google Analytics tracking code, and may include social
communication buttons, comment section, or other useless things in the
future.

Also included errata since the last release.

Resolves #2.
2015-06-27 13:56:27 -05:00

31 lines
857 B
C++

// This file was generated automatically.
// Stream operators
//
// These work almost as you'd expect. First, make sure you include iostream
// before enum.h in any translation unit in which you intend to use the
// operators:
#include <iostream>
#include <enum.h>
ENUM(Channel, int, Red, Green, Blue)
int main()
{
std::cout << +Channel::Red << std::endl;
return 0;
}
// The thing to watch for is the +: without it, Channel::Red is a value of type
// Channel::_enumerated, a C++98 enum type, so writing that to cout will output
// an integer. +Channel::Red, however, is a value of type Channel, and writing
// that instead will output the string "Red".
//
// Input is also supported:
//
// Channel channel = Channel::Blue;
// std::cin >> channel; // Expects input such as "Green".
// Only char streams are supported for the time being.