Dv::iomanip< T > Struct Template Reference

Convert typical member functions to iomanip objects that can be put on a stream using the conventional operator<<. More...

#include <iomanip.h>

List of all members.

Public Types

typedef basetype< T >::base BT
typedef std::ostream &(* Print )(std::ostream &, const BT &)

Public Member Functions

 iomanip (Print f, const BT &t)

Public Attributes

Print print_
const BTt_

Detailed Description

template<typename T>
struct Dv::iomanip< T >

Convert typical member functions to iomanip objects that can be put on a stream using the conventional operator<<.

This is the version that uses a static intermediate function. Typical usage example:

 struct C {
   virtual std::ostream print_summary(std::ostream& os) const {
     ..
   }

   static std::ostream print_summary(std::ostream& os, const C& c) {
     return c.print_summary(os);
   }

   Dv::iomanip<C> summary() const { 
     return Dv::iomanip<C>(print_summary, *this);
   }
 };
 
 C c;
 std::cout << "foobar: " << c.summary() << std::endl;

The above also works when subclassing, unlike the approach that directly uses a member function.

 struct D: public C {
   virtual std::ostream print_summary(std::ostream& os) const {
     ..
   }
 };

 D d;
 // use D's own print_summary
 std::cout << "foobar: " << d.summary() << std::endl;
See also:
Dv::iomanip_m

Definition at line 50 of file iomanip.h.


Member Typedef Documentation

template<typename T>
typedef basetype<T>::base Dv::iomanip< T >::BT

Definition at line 51 of file iomanip.h.

template<typename T>
typedef std::ostream&(* Dv::iomanip< T >::Print)(std::ostream &, const BT &)

Definition at line 52 of file iomanip.h.


Constructor & Destructor Documentation

template<typename T>
Dv::iomanip< T >::iomanip ( Print  f,
const BT t 
) [inline]

Definition at line 53 of file iomanip.h.


Member Data Documentation

template<typename T>
Print Dv::iomanip< T >::print_

Definition at line 54 of file iomanip.h.

template<typename T>
const BT& Dv::iomanip< T >::t_

Definition at line 55 of file iomanip.h.


The documentation for this struct was generated from the following file:

dvutil-1.0.10 [ 5 December, 2009]