|
DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
|
A unified smart pointer that supports both unique and shared ownership semantics. More...
#include <SmartPointer.h>
Public Member Functions | |
| SmartPointer () | |
| Default constructor. For concrete types: Automatically allocates a new instance of T. For abstract types: Initializes to nullptr. | |
| SmartPointer (bool bIsShared) | |
| Constructor with ownership mode flag. Automatically allocates a new instance of T. | |
| SmartPointer (const SmartPointer &objOther) | |
| Copy constructor. Only permitted if the source is in Shared mode. | |
| template<typename U, typename = std::enable_if_t<std::is_convertible_v<U*, T*>>> | |
| SmartPointer (const SmartPointer< U > &objOther) | |
| SmartPointer (SmartPointer &&objOther) noexcept | |
| Move constructor. Transfers ownership from the source. | |
| template<typename U, typename = std::enable_if_t<std::is_convertible_v<U*, T*>>> | |
| SmartPointer (SmartPointer< U > &&objOther) noexcept | |
| SmartPointer (std::nullptr_t) | |
| Explicit null constructor. | |
| SmartPointer (T *pPtr) | |
| Constructor for explicit raw pointer attachment. | |
| SmartPointer (T *pPtr, bool bIsShared) | |
| Constructor that specifies ownership mode for a raw pointer. | |
| ~SmartPointer () | |
| Destructor. Cleans up the managed object based on ownership mode. | |
| void | Attach (T *pPtr, bool bIsShared=false) |
| Attaches a new raw pointer to the SmartPointer. | |
| template<typename U> | |
| SmartPointer< U > | ConstCast () const |
| Const casts the managed pointer to another type U and returns a new SmartPointer sharing ownership. | |
| T * | Detach () |
| Detaches the managed object and returns it. The SmartPointer will no longer own the object. | |
| template<typename U> | |
| SmartPointer< U > | DynamicCast () const |
| Dynamically casts the managed pointer to another type U and returns a new SmartPointer sharing ownership. | |
| T * | Get () const noexcept |
| Gets the raw pointer. | |
| int | GetRefCount () const noexcept |
| Gets the current reference count. Returns 0 for Unique or Null pointers. | |
| bool | IsNull () const noexcept |
| Checks if the SmartPointer is null. | |
| operator bool () const noexcept | |
| bool | operator!= (const SmartPointer &other) const noexcept |
| template<typename U> | |
| bool | operator!= (const SmartPointer< U > &other) const noexcept |
| template<typename U> | |
| bool | operator!= (const U *pOther) const noexcept |
| bool | operator!= (std::nullptr_t) const noexcept |
| T & | operator* () const |
| T * | operator-> () const noexcept |
| SmartPointer & | operator= (const SmartPointer &objOther) |
| Copy assignment operator. Only permitted if the source is in Shared mode. | |
| template<typename U, typename = std::enable_if_t<std::is_convertible_v<U*, T*>>> | |
| SmartPointer & | operator= (const SmartPointer< U > &objOther) |
| SmartPointer & | operator= (SmartPointer &&objOther) noexcept |
| Move assignment operator. Transfers ownership from the source. | |
| template<typename U, typename = std::enable_if_t<std::is_convertible_v<U*, T*>>> | |
| SmartPointer & | operator= (SmartPointer< U > &&objOther) noexcept |
| bool | operator== (const SmartPointer &other) const noexcept |
| template<typename U> | |
| bool | operator== (const SmartPointer< U > &other) const noexcept |
| template<typename U> | |
| bool | operator== (const U *pOther) const noexcept |
| bool | operator== (std::nullptr_t) const noexcept |
| void | Reset (T *pPtr, bool bIsShared) |
| Resets the SmartPointer with a specific ownership mode. | |
| void | Reset (T *pPtr=nullptr) |
| Resets the SmartPointer to null or a new object in Unique mode. | |
| template<typename U> | |
| SmartPointer< U > | StaticCast () const |
| Statically casts the managed pointer to another type U and returns a new SmartPointer sharing ownership. | |
Static Public Member Functions | |
| template<typename From> | |
| static SmartPointer< T > | ConstCast (const SmartPointer< From > &sp) |
| template<typename From> | |
| static SmartPointer< T > | DynamicCast (const SmartPointer< From > &sp) |
| static SmartPointer< T > | MakeShared () |
| Alias for NewShared (default construction). | |
| template<typename Arg1, typename... Args> | |
| static SmartPointer< T > | MakeShared (Arg1 &&arg1, Args &&... args) |
| Alias for NewShared. Provided for compatibility. | |
| static SmartPointer< T > | MakeUnique () |
| Alias for NewUnique (default construction). | |
| template<typename Arg1, typename... Args> | |
| static SmartPointer< T > | MakeUnique (Arg1 &&arg1, Args &&... args) |
| Alias for NewUnique. Provided for compatibility. | |
| static SmartPointer< T > | New () |
| Creates a new SmartPointer (default construction). | |
| template<typename Arg1, typename... Args> | |
| static SmartPointer< T > | New (Arg1 &&arg1, Args &&... args) |
| Creates a new SmartPointer with variadic arguments for T's constructor. | |
| static SmartPointer< T > | NewShared () |
| Creates a Shared SmartPointer, default constructing T. | |
| template<typename Arg1, typename... Args> | |
| static SmartPointer< T > | NewShared (Arg1 &&arg1, Args &&... args) |
| Creates a Shared SmartPointer, forwarding arguments to T's constructor. | |
| static SmartPointer< T > | NewUnique () |
| Creates a Unique SmartPointer, default constructing T. | |
| template<typename Arg1, typename... Args> | |
| static SmartPointer< T > | NewUnique (Arg1 &&arg1, Args &&... args) |
| Creates a Unique SmartPointer, forwarding arguments to T's constructor. | |
| template<typename From> | |
| static SmartPointer< T > | StaticCast (const SmartPointer< From > &sp) |
A unified smart pointer that supports both unique and shared ownership semantics.
Provides high-performance automatic lifetime management without raw pointer leaks:
Definition at line 72 of file SmartPointer.h.
|
inline |
Default constructor. For concrete types: Automatically allocates a new instance of T. For abstract types: Initializes to nullptr.
Definition at line 85 of file SmartPointer.h.
|
inlineexplicit |
Constructor with ownership mode flag. Automatically allocates a new instance of T.
| bIsShared | If true, enables reference counting (Shared mode). |
Definition at line 105 of file SmartPointer.h.
|
inlineexplicit |
Constructor for explicit raw pointer attachment.
| pPtr | The raw pointer to take ownership of. |
Definition at line 127 of file SmartPointer.h.
|
inline |
Constructor that specifies ownership mode for a raw pointer.
| pPtr | The raw pointer to take ownership of. |
| bIsShared | If true, enables reference counting (Shared mode). |
Definition at line 134 of file SmartPointer.h.
|
inline |
Explicit null constructor.
Definition at line 143 of file SmartPointer.h.
|
inline |
Destructor. Cleans up the managed object based on ownership mode.
Definition at line 148 of file SmartPointer.h.
|
inline |
Copy constructor. Only permitted if the source is in Shared mode.
| SystemException | If the source pointer is in Unique mode. |
Definition at line 158 of file SmartPointer.h.
|
inline |
Definition at line 170 of file SmartPointer.h.
|
inlinenoexcept |
Move constructor. Transfers ownership from the source.
Definition at line 218 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 225 of file SmartPointer.h.
|
inline |
Attaches a new raw pointer to the SmartPointer.
| pPtr | The new pointer to manage. |
| bIsShared | Ownership mode for the new pointer. |
Definition at line 345 of file SmartPointer.h.
|
inline |
Const casts the managed pointer to another type U and returns a new SmartPointer sharing ownership.
Definition at line 419 of file SmartPointer.h.
|
inlinestatic |
Definition at line 436 of file SmartPointer.h.
|
inline |
Detaches the managed object and returns it. The SmartPointer will no longer own the object.
Definition at line 378 of file SmartPointer.h.
|
inline |
Dynamically casts the managed pointer to another type U and returns a new SmartPointer sharing ownership.
Definition at line 399 of file SmartPointer.h.
Referenced by DotNetDupe::System::Text::TextEncoding::UTF8().
|
inlinestatic |
Definition at line 426 of file SmartPointer.h.
|
inlinenoexcept |
Gets the raw pointer.
Definition at line 388 of file SmartPointer.h.
Referenced by DotNetDupe::System::Net::Security::HandleHandshakeError(), DotNetDupe::System::Net::Security::HandleWriteError(), and DotNetDupe::WebAppCore::Builder::RouteAndSendResponse().
|
inlinenoexcept |
Gets the current reference count. Returns 0 for Unique or Null pointers.
Definition at line 443 of file SmartPointer.h.
|
inlinenoexcept |
Checks if the SmartPointer is null.
Definition at line 393 of file SmartPointer.h.
Referenced by DotNetDupe::System::Net::Sockets::NetworkStream::NetworkStream(), DotNetDupe::System::Net::Sockets::NetworkStream::NetworkStream(), DotNetDupe::System::Net::Security::SslStream::SslStream(), DotNetDupe::System::Net::Security::SslStream::SslStream(), DotNetDupe::System::Net::Http::StreamContent::StreamContent(), DotNetDupe::WebAppCore::Server::WebAppServer::WebAppServer(), DotNetDupe::Extensions::Logging::AggregateLogger::AddLogger(), DotNetDupe::Extensions::Logging::LoggerFactory::AddProvider(), DotNetDupe::Extensions::Logging::LogManager::AddProvider(), DotNetDupe::System::Net::Security::SslStream::AuthenticateAsServer(), DotNetDupe::System::Net::Sockets::TcpClient::Connected(), DotNetDupe::System::Net::Http::ByteArrayContent::CopyTo(), DotNetDupe::System::Net::Http::HttpContent::CopyTo(), DotNetDupe::System::Net::Http::StreamContent::CopyTo(), DotNetDupe::System::Net::Http::StringContent::CopyTo(), DotNetDupe::System::HashHelper< SmartPointer< T > >::GetHashCode(), DotNetDupe::System::IServiceProvider::GetRequiredService(), DotNetDupe::System::IServiceProvider::GetService(), DotNetDupe::System::Net::Http::HttpClient::Send(), DotNetDupe::WebAppCore::Builder::TryHandleWebSocket(), and DotNetDupe::WebAppCore::Http::WriteRaw().
|
inlinestatic |
Alias for NewShared (default construction).
Definition at line 326 of file SmartPointer.h.
|
inlinestatic |
Alias for NewShared. Provided for compatibility.
Definition at line 334 of file SmartPointer.h.
|
inlinestatic |
Alias for NewUnique (default construction).
Definition at line 311 of file SmartPointer.h.
|
inlinestatic |
Alias for NewUnique. Provided for compatibility.
Definition at line 319 of file SmartPointer.h.
|
inlinestatic |
Creates a new SmartPointer (default construction).
Definition at line 294 of file SmartPointer.h.
Referenced by DotNetDupe::System::Text::Json::JsonElement::operator=().
|
inlinestatic |
Creates a new SmartPointer with variadic arguments for T's constructor.
Definition at line 302 of file SmartPointer.h.
|
inlinestatic |
Creates a Shared SmartPointer, default constructing T.
Definition at line 277 of file SmartPointer.h.
Referenced by DotNetDupe::System::Threading::ConditionVariable::ConditionVariable(), DotNetDupe::Extensions::Logging::FileLoggerProvider::FileLoggerProvider(), DotNetDupe::Extensions::Logging::FileLoggerProvider::FileLoggerProvider(), DotNetDupe::WebAppCore::Http::HttpContext::HttpContext(), DotNetDupe::System::Data::SqlClient::SqlCommand::SqlCommand(), DotNetDupe::System::Data::SqlClient::SqlCommand::SqlCommand(), DotNetDupe::System::Threading::Tasks::Task::Task(), DotNetDupe::System::Data::Common::DbParameterCollection::AddWithValue(), DotNetDupe::System::Data::Common::DbParameterCollection::AddWithValue(), DotNetDupe::System::Data::Common::DbParameterCollection::AddWithValue(), DotNetDupe::WebAppCore::Builder::WebApplicationBuilder::Build(), DotNetDupe::Extensions::Logging::LogManager::Configure(), DotNetDupe::WebAppCore::Builder::WebApplication::CreateBuilder(), DotNetDupe::System::Data::SqlClient::SqlConnection::CreateCommand(), DotNetDupe::Extensions::Logging::ConsoleLoggerProvider::CreateLogger(), DotNetDupe::Extensions::Logging::FileLoggerProvider::CreateLogger(), DotNetDupe::Extensions::Logging::LoggerFactory::CreateLogger(), DotNetDupe::System::Diagnostics::SystemMetrics::CreateProcessStreamer(), DotNetDupe::Extensions::DependencyInjection::ServiceScopeFactory::CreateScope(), DotNetDupe::Extensions::DependencyInjection::ServiceDescriptor::Describe(), DotNetDupe::System::Diagnostics::EnumerateWin32Processes(), DotNetDupe::System::Data::SqlClient::SqlCommand::ExecuteReader(), DotNetDupe::System::Diagnostics::Process::GetProcessById(), DotNetDupe::Extensions::DependencyInjection::ServiceProvider::GetService(), DotNetDupe::System::TimeProvider::GetSystem(), DotNetDupe::Extensions::DependencyInjection::InstantiateService(), DotNetDupe::System::IdentityModel::Tokens::Jwt::JWTToken::Parse(), DotNetDupe::System::Net::Http::RestClient< TResource >::Post(), DotNetDupe::System::Net::Http::RestClient< TResource >::PostAndReturn(), DotNetDupe::WebAppCore::Builder::ProcessWsSession(), DotNetDupe::System::Net::Http::RestClient< TResource >::Put(), DotNetDupe::System::Data::SqlClient::RegisterSelectedBackend(), DotNetDupe::System::Net::Http::FileDownloader::Resume(), DotNetDupe::System::Threading::Tasks::Task::Run(), DotNetDupe::System::Diagnostics::Process::Start(), DotNetDupe::System::Net::Http::FileDownloader::Start(), DotNetDupe::System::Threading::AutoResetEvent::TryOpenExisting(), DotNetDupe::System::Threading::EventWaitHandle::TryOpenExisting(), DotNetDupe::System::Threading::ManualResetEvent::TryOpenExisting(), DotNetDupe::System::Threading::Mutex::TryOpenExisting(), DotNetDupe::System::Threading::Semaphore::TryOpenExisting(), and DotNetDupe::System::Text::TextEncoding::UTF8().
|
inlinestatic |
Creates a Shared SmartPointer, forwarding arguments to T's constructor.
Definition at line 285 of file SmartPointer.h.
|
inlinestatic |
Creates a Unique SmartPointer, default constructing T.
Definition at line 262 of file SmartPointer.h.
|
inlinestatic |
Creates a Unique SmartPointer, forwarding arguments to T's constructor.
Definition at line 270 of file SmartPointer.h.
|
inlineexplicitnoexcept |
Definition at line 451 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 457 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 467 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 493 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 475 of file SmartPointer.h.
|
inline |
Definition at line 449 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 450 of file SmartPointer.h.
|
inline |
Copy assignment operator. Only permitted if the source is in Shared mode.
Definition at line 184 of file SmartPointer.h.
|
inline |
Definition at line 200 of file SmartPointer.h.
|
inlinenoexcept |
Move assignment operator. Transfers ownership from the source.
Definition at line 234 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 246 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 453 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 462 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 488 of file SmartPointer.h.
|
inlinenoexcept |
Definition at line 471 of file SmartPointer.h.
|
inline |
Resets the SmartPointer with a specific ownership mode.
| pPtr | The raw pointer to manage. |
| bIsShared | If true, enables reference counting. |
Definition at line 366 of file SmartPointer.h.
|
inline |
Resets the SmartPointer to null or a new object in Unique mode.
| pPtr | Optional new raw pointer to manage. |
Definition at line 355 of file SmartPointer.h.
|
inline |
Statically casts the managed pointer to another type U and returns a new SmartPointer sharing ownership.
Definition at line 409 of file SmartPointer.h.
|
inlinestatic |
Definition at line 431 of file SmartPointer.h.