STL

C++ Standard Template Library

Writing IEEE Floating-Point C++ Data as Decimal Text

Here are my notes on writing floating-point binary data as decimal strings, including within XML nodes. My concern is with IEEE 754-2008 Floating-Point binary values, and really only with the single- (C/C++ float) and double-precision (C/C++ double) forms, not the extended forms.

Avoiding Round-Off Errors in the Round Trip

Using std::copy for STL Container Output and Input

Here are a couple of concise constructs that come in handy when debugging C++ code involving STL containers.

Output

The following line of code prints the contents of an STL container cont whose value_type is T to the std::cout stream, where each element is separated by a space.

#include <algorithm>
#include <iterator>
#include <iostream>
 
std::copy(cont.begin(), cont.end(), std::ostream_iterator<T>(std::cout, " "));
Syndicate content