about summary refs log tree commit diff stats
path: root/data/maps/the_plaza/rooms/Mastery.txtpb
diff options
context:
space:
mode:
Diffstat (limited to 'data/maps/the_plaza/rooms/Mastery.txtpb')
0 files changed, 0 insertions, 0 deletions
8b2ec2d52e'>^
a9a5996 ^

b430eb5 ^

a9a5996 ^



b430eb5 ^





































a9a5996 ^




b430eb5 ^







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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104















                                                                                

                       









                               
     



                                  











                                          

                       

       



                                  





































                                     




                               







                                                    
#ifndef RECPTR_H_BCF778F0
#define RECPTR_H_BCF778F0

namespace hatkirby {

  /**
   * This class provides a pointer wrapper for an object. The difference between
   * it and std::unique_ptr is that it has a defined copy constructor, which
   * uses the object's copy constructor to make a new object. This class is
   * useful for the situation in which an object needs to have a member variable
   * of the same type as itself.
   */
  template <typename T>
  class recptr {
  public:

    recptr() = default;

    recptr(T* ptr) : ptr_(ptr)
    {
    }

    ~recptr()
    {
      delete ptr_;
    }

    recptr(const recptr& other)
    {
      if (other.ptr_)
      {
        ptr_ = new T(*other.ptr_);
      }
    }

    recptr(recptr&& other)
    {
      std::swap(ptr_, other.ptr_);
    }

    recptr& operator=(const recptr& other)
    {
      if (ptr_)
      {
        delete ptr_;

        ptr_ = nullptr;
      }

      if (other.ptr_)
      {
        ptr_ = new T(*other.ptr_);
      }

      return *this;
    }

    recptr& operator=(recptr&& other)
    {
      if (ptr_)
      {
        delete ptr_;

        ptr_ = nullptr;
      }

      std::swap(ptr_, other.ptr_);

      return *this;
    }

    T& operator*()
    {
      return *ptr_;
    }

    T* operator->()
    {
      return ptr_;
    }

    const T& operator*() const
    {
      return *ptr_;
    }

    const T* operator->() const
    {
      return ptr_;
    }

    operator bool() const
    {
      return (ptr_ != nullptr);
    }

  private:

    T* ptr_ = nullptr;
  };

}

#endif /* end of include guard: RECPTR_H_BCF778F0 */