File tree 1 file changed +17
-0
lines changed
include/psi/vm/containers
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -916,6 +916,23 @@ class [[ nodiscard, clang::trivial_abi ]] vector_impl
916
916
}
917
917
return data;
918
918
}
919
+ template <typename U>
920
+ value_type * grow_to ( this Impl & self, size_type const target_size, U && default_value )
921
+ requires std::constructible_from<T, U>
922
+ {
923
+ auto const current_size{ self.size () };
924
+ BOOST_ASSUME ( target_size >= current_size );
925
+ auto const data{ self.grow_to ( target_size, no_init ) };
926
+ auto const uninitialized_space_begin{ &data[ current_size ] };
927
+ auto const uninitialized_space_size { target_size - current_size };
928
+ try {
929
+ std::uninitialized_fill_n ( uninitialized_space_begin, uninitialized_space_size, std::forward<U>( default_value ) );
930
+ } catch (...) {
931
+ self.storage_shrink_size_to ( current_size );
932
+ throw ;
933
+ }
934
+ }
935
+
919
936
value_type * grow_by ( this Impl & self, size_type const delta, auto const init_policy )
920
937
{
921
938
return self.grow_to ( self.size () + delta, init_policy );
You can’t perform that action at this time.
0 commit comments