summaryrefslogtreecommitdiff
path: root/include/mbgl/util/pass_types.hpp
blob: 227a81778d055d17de9e25f00f817562b19fb510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once

#include <memory>

namespace mbgl {

// Using this type as a return type enforces the client to retain the returned object.
template <typename T>
class Pass {
public:
    Pass(T obj_) : obj(std::move(obj_)) {}
    Pass(Pass&&) noexcept = default;
    Pass(const Pass&) = delete;
    Pass& operator=(const Pass&) = delete;
    operator T() && { return std::move(obj); }

private:
    T obj;
};

template <typename T>
using PassRefPtr = Pass<std::shared_ptr<T>>;

} // namespace mbgl