blob: 0a0d85de7831f92e9497aa854e2d0a29d2f03bde (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
// This source code is released into the public domain.
export module nihil.util:construct;
import nihil.std;
namespace nihil {
// A functor that constructs objects of an arbitrary type.
// Useful for std::views::transform.
template <typename T>
struct construct_fn {
auto operator()(this construct_fn const &, auto &&...args) -> T
{
return T(std::forward<decltype(args)>(args)...);
}
};
export template<typename T>
inline constexpr auto construct = construct_fn<T>{};
}
|