aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/unified_agent_client/f_maybe.h
blob: 7abd4c0aacbe78f0c072f798a94b7181867ae33a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

#include <util/generic/maybe.h>

namespace NUnifiedAgent {
    template <typename T>
    using TFMaybe = TMaybe<T, ::NMaybe::TPolicyUndefinedFail>;

    template <class T>
    inline constexpr TFMaybe<std::decay_t<T>> MakeFMaybe(T&& value) {
        return TMaybe<std::decay_t<T>, ::NMaybe::TPolicyUndefinedFail>(std::forward<T>(value));
    }

    template <class T, class... TArgs>
    inline constexpr TFMaybe<T> MakeFMaybe(TArgs&&... args) {
        return TFMaybe<T>(typename TFMaybe<T>::TInPlace{}, std::forward<TArgs>(args)...);
    }

    template <class T>
    inline constexpr TFMaybe<std::decay_t<T>> MakeFMaybe(const TMaybe<T>& source) {
        return source.Defined() ? MakeFMaybe(*source) : Nothing();
    }
}