[Bug libstdc++/42242] vector::resize unnecessarily calls null constructor
--- Comment #1 from redi at gcc dot gnu dot org 2009-12-01 18:21 --- this is caused by the default argument to resize: void resize(size_type __new_size, value_type __x = value_type()); It would be possible to avoid the default construction by replacing that member with two overloads of resize, but I'm not sure it's worth doing. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42242
[Bug libstdc++/42242] vector::resize unnecessarily calls null constructor
--- Comment #2 from redi at gcc dot gnu dot org 2009-12-01 18:30 --- On second thoughts, it might be necessary to split it into two overloads for C++1x, because this should work: #include vector struct moveable { explicit moveable(int) { } moveable(const moveable) = delete; moveable(moveable) { } }; int main() { std::vectormoveable v; moveable m(0); v.resize(1, m); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42242
[Bug libstdc++/42242] vector::resize unnecessarily calls null constructor
--- Comment #3 from pinskia at gcc dot gnu dot org 2009-12-01 18:33 --- (In reply to comment #1) It would be possible to avoid the default construction by replacing that member with two overloads of resize, but I'm not sure it's worth doing. The C++03 standard only lists the function with the default value so this is invalid. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42242
[Bug libstdc++/42242] vector::resize unnecessarily calls null constructor
--- Comment #4 from pinskia at gcc dot gnu dot org 2009-12-01 18:34 --- (In reply to comment #2) On second thoughts, it might be necessary to split it into two overloads for C++1x, because this should work: But std::vector::resize (size_type sz, T c = T()); is the only one listed at least in C++03. What does C++1x say about that function? You might need to raise this to the C++ standards committee. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42242
[Bug libstdc++/42242] vector::resize unnecessarily calls null constructor
--- Comment #5 from redi at gcc dot gnu dot org 2009-12-01 18:37 --- (In reply to comment #2) On second thoughts, it might be necessary to split it into two overloads for C++1x, because this should work: Gah, ignore that, I'm talking rubbish and that shouldn't work Andrew, the standard would allow two overloads instead of one, see [member.functions]/2 - and the C++1x draft specifies two separate overloads. It's a reasonable enhancement request IMHO, but necessarily not a bug. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42242