DuxReiNummariae 1.1.0-alpha.19
Simple and powerful budgeting application
Loading...
Searching...
No Matches
drn::foundation::RequireClonable< BaseType > Struct Template Referenceabstract

Abstract base class requiring derived classes to implement deep-copy functionality. More...

#include <Mixins.hpp>

Inheritance diagram for drn::foundation::RequireClonable< BaseType >:
Collaboration diagram for drn::foundation::RequireClonable< BaseType >:

Public Member Functions

virtual ~RequireClonable ()=default
virtual std::unique_ptr< BaseType > clone () const =0
 When implemented, creates a polymorphic deep copy of the object.

Detailed Description

template<typename BaseType>
struct drn::foundation::RequireClonable< BaseType >

Abstract base class requiring derived classes to implement deep-copy functionality.

Provides an interface for creating polymorphic deep copies of objects. Classes that inherit from this must implement the clone method, enabling the creation of a unique pointer to a new copy of the object. This facilitates copying of instances while preserving their full dynamic type.

Template Parameters
BaseTypeThe base type of objects which can be cloned.

Constructor & Destructor Documentation

◆ ~RequireClonable()

template<typename BaseType>
virtual drn::foundation::RequireClonable< BaseType >::~RequireClonable ( )
virtualdefault

Member Function Documentation

◆ clone()

template<typename BaseType>
virtual std::unique_ptr< BaseType > drn::foundation::RequireClonable< BaseType >::clone ( ) const
nodiscardpure virtual

When implemented, creates a polymorphic deep copy of the object.

Ensures the creation of a new instance of the derived type, preserving the object's dynamic type.

Returns
A newly created deep copy of the object.

Implemented in drn::budgeting::Bill, drn::budgeting::Debt, drn::budgeting::Goal, drn::budgeting::Nontrack, and drn::budgeting::Wage.