refactor: use perfect forwarding for make functions

Addresses https://github.com/mpusz/units/pull/261#discussion_r597131272.
This commit is contained in:
Johel Ernesto Guerrero Peña
2021-03-18 22:37:25 +01:00
committed by Mateusz Pusz
parent c61b8643d7
commit 234337d310
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -37,9 +37,9 @@ namespace units {
namespace detail {
template<Reference auto R> // 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<typename decltype(R)::dimension, typename decltype(R)::unit, Rep>(std::move(v));
inline constexpr auto make_quantity = [](auto&& v) {
using Rep = std::remove_cvref_t<decltype(v)>;
return quantity<typename decltype(R)::dimension, typename decltype(R)::unit, Rep>(std::forward<decltype(v)>(v));
};
} // namespace detail