Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
27.basic.ios.copyfmt.stdcxx-766.cpp
Go to the documentation of this file.
1
29#include <cassert>
30#include <ios>
31#include <iosfwd>
32#include <locale>
33#include <ostream>
34
35
36int main ()
37{
38 struct sbuf : std::streambuf { } xsb, ysb;
39 std::ostream xstrm (0);
40 std::ostream ystrm (0);
41
42 std::ios x (&xsb);
43 std::ios y (&ysb);
44
45 x.tie (&xstrm);
46
47 const std::ios::iostate x_rdstate = x.rdstate ();
48 const std::streambuf* const x_rdbuf = x.rdbuf ();
49
50 const std::locale loc =
51 std::locale (std::locale::classic (), new std::numpunct<char>());
52
53 // set up y to be different from x
54 y.tie (&ystrm);
55 y.exceptions (y.eofbit);
56 y.setf (y.boolalpha);
57 y.precision (x.precision () + 1);
58 y.width (x.width () + 1);
59 y.fill (x.fill () + 1);
60 y.imbue (loc);
61
62 // verify test preconditions
63 assert (x.tie () != y.tie ());
64 assert (x.getloc () != y.getloc ());
65
66 x.copyfmt (y);
67
68 // verify copyfmt() postconditions
69 assert (x.rdbuf () == x_rdbuf);
70 assert (x.tie () == y.tie ());
71 assert (x.rdstate () == x_rdstate);
72 assert (x.exceptions () == y.exceptions ());
73 assert (x.flags () == y.flags ());
74 assert (x.precision () == y.precision ());
75 assert (x.width () == y.width ());
76 assert (x.fill () == y.fill ());
77 assert (x.getloc () == y.getloc ());
78}
#define y
Definition 17.names.cpp:141
#define loc
Definition 17.names.cpp:492
#define x
Definition 17.names.cpp:140
#define assert(expr)
Definition _cassert.h:40