/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/cpp/messagebus/moved.h
39 строк
605 B
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#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; } };