1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- namespace NYT::NGlobal {
- ////////////////////////////////////////////////////////////////////////////////
- namespace NDetail {
- // Defined in impl.cpp.
- void RegisterVariable(const TVariableTag& tag, TAccessor accessor);
- } // namespace NDetail
- ////////////////////////////////////////////////////////////////////////////////
- template <CTriviallyErasable<GlobalVariableMaxByteSize> T>
- class TVariable
- {
- public:
- TVariable(
- const TVariableTag& tag,
- TAccessor accessor,
- T initValue = {}) noexcept;
- TVariable(const TVariable& other) = delete;
- TVariable& operator=(const TVariable& other) = delete;
- T Get() const noexcept;
- void Set(T value) noexcept;
- private:
- // NB(arkady-e1ppa): Ban TVariable<TVariable<T>>.
- static_assert(!requires (T t) {
- [] <class U> (TVariable<U>&) { } (t);
- });
- T Value_;
- };
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- } // namespace NYT::NGlobal
|