相关疑难解决方法(0)

put_money是否按值或引用保留其参数?

以下是否调用未定义的行为?

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <experimental/iterator>

int main() {
    long double values[] = {1, 2, 3};
    std::transform(
        std::begin(values), std::end(values),
        std::experimental::make_ostream_joiner(std::cout, ", "),
        [](long double v) {
            return std::put_money(v + 1);
        }
    );
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我担心的是会return std::put_money(v + 1)返回对临时目录的引用v + 1。

c++ undefined-behavior iomanip

7
推荐指数
1
解决办法
152
查看次数

标签 统计

c++ ×1

iomanip ×1

undefined-behavior ×1