blob: 5dd4422d03c1d3bc069e477c42078a6d6c3d0cab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// This source code is released into the public domain.
export module nihil.core: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 final
{
[[nodiscard]] 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>{};
} // namespace nihil
|