rogue
Loading...
Searching...
No Matches
EnableSharedFromThis.h
Go to the documentation of this file.
1
19#ifndef __ROGUE_ENABLE_SHARED_FROM_THIS_H__
20#define __ROGUE_ENABLE_SHARED_FROM_THIS_H__
21#include "rogue/Directives.h"
22
23#include <memory>
24
25namespace rogue {
26
35class EnableSharedFromThisBase : public std::enable_shared_from_this<rogue::EnableSharedFromThisBase> {
36 public:
39};
40
51template <typename T>
53 public:
58 std::shared_ptr<T> shared_from_this() {
59 return std::dynamic_pointer_cast<T>(EnableSharedFromThisBase::shared_from_this());
60 }
61};
62} // namespace rogue
63
64#endif
Common virtual base for Rogue shared-from-this support.
virtual ~EnableSharedFromThisBase()
Virtual destructor for polymorphic base usage.
Typed shared-from-this helper for Rogue classes.
std::shared_ptr< T > shared_from_this()
Returns a shared_ptr<T> for this instance.