Add a reserve before to copy attribute (to solve a bug for index versions)

This commit is contained in:
Guillaume Damiand 2023-03-10 13:20:03 +01:00
parent 72b356d309
commit 8dc54d3c62
2 changed files with 14 additions and 0 deletions

View File

@ -288,6 +288,13 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"copy_attribute<i> called but i-attributes are disabled.");
// We need to do a reserve before the emplace in order to avoid a bug of
// invalid reference when the container is reallocated.
std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).reserve
(std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).size()+1);
typename Attribute_descriptor<i>::type res=
std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(get_attribute<i>(ah));

View File

@ -242,6 +242,13 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"copy_attribute<i> called but i-attributes are disabled.");
// We need to do a reserve before the emplace in order to avoid a bug of
// invalid reference when the container is reallocated.
std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).reserve
(std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).size()+1);
typename Attribute_descriptor<i>::type res=
std::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(get_attribute<i>(ah));