Will any compiler actually ever elide these copies?
问题 Given 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; }; someone said that in Box box(Range(0.0,1.0),Range(0.0,2.0)) , the compiler can avoid copying Range objects altogether by constructing them inside box to begin with. Does any compiler actually do this? My own attempts haven't succeeded.