LatNet Builder Manual  2.0.1-11
Software Package for Constructing Highly Uniform Point Sets
LatBuilder::TextStream Namespace Reference

Overloaded stream operators. More...

Functions

template<typename T >
std::enable_if< detail::has_const_iterator< T >::value and !detail::is_ostreamable< T >::value, std::ostream & >::type operator<< (std::ostream &os, const T &x)
 Overload of the output stream operator for sequences. More...
 
template<typename T >
std::enable_if< detail::is_pair< T >::value, std::ostream & >::type operator<< (std::ostream &os, const T &x)
 Overload of the output stream operator for pair.
 

Detailed Description

Overloaded stream operators.

Provides stream operators for all classes that define a const_iterator type, such as STL containers.

To bring the operators defined in TextStream in the current scope, simply use:

using TextStream::operator<<;

If the preprocessor macro TEXTSTREAM_DISPLAY_COUNT is defined, the number of elements printed to the stream is appended to the output. For example, without defining that macro, the following code:

using TextStream::operator<<;
std::cout << std::vector<int>{1, 2, 3, 4, 5} << std::endl;

outputs:

[1, 2, 3, 4, 5]

whereas it ouputs:

[1, 2, 3, 4, 5]/5

when TEXTSTREAM_DISPLAY_COUNT is defined (before including TextStream.h).

Function Documentation

◆ operator<<()

template<typename T >
std::enable_if< detail::has_const_iterator< T >::value and !detail::is_ostreamable< T >::value, std::ostream & >::type LatBuilder::TextStream::operator<< ( std::ostream &  os,
const T &  x 
)

Overload of the output stream operator for sequences.

This operator can be applied an instance of a class that defines a const_iterator type, assuming that the members begin() and end() are also defined. If the class defines a key_type type, curly brackets are used as delimitors; otherwise, square brackets are used.