EHS/include/ehs/Link.h
Karutoh bcd71cf2b5
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 1m8s
Build & Release / Linux-AMD64-Build (push) Successful in 1m30s
Build & Release / Linux-AARCH64-Build (push) Successful in 3m21s
Adjusted workflow.
2024-02-05 22:25:30 -08:00

71 lines
1.2 KiB
C++

#pragma once
namespace ehs
{
/// Test
template<typename T>
class Link
{
public:
T value;
Link<T> *child;
~Link()
{
delete child;
}
Link()
: value(), child(nullptr)
{
}
Link(const T value, Link* child)
: value(value), child(child)
{
}
Link(const T value)
: value(value), child(nullptr)
{
}
Link(const Link& link)
: value(link.value), child(nullptr)
{
}
Link(Link&& link) noexcept
: value(link.value), child(link.child)
{
link.value = 0;
link.child = nullptr;
}
Link& operator=(const Link& link)
{
if (this == &link)
return *this;
value = link.value;
child = nullptr;
return *this;
}
Link& operator=(Link&& link) noexcept
{
if (this == &link)
return *this;
value = link.value;
child = link.child;
link.value = 0;
link.child = nullptr;
return *this;
}
};
}