Class documentation of Concepts

Loading...
Searching...
No Matches
outputOperator.hh
Go to the documentation of this file.
1
6#ifndef OutputOperator_h
7#define OutputOperator_h
8
9#include <iostream>
10#include <memory>
11#include <map>
12
13#include "output.hh"
14
15namespace concepts {
16
17 // ******************************************************** OutputOperator **
18
43 friend std::ostream& operator<<(std::ostream& os, const OutputOperator& o);
44 public:
45 virtual ~OutputOperator();
46 protected:
48 virtual std::ostream& info(std::ostream& os) const;
49 };
50
51 // *********************************** Output operator for a std::unique_ptr<> **
52
53 template<class F>
54 std::ostream& operator<<(std::ostream& os, const std::unique_ptr<F>& p) {
55 if (p.get()) return os << "&" << *p; // pointer to value
56 return os << "0";
57 }
58
59} // namespace concepts
60
61
62// *************************************** Output operator for a std::pair<> **
63
64template<class F, class G>
65std::ostream& operator<<(std::ostream& os, const std::pair<F,G>& p) {
66 return os << "std::pair(" << p.first << ", " << p.second << ")";
67}
68
69namespace concepts {
70
71 template<class F, class G>
72 std::ostream& operator<<(std::ostream& os, const std::pair<F,G>& p) {
73 return os << "std::pair(" << p.first << ", " << p.second << ")";
74 }
75
76 // ************************************** Output operator for a std::map<> **
77
78 template<class F, class G>
79 std::ostream& operator<<(std::ostream& os, const std::map<F,G*>& m) {
80 os << "std::map(";
81 typename std::map<F,G*>::const_iterator i = m.begin();
82 for(; i != m.end(); ++i)
83 os << std::endl << " ("
84 << i->first << "-> &"
85 << *i->second << ") ";
86 return os << ')';
87 }
88
89 template<class F, class G>
90 std::ostream& operator<<(std::ostream& os, const std::map<F,G>& m) {
91 os << "std::map(";
92 typename std::map<F,G>::const_iterator i = m.begin();
93 for(; i != m.end(); ++i)
94 os << std::endl << " ("
95 << i->first << " -> "
96 << i->second << ") ";
97 return os << ')';
98 }
99
100}
101
102#endif // OutputOperator_h
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320