与えられた
struct Range{
Range(double from, double to) : from(from), to(to) {}
double from;
double to;
// if it matters to the compiler, we can add more fields here to make copying expensive
};
struct Box{
Box(Range x, Range y) : x(x), y(y) {}
Range x;
Range y;
};
誰かが、コンパイラは最初からオブジェクトを内部で構築することにより、オブジェクトを完全にBox box(Range(0.0,1.0),Range(0.0,2.0))
コピーすることを避けることができると言いました。Range
box
実際にこれを行うコンパイラはありますか?
私自身の試みは成功していません。