From 5adeb648f74c1771164c0686d6e0fc584cf36d9e Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Wed, 2 Jul 2025 04:00:06 +0100 Subject: move everything from util to core --- nihil.core/construct.ccm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 nihil.core/construct.ccm (limited to 'nihil.core/construct.ccm') diff --git a/nihil.core/construct.ccm b/nihil.core/construct.ccm new file mode 100644 index 0000000..5dd4422 --- /dev/null +++ b/nihil.core/construct.ccm @@ -0,0 +1,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 +struct construct_fn final +{ + [[nodiscard]] auto operator()(this construct_fn const &, auto &&...args) -> T + { + return T(std::forward(args)...); + } +}; + +export template +inline constexpr auto construct = construct_fn{}; + +} // namespace nihil -- cgit v1.2.3