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

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{std::forward<F>(fun)} {}
    constexpr operator type() const noexcept { return fun(); }
};

} // namespace floormat