From 378dd663a402fe196f2b56c6413eb3f623aecbbf Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Tue, 1 Jul 2025 19:18:42 +0100 Subject: cli: refactoring --- nihil.util/construct.ccm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 nihil.util/construct.ccm (limited to 'nihil.util/construct.ccm') diff --git a/nihil.util/construct.ccm b/nihil.util/construct.ccm new file mode 100644 index 0000000..0a0d85d --- /dev/null +++ b/nihil.util/construct.ccm @@ -0,0 +1,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 +struct construct_fn { + auto operator()(this construct_fn const &, auto &&...args) -> T + { + return T(std::forward(args)...); + } +}; + +export template +inline constexpr auto construct = construct_fn{}; + +} -- cgit v1.2.3