<commit_before>#pragma once
//------------------------------------------------------------------------------
/**
    @class Oryol::Core::Ptr
    @brief Oryol's smart pointer class

    The Oryol smart pointer class is used together with the RefCounted
    base class to implement automatic object life-time management.

    @see RefCounted
*/
#include "Core/Types.h"
#include "Core/Macros.h"

namespace Oryol {
namespace Core {

template<class T> class Ptr {
public:
    /// unsafe get, may return nullptr
    T* GetUnsafe() const noexcept {
        return p;
    };

    /// default constructor
    constexpr Ptr() noexcept : p(nullptr) {
        // empty
    };
    /// nullptr constructor
    constexpr Ptr(std::nullptr_t) noexcept : p(nullptr) {
        // empty
    };
    /// construct from compatible raw pointer
    template<class U> Ptr(U* rhs) noexcept {
        set(static_cast<T*>(rhs));
    };
    /// copy-construct from Ptr<TYPE>
    Ptr(const Ptr<T>& rhs) noexcept {
        set(rhs.p);
    };
    /// copy-construct from Ptr<OTHER>
    template<class U> Ptr(const Ptr<U>& rhs) noexcept {
        set(static_cast<T*>(rhs.GetUnsafe()));
    };
    /// move constructor from Ptr<TYPE>
    Ptr(Ptr<T>&& rhs) noexcept {
        p = rhs.p;
        rhs.p = nullptr;
    };
    /// move constructor from compatible type
    template<class U> Ptr(Ptr<U>&& rhs) noexcept {
        p = static_cast<T*>(rhs.GetUnsafe());
        rhs.p = nullptr;
    };
    
    /// destructor
    ~Ptr() {
        del();
    };
    
    /// assign from compatible raw pointer
    template<class U> void operator=(U* rhs) noexcept {
        if (static_cast<T*>(rhs) != p) {
            del();
            set(static_cast<T*>(rhs));
        }
    };
    /// assign from compatible Ptr<>
    template<class U> void operator=(const Ptr<U>& rhs) noexcept {<commit_msg>Added missing copy constructors and copy-assignment operators to Ptr<commit_after>#pragma once
//------------------------------------------------------------------------------
/**
    @class Oryol::Core::Ptr
    @brief Oryol's smart pointer class

    The Oryol smart pointer class is used together with the RefCounted
    base class to implement automatic object life-time management.

    @see RefCounted
*/
#include "Core/Types.h"
#include "Core/Macros.h"

namespace Oryol {
namespace Core {

template<class T> class Ptr {
public:
    /// unsafe get, may return nullptr
    T* GetUnsafe() const noexcept {
        return p;
    };

    /// default constructor
    constexpr Ptr() noexcept : p(nullptr) {
        // empty
    };
    /// nullptr constructor
    constexpr Ptr(std::nullptr_t) noexcept : p(nullptr) {
        // empty
    };
    /// construct from compatible raw pointer
    template<class U> Ptr(U* rhs) noexcept {
        set(static_cast<T*>(rhs));
    };
    /// copy-construct from Ptr<TYPE>
    Ptr(const Ptr<T>& rhs) noexcept {
        set(rhs.p);
    };
    /// copy-construct from Ptr<OTHER>
    template<class U> Ptr(const Ptr<U>& rhs) noexcept {
        set(static_cast<T*>(rhs.GetUnsafe()));
    };
    /// move constructor from Ptr<TYPE>
    Ptr(Ptr<T>&& rhs) noexcept {
        p = rhs.p;
        rhs.p = nullptr;
    };
    /// move constructor from compatible type
    template<class U> Ptr(Ptr<U>&& rhs) noexcept {
        p = static_cast<T*>(rhs.GetUnsafe());
        rhs.p = nullptr;
    };
    
    /// destructor
    ~Ptr() {
        del();
    };
    
    /// copy-assign from Ptr<TYPE>
    void operator=(const Ptr<T>& rhs) noexcept {
        if (rhs.p != p) {
            del();
            set(rhs.p);
        }
    };
    /// copy-assign from compatible raw pointer
    template<class U> void operator=(U* rhs) noexcept {
        if (static_cast<T*>(rhs) != p) {
            del();
            set(static_cast<T*>(rhs));
        }
    };
    /// copy-assign from compatible Ptr<>
    template<class U> void operator=(const Ptr<U>& rhs) noexcept {
{'fraction_non_alphanumeric': 0.17314039096217315, 'fraction_numerical': 0.0, 'mean_word_length': 1.9468960359012715, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4904156', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1210, 'n_words': 325}