Defect report: missing exception specifications for vector::resize(size_type sz)

Defect report: missing exception specifications for vector::resize(size_type sz)

Post by Rani Sharo » Wed, 30 Mar 2011 22:07:54



In C++1x (N3090) there are two version of vector::resize - 23.3.6:
void resize(size_type sz);
void resize(size_type sz, const T& c);

The text in 23.3.6.2/12 only mentions "no effects on throw" for the
two args version of resize:
Requires: If an exception is thrown other than by the move constructor
of a non-CopyConstructible T there are no effects.

This seems like unintentional oversight since resize(size) is
semantically the same as resize(size, T()).
Additionally, the C++03 standard only specify single version of resize
with default for the second argument - 23.2.4:
void resize(size_type sz, T c = T());

Therefore not requiring same guarantees for both version of resize is
in fact a regression.

Rani
 
 
 

1. Defect report: missing exception specifications for vector::resize(size_type sz)

2. vector::resize(size_type sz, T c = T());

In the ISO/IEC 14882:2003 document, in page 490 in section 23.2.4, the
definition of the class template vector contains the following member
function declaration:
void resize(size_type sz, T c = T());

My question here is: why the second parameter type is just 'T' instead
of 'const T&' ie why doesn't the Standard declare this member function
as
void resize(size_type, const T& c = T());

But the following other member functions take 'const T&' type
parameter.

explicit vector(size_type n, const T& value = T(),
const Allocator& = Allocator());

void assign(size_type n, const T& u);
void push_back(const T& x);
iterator insert(iterator position, const T& x);

Kindly explain the reason.

Thanks
V.Subramanian

3. Defect report: Default modes missing from basic_fstream member specifications

4. Defect report: Default modes missing from basic_fstream member specifications

5. std::vector::resize and std::vector::insert (was std::vector::resize)

6. Defect Report: map::at() need a complexity specification

7. N3000 Defect - vector<bool> initializer_list constructor missing an allocator argument

8. std::string.find_first_not_of(size_type index, size_type num)

9. [Defect Report] Illegal use of "T" in std::vector<bool>

10. defect report: vector reallocation and max_size are underspecified

11. Defect Report: Why does forward_list::resize take the object to be copied by value?

12. Why can't I use vector<T1>::size_type where T1 is a template typename?

13. does vector::resize throw bad_alloc exception?

14. Defect Report: Multiple exceptions from connected shared_futu:get()?

15. vector::size_type