Bug 42573 - [C++0x] shrink_to_fit() missing
Summary: [C++0x] shrink_to_fit() missing
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.4.2
: P3 normal
Target Milestone: 4.5.0
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-01 16:05 UTC by Nicolai Josuttis
Modified: 2010-01-08 13:06 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-01-07 16:42:32


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolai Josuttis 2010-01-01 16:05:24 UTC
For vector<>, deque<>, and string<>
the new member function shrink_to_fit()
is missing.
Comment 1 Paolo Carlini 2010-01-01 17:08:01 UTC
Yeah, *a lot* of C++0x things are missing, or still incorrectly implemented, in general we are not tracking in Bugzilla each!
Comment 2 Paolo Carlini 2010-01-07 16:42:17 UTC
Ok, let's re-open this and add the basic implementation in time for gcc4.5 (C++0x mode only of course).
Comment 3 Paolo Carlini 2010-01-07 23:17:54 UTC
Nope... I went through this and came to the conclusion that a fairly good implementation has to wait for a complete resolution of N2983: the request is non-binding thus if the move constructor can throw and the type T isn't CopyConstructible the implementation should not do anything. Given the subtleties wrt throwing move constructors recently surfaced, I think we'll add this member in due course, in any case *after* having tweaked the internals of the std containers for the other traditional member functions...
Comment 4 Jonathan Wakely 2010-01-08 10:05:32 UTC
It would be conforming to add the function with an empty body ;)
Comment 5 Paolo Carlini 2010-01-08 10:29:13 UTC
Good joke and also good point Jon: I still believe that our C++0x user interfaces, even not considering the semantics, aren't yet such complete and otherwise perfect to grant that action, but all in all, if somebody wants to add the empty bodies with a BIG TODO comment in the code, I do not object...
Comment 6 Paolo Carlini 2010-01-08 10:46:02 UTC
Ok, Jon, you convinced me: I'll add the interfaces, and a very, very basic implementation for vector and deque for now, I think just do something for PODs (reminder to ourselves, change the dispatches in unitialized_* functions, etc, to use to most strict yet correct traits)
Comment 7 paolo@gcc.gnu.org 2010-01-08 13:01:43 UTC
Subject: Bug 42573

Author: paolo
Date: Fri Jan  8 13:01:24 2010
New Revision: 155733

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155733
Log:
2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/42573
	* include/bits/allocator.h (struct __shrink_to_fit): Add.
	* include/bits/stl_deque.h (deque<>::shrink_to_fit): Add.
	* include/bits/stl_vector.h (vector<>::shrink_to_fit): Likewise.
	* include/bits/stl_bvector.h (vector<bool>::shrink_to_fit): Likewise.
	* include/bits/basic_string.h (basic_string<>::shrink_to_fit):
	Likewise.
	* include/ext/vstring.h (__versa_string<>::shrink_to_fit): Likewise.
	* include/debug/deque: Add corresponding using declaration.
	* include/debug/vector: Likewise.
	* include/debug/string: Likewise.
	* include/profile/deque: Likewise.
	* include/profile/vector: Likewise.
	* config/abi/pre/gnu.ver: Export new symbols.
	* testsuite/23_containers/deque/capacity/shrink_to_fit.cc: New.
	* testsuite/23_containers/vector/capacity/shrink_to_fit.cc: Likewise.
	* testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc:
	Likewise.
	* testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc:
	Likewise.
	* testsuite/ext/vstring/capacity/shrink_to_fit.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/vector/requirements/dr438/
	constructor_2_neg.cc: Likewise.

Added:
    trunk/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc
    trunk/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc
    trunk/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc
    trunk/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc
    trunk/libstdc++-v3/testsuite/ext/vstring/capacity/shrink_to_fit.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/config/abi/pre/gnu.ver
    trunk/libstdc++-v3/include/bits/allocator.h
    trunk/libstdc++-v3/include/bits/basic_string.h
    trunk/libstdc++-v3/include/bits/stl_bvector.h
    trunk/libstdc++-v3/include/bits/stl_deque.h
    trunk/libstdc++-v3/include/bits/stl_vector.h
    trunk/libstdc++-v3/include/debug/deque
    trunk/libstdc++-v3/include/debug/string
    trunk/libstdc++-v3/include/debug/vector
    trunk/libstdc++-v3/include/ext/vstring.h
    trunk/libstdc++-v3/include/profile/deque
    trunk/libstdc++-v3/include/profile/vector
    trunk/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc
    trunk/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
    trunk/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
    trunk/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc
    trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
    trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
    trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
    trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc

Comment 8 Paolo Carlini 2010-01-08 13:06:07 UTC
Done (within the limits explained in the audit trail).