Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

basics/outputOperator.hh
Go to the documentation of this file.
00001 /* output operator for all classes in concepts
00002  */
00003 
00004 #ifndef OutputOperator_h
00005 #define OutputOperator_h
00006 
00007 #include <iostream>
00008 #include <memory>
00009 
00010 namespace concepts {
00011 
00012   // ******************************************************** OutputOperator **
00013 
00037   class OutputOperator {
00038     friend std::ostream& operator<<(std::ostream& os, const OutputOperator& o);
00039   public:
00040     virtual ~OutputOperator();
00041   protected:
00043     virtual std::ostream& info(std::ostream& os) const;
00044   };
00045 
00046   // *********************************** Output operator for a std::auto_ptr<> **
00047 
00048   template<class F>
00049   std::ostream& operator<<(std::ostream& os, const std::auto_ptr<F>& p) {
00050     if (p.get()) return os << "&" << *p;  // pointer to value
00051     return os << "0";
00052   }
00053 
00054 } // namespace concepts
00055 
00056 
00057   // *************************************** Output operator for a std::pair<> **
00058 
00059   template<class F, class G>
00060   std::ostream& operator<<(std::ostream& os, const std::pair<F,G>& p) {
00061     return os << "std::pair(" << p.first << ", " << p.second << ")";
00062   }
00063 
00064 namespace concepts {
00065 
00066   template<class F, class G>
00067   std::ostream& operator<<(std::ostream& os, const std::pair<F,G>& p) {
00068     return os << "std::pair(" << p.first << ", " << p.second << ")";
00069   }
00070 
00071 }
00072 
00073 #endif // OutputOperator_h

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)