Nugget
enable_shared.h
1 // Copyright (c) Electronic Arts Inc. All rights reserved.
4 
5 
6 #ifndef EASTL_INTERNAL_ENABLE_SHARED_H
7 #define EASTL_INTERNAL_ENABLE_SHARED_H
8 
9 
10 #include <EABase/eabase.h>
11 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
12  #pragma once
13 #endif
14 
15 namespace eastl
16 {
17 
38  template <typename T>
40  {
41  public:
42  shared_ptr<T> shared_from_this()
43  { return shared_ptr<T>(mWeakPtr); }
44 
45  shared_ptr<const T> shared_from_this() const
46  { return shared_ptr<const T>(mWeakPtr); }
47 
48  weak_ptr<T> weak_from_this()
49  { return mWeakPtr; }
50 
51  weak_ptr<const T> weak_from_this() const
52  { return mWeakPtr; }
53 
54  public: // This is public because the alternative fails on some compilers that we need to support.
55  mutable weak_ptr<T> mWeakPtr;
56 
57  protected:
58  template <typename U> friend class shared_ptr;
59 
60  EA_CONSTEXPR enable_shared_from_this() EA_NOEXCEPT
61  { }
62 
64  { }
65 
66  enable_shared_from_this& operator=(const enable_shared_from_this&) EA_NOEXCEPT
67  { return *this; }
68 
70  { }
71 
72  }; // enable_shared_from_this
73 
74 } // namespace eastl
75 
76 
77 #endif // Header include guard
78 
79 
80 
81 
82 
83 
Definition: enable_shared.h:40
Definition: shared_ptr.h:359
Definition: shared_ptr.h:1361
EA Standard Template Library.
Definition: algorithm.h:288