mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 05:04:27 +02:00
refactor: use perfect forwarding for make functions
Addresses https://github.com/mpusz/units/pull/261#discussion_r597131272.
This commit is contained in:
committed by
Mateusz Pusz
parent
c61b8643d7
commit
234337d310
@@ -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
|
||||
|
@@ -34,9 +34,9 @@ namespace units {
|
||||
namespace detail {
|
||||
|
||||
template<Kind K>
|
||||
inline constexpr auto make_quantity_kind_fn = [](auto q) {
|
||||
using Q = decltype(q);
|
||||
return quantity_kind<K, typename Q::unit, typename Q::rep>(std::move(q));
|
||||
inline constexpr auto make_quantity_kind_fn = [](auto&& q) {
|
||||
using Q = std::remove_reference_t<decltype(q)>;
|
||||
return quantity_kind<K, typename Q::unit, typename Q::rep>(std::forward<decltype(q)>(q));
|
||||
};
|
||||
|
||||
template<QuantityKind QK>
|
||||
|
Reference in New Issue
Block a user