From 234337d31028ca2d736bb4acc39daf9740645b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Thu, 18 Mar 2021 17:06:17 -0400 Subject: [PATCH] refactor: use perfect forwarding for make functions Addresses https://github.com/mpusz/units/pull/261#discussion_r597131272. --- src/core/include/units/quantity.h | 6 +++--- src/core/include/units/quantity_kind.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/include/units/quantity.h b/src/core/include/units/quantity.h index ec246f4f..84044f09 100644 --- a/src/core/include/units/quantity.h +++ b/src/core/include/units/quantity.h @@ -37,9 +37,9 @@ namespace units { namespace detail { template // TODO: Replace with `v * R{}` pending https://github.com/BobSteagall/wg21/issues/58. -inline constexpr auto make_quantity = [](auto v) { - using Rep = decltype(v); - return quantity(std::move(v)); +inline constexpr auto make_quantity = [](auto&& v) { + using Rep = std::remove_cvref_t; + return quantity(std::forward(v)); }; } // namespace detail diff --git a/src/core/include/units/quantity_kind.h b/src/core/include/units/quantity_kind.h index 868c4a3a..a9357e3d 100644 --- a/src/core/include/units/quantity_kind.h +++ b/src/core/include/units/quantity_kind.h @@ -34,9 +34,9 @@ namespace units { namespace detail { template -inline constexpr auto make_quantity_kind_fn = [](auto q) { - using Q = decltype(q); - return quantity_kind(std::move(q)); +inline constexpr auto make_quantity_kind_fn = [](auto&& q) { + using Q = std::remove_reference_t; + return quantity_kind(std::forward(q)); }; template