summaryrefslogtreecommitdiffhomepage
path: root/src/emplacer.hpp
blob: d132bd7b37595b85e7d6d4a79d588ff3a9e5be89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#pragma once
#include <type_traits>
#include <Corrade/Utility/Move.h>

namespace floormat {

template<typename F>
class emplacer {
    F fun;
    using type = std::decay_t<decltype(std::declval<F>()())>;

public:
    explicit constexpr emplacer(F&& fun) noexcept : fun{Utility::forward<F>(fun)} {}
    constexpr operator type() const noexcept { return fun(); }
};

} // namespace floormat