共用方式為


forward_list::resize

Specifies a new size for a forward list.

void resize(size_type _Newsize);
void resize(size_type _Newsize, const Type& _Val);

Parameters

Parameter

Description

_Newsize

The number of elements in the resized forward list.

_Val

The value to use for padding.

Remarks

The member functions both ensure that the number of elements in the list henceforth is _Newsize. If it must make the controlled sequence longer, the first member function appends elements with value Type(), while the second member function appends elements with value _Val. To make the controlled sequence shorter, both member functions effectively call erase_after(begin() + _Newsize - 1, end()).

Requirements

Header: <forward_list>

Namespace: std

See Also

Reference

forward_list Class