aboutsummaryrefslogblamecommitdiffstats
path: root/library/cpp/messagebus/moved.h
blob: ede8dcd2443c7f97c7d8638720a42c5d2fbef6bb (plain) (tree)
1
2
3
4
5
6
7
8
9
10








                                 
              

























                                            
#pragma once

#include <util/generic/utility.h>

template <typename T>
class TMoved {
private:
    mutable T Value;

public:
    TMoved() {
    }
    TMoved(const TMoved<T>& that) {
        DoSwap(Value, that.Value);
    }
    TMoved(const T& that) {
        DoSwap(Value, const_cast<T&>(that));
    }

    void swap(TMoved& that) {
        DoSwap(Value, that.Value);
    }

    T& operator*() {
        return Value;
    }

    const T& operator*() const {
        return Value;
    }

    T* operator->() {
        return &Value;
    }

    const T* operator->() const {
        return &Value;
    }
};