mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Bugfix: Avoid possible use of out-of-scope temporary.
Since std::clamp returns a reference we must be careful to not capture the return value by reference, when there is a temporary among the input parameters. For the second change (adding the explicit Scalar return type to a lambda) this is strictly speaking not necessary, as the lambda's return type is not a reference, but that is obscure so the change is just done as to clarify.
This commit is contained in:
@@ -338,7 +338,7 @@ copyToWellState(const MultisegmentWellGeneric<Scalar>& mswell,
|
||||
std::transform(segments.phase_resv_rates.begin() + (seg + 0) * well_.numPhases(),
|
||||
segments.phase_resv_rates.begin() + (seg + 1) * well_.numPhases(),
|
||||
segments.phase_holdup.begin() + (seg + 0) * well_.numPhases(),
|
||||
[tot_resv](const auto qr) { return std::clamp(qr / tot_resv, 0.0, 1.0); });
|
||||
[tot_resv](const auto qr) -> Scalar { return std::clamp(qr / tot_resv, 0.0, 1.0); });
|
||||
|
||||
// 4) Local condition flow velocities for segments other than top segment.
|
||||
if (seg > 0) {
|
||||
|
||||
Reference in New Issue
Block a user