/[escript]/trunk/esys2/esysUtils/src/estream.cpp.hide
ViewVC logotype

Contents of /trunk/esys2/esysUtils/src/estream.cpp.hide

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (show annotations)
Tue Oct 26 06:53:54 2004 UTC (18 years, 5 months ago) by jgs
File size: 815 byte(s)
Initial revision

1 #include <iostream>
2 #include <sstream>
3 namespace {
4 char tmp = 'a';
5 };
6 class ErrStream
7 {
8 public:
9 template <typename Tmpl>
10 ErrStream operator<<(Tmpl t)
11 {
12 std::stringstream str;
13 str << t;
14 m_msg += str.str();
15
16 return *this;
17 }
18
19 const std::string &getMsg() const
20 {
21 return m_msg;
22 }
23
24 std::string m_msg;
25 };
26
27 std::ostream &operator<<(std::ostream &oStream, const ErrStream &errStream)
28 {
29 oStream << errStream.getMsg();
30 return oStream;
31 }
32
33 int main(int argc, char *argv[])
34 {
35 int tmp = 0;
36 {
37 char tmp = 'A';
38 std::stringstream tmpStr;
39 tmpStr << tmp;
40 std::cout << tmp << " " << (ErrStream() << "give out garbage" << tmp << "hi jimmy here is a float: " << 2.333).getMsg() << std::endl;
41 std::cout << tmpStr.str() << std::endl;
42 }
43
44 std::cout << tmp << std::endl;
45 }
46

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26