File tree Expand file tree Collapse file tree 4 files changed +57
-2
lines changed Expand file tree Collapse file tree 4 files changed +57
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,18 @@ StreamReader(const StreamReader ©) :
43
43
}
44
44
45
45
/* *
46
- * The copy constructor does not copy ownership of the stream.
46
+ * The move constructor steals ownership of the stream.
47
+ */
48
+ INLINE StreamReader::
49
+ StreamReader (StreamReader &&from) noexcept :
50
+ _in(from._in),
51
+ _owns_stream(from._owns_stream)
52
+ {
53
+ from._owns_stream = false ;
54
+ }
55
+
56
+ /* *
57
+ * The copy assignment operator does not copy ownership of the stream.
47
58
*/
48
59
INLINE void StreamReader::
49
60
operator = (const StreamReader ©) {
@@ -54,6 +65,19 @@ operator = (const StreamReader ©) {
54
65
_owns_stream = false ;
55
66
}
56
67
68
+ /* *
69
+ * The move assignment operator steals ownership of the stream.
70
+ */
71
+ INLINE void StreamReader::
72
+ operator = (StreamReader &&from) noexcept {
73
+ if (_owns_stream) {
74
+ delete _in;
75
+ }
76
+ _in = from._in ;
77
+ _owns_stream = from._owns_stream ;
78
+ from._owns_stream = false ;
79
+ }
80
+
57
81
/* *
58
82
*
59
83
*/
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ class EXPCL_DTOOL_PRC StreamReader {
31
31
PUBLISHED:
32
32
INLINE explicit StreamReader (std::istream *in, bool owns_stream);
33
33
INLINE StreamReader (const StreamReader ©);
34
+ INLINE StreamReader (StreamReader &&from) noexcept ;
34
35
INLINE void operator = (const StreamReader ©);
36
+ INLINE void operator = (StreamReader &&from) noexcept ;
35
37
INLINE ~StreamReader ();
36
38
37
39
INLINE std::istream *get_istream () const ;
Original file line number Diff line number Diff line change @@ -51,7 +51,21 @@ StreamWriter(const StreamWriter ©) :
51
51
}
52
52
53
53
/* *
54
- * The copy constructor does not copy ownership of the stream.
54
+ * The move constructor steals ownership of the stream.
55
+ */
56
+ INLINE StreamWriter::
57
+ StreamWriter (StreamWriter &&from) noexcept :
58
+ #ifdef HAVE_PYTHON
59
+ softspace (0 ),
60
+ #endif
61
+ _out (from._out),
62
+ _owns_stream(from._owns_stream)
63
+ {
64
+ from._owns_stream = false ;
65
+ }
66
+
67
+ /* *
68
+ * The copy assignment operator does not copy ownership of the stream.
55
69
*/
56
70
INLINE void StreamWriter::
57
71
operator = (const StreamWriter ©) {
@@ -62,6 +76,19 @@ operator = (const StreamWriter ©) {
62
76
_owns_stream = false ;
63
77
}
64
78
79
+ /* *
80
+ * The move assignment operator steals ownership of the stream.
81
+ */
82
+ INLINE void StreamWriter::
83
+ operator = (StreamWriter &&from) noexcept {
84
+ if (_owns_stream) {
85
+ delete _out;
86
+ }
87
+ _out = from._out ;
88
+ _owns_stream = from._owns_stream ;
89
+ from._owns_stream = false ;
90
+ }
91
+
65
92
/* *
66
93
*
67
94
*/
Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ class EXPCL_DTOOL_PRC StreamWriter {
32
32
PUBLISHED:
33
33
INLINE explicit StreamWriter (std::ostream *out, bool owns_stream);
34
34
INLINE StreamWriter (const StreamWriter ©);
35
+ INLINE StreamWriter (StreamWriter &&from) noexcept ;
35
36
INLINE void operator = (const StreamWriter ©);
37
+ INLINE void operator = (StreamWriter &&from) noexcept ;
36
38
INLINE ~StreamWriter ();
37
39
38
40
INLINE std::ostream *get_ostream () const ;
You can’t perform that action at this time.
0 commit comments