CGAL 5.4 - IO Streams
CGAL::Output_rep< T, F > Class Template Reference

#include <CGAL/IO/io.h>

Inherits from

CGAL::IO_rep_is_not_specialized_aux< Dummy >.

Definition

template<class T, class F = ::CGAL::Null_tag>
class CGAL::Output_rep< T, F >

The purpose of Output_rep is to provide a way to control output formatting that works independently of the object's stream output operator.

If you dont specialize Output_rep for T, T's stream output operator is called from within Output_rep, by default. If you want another behaviour for your type T, you have to provide a specialization for that type. Furthermore, you can provide specializations with a second template parameter (a formatting tag). The second template parameter defaults to Null_tag and means default behaviour.

Specializations of Output_rep should provide the following features:

template< class F >
struct Output_rep< Some_type, F > {
static const bool is_specialized = true;
Output_rep( const Some_type& t );
std::ostream& operator()( std::ostream& os ) const;
};

You can also specialize for a formatting tag F.

The constant is_specialized can be tested by meta-programming tools to verify that a given type can be used with oformat(). Its value has to be true in a specialization of Output_rep. When there is no specialization for a type, the class template Output_rep defines is_specialized to the default value false.

Public Member Functions

 Output_rep (const T &tt)
 initialize with a const reference to t.
 
std::ostream & operator() (std::ostream &os) const
 perform the output, calls operator<< by default.
 

Related Functions

(Note that these are not member functions.)

template<class T , class F >
std::ostream & operator<< (std::ostream &os, Output_rep< T, F > rep)
 stream output of the Output_rep calls its operator(). More...
 

Friends And Related Function Documentation

◆ operator<
template<class T , class F >
std::ostream & operator<< ( std::ostream &  os,
Output_rep< T, F >  rep 
)
related

stream output of the Output_rep calls its operator().

CGAL defines output operators for classes that are derived from the class ostream. This enables to write to ostreams as cout or cerr, as well as to std::ostringstream and std::ofstream. The output operator is defined for all classes in the CGAL Kernel and for the class Color as well.