diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-07-01 19:21:05 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-07-01 19:21:05 +0100 |
| commit | e461c17c24115132601362a96b6a85c0dd12f471 (patch) | |
| tree | 4eff88732245f39a2f52565eb5424842428488c9 /nihil.util | |
| parent | 378dd663a402fe196f2b56c6413eb3f623aecbbf (diff) | |
| download | nihil-e461c17c24115132601362a96b6a85c0dd12f471.tar.gz nihil-e461c17c24115132601362a96b6a85c0dd12f471.tar.bz2 | |
construct: add final and [[nodiscard]]
Diffstat (limited to 'nihil.util')
| -rw-r--r-- | nihil.util/construct.ccm | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/nihil.util/construct.ccm b/nihil.util/construct.ccm index 0a0d85d..894a446 100644 --- a/nihil.util/construct.ccm +++ b/nihil.util/construct.ccm @@ -8,14 +8,15 @@ 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 +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> +export template <typename T> inline constexpr auto construct = construct_fn<T>{}; -} +} // namespace nihil |
