Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
unique_ptr.hpp
Go to the documentation of this file.
1#pragma once
2#include <fc/utility.hpp>
3#include <memory>
4
5namespace fc
6{
7 template<typename T>
9 {
10 public:
11 typedef T* pointer;
12
13 explicit unique_ptr( pointer t = nullptr ):_p(t){}
14
16 :_p(m._p){ m._p = nullptr; }
17
18 ~unique_ptr() { delete _p; }
19
20 operator bool()const { return _p != nullptr; }
21 friend bool operator==(const unique_ptr& p, nullptr_t)
22 {
23 return p._p == nullptr;
24 }
25
26 friend bool operator!=(const unique_ptr& p, nullptr_t)
27 {
28 return p._p != nullptr;
29 }
30
32 {
33 delete _p; _p = nullptr;
34 }
35
37 {
38 fc_swap( _p, o._p );
39 return *this;
40 }
41
42 pointer operator->()const { return _p; }
43 T& operator*()const { return *_p; }
44
45 void reset( pointer v )
46 {
47 delete _p; _p = v;
48 }
50 {
51 auto tmp = _p;
52 _p = nullptr;
53 return tmp;
54 }
55
56 private:
57 pointer _p;
58 };
59
60}
const mie::Vuint & p
Definition bn.cpp:27
pointer operator->() const
unique_ptr(unique_ptr &&m)
unique_ptr & operator=(nullptr_t)
pointer release()
T & operator*() const
friend bool operator!=(const unique_ptr &p, nullptr_t)
friend bool operator==(const unique_ptr &p, nullptr_t)
unique_ptr(pointer t=nullptr)
void reset(pointer v)
unique_ptr & operator=(unique_ptr &&o)
namespace sysio::chain
Definition authority.cpp:3
decltype(nullptr) nullptr_t
Definition utility.hpp:28
#define T(meth, val, expected)
void fc_swap(T &a, T &b)
Definition utility.hpp:211