-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmove_semantics.h
More file actions
46 lines (34 loc) · 1.02 KB
/
move_semantics.h
File metadata and controls
46 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//*****************************************************************************
//
// Author: Michael Price
// License: Attribution-NonCommercial-NoDerivs 3.0 Unported
// http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode
//
//*****************************************************************************
#ifndef MOVE_SEMANTICS_H__
#define MOVE_SEMANTICS_H__
#ifndef WIN32
namespace std {
template <class InputIterator, class OutputIterator>
OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result);
} // namespace std
#endif // WIN32
class MoveableBuffer
{
public:
MoveableBuffer () { buf = new char[256]; }
~MoveableBuffer () { delete[] buf; }
MoveableBuffer (const MoveableBuffer & other)
{
buf = new char[256];
std::copy(buf, buf + 256, other.buf);
}
MoveableBuffer(MoveableBuffer && other)
{
buf = other.buf;
other.buf = nullptr;
}
private:
char * buf;
};
#endif /* end of include guard: MOVE_SEMANTICS_H__ */