Echo Writes Code

copy_move_tracer.cpp

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
#include "crucible/test/copy_move_tracer.hpp"

#include "crucible/core/string.hpp"

namespace crucible
{
  CopyMoveTracer::CopyMoveTracer() = default;

  CopyMoveTracer::CopyMoveTracer(CopyMoveTracer const &that)
  {
    that.copied_from = true;
    copied_into = true;
  }

  CopyMoveTracer::CopyMoveTracer(CopyMoveTracer &&that)
  {
    that.moved_from = true;
    moved_into = true;
  }

  auto CopyMoveTracer::operator=(CopyMoveTracer const &that) -> CopyMoveTracer &
  {
    that.copied_from = true;
    copied_into = true;
    return *this;
  }

  auto CopyMoveTracer::operator=(CopyMoveTracer &&that) -> CopyMoveTracer &
  {
    that.moved_from = true;
    moved_into = true;
    return *this;
  }

  auto CopyMoveTracer::describe() const -> String
  {
    return "We sure did trace some copies and moves!";
  }
}