Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using std::optional for Property_container::get<T> #8035

Merged
merged 11 commits into from
May 22, 2024

Conversation

soesau
Copy link
Member

@soesau soesau commented Feb 15, 2024

Summary of Changes

Switching from std::pair<Property_map<T>, bool> to std::optional in Property_container::get<T>

Introducing Pair_optional_adaptor for backward compatibility which extends std::optional<T> to interface of std::pair

using Pair_optional_adaptor for Surface_mesh and Point_set_3

Release Management

  • Affected package(s): Point_set_3, Surface_mesh, STL_Extension

Copy link
Member

@lrineau lrineau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class Pair_optional_adaptor<T> has four data members:

  • its base class, of type std::optional<T>,
  • T &first and bool second for the compatibility with std::pair<T, bool>,
  • and t_storage (I am not sure why it is an union instead of a plain T).

That makes that class source-incompatible with:

auto [pmap, ok] = point.get<Foo>("bar");

See live on compiler explorer: https://godbolt.org/z/3xY6qzPTq

@lrineau
Copy link
Member

lrineau commented Feb 15, 2024

I am in favor of a real breaking change:

  • change the API of CGAL::Property_container (undocumented anyway),

  • In Surface_mesh.h, add:

    • vertex_property_map,
    • halfedge_property_map,
    • edge_property_map, and
    • face_property_map,

    with the new API, and keep the old property_map,

  • a breaking change in Point_set_3.h.

@soesau
Copy link
Member Author

soesau commented Feb 16, 2024

* and `t_storage` (I am not sure why it is an union instead of a plain `T`).

I used the union originally to avoid construction of T in case there is no default constructor. Sebastien mentioned already that T will be some lightweight object anyway that has to be default constructible for being put into a pair.

The PR is still WIP. I made it work locally for Surface_mesh and Point_set_3 and then created the PR to see if this works in the CI.

So, I'll remove the union and switch to a plain T.

@sloriot
Copy link
Member

sloriot commented Feb 26, 2024

We decided during meeting to break the compatibility and use std::optional directly.

@sloriot sloriot added the rm only: release blocker For the release team only: the next release requires this issue/PR to be solved/merge label Apr 30, 2024
@sloriot
Copy link
Member

sloriot commented Apr 30, 2024

@soesau Note that this PR is a release blocker and it should be updated following the discussion we had with @lrineau and @afabri

@lrineau
Copy link
Member

lrineau commented May 2, 2024

@sloriot, in a message dated Feb 2024:

We decided during meeting to break the compatibility and use std::optional directly.

@sloriot, yesterday:

@soesau Note that this PR is a release blocker and it should be updated following the discussion we had with @lrineau and @afabri

@sloriot, why is it release blocker?

@soesau If this PR is really blocking the next release, then we should hurry. Do you need help on it?

@sloriot
Copy link
Member

sloriot commented May 2, 2024

The API change is possible thanks to std::optional that is introduced in CGAL APIs with CGAL 6.0, and Orthtree is already using it for its dynamic property system.

@soesau soesau force-pushed the Surface_mesh-optional_for_properties-GF branch from 23cc636 to a873482 Compare May 13, 2024 14:11
@lrineau lrineau added this to the 6.0-beta milestone May 14, 2024
@soesau
Copy link
Member Author

soesau commented May 14, 2024

This class Pair_optional_adaptor<T> has four data members:

  • its base class, of type std::optional<T>,
  • T &first and bool second for the compatibility with std::pair<T, bool>,
  • and t_storage (I am not sure why it is an union instead of a plain T).

That makes that class source-incompatible with:

auto [pmap, ok] = point.get<Foo>("bar");

See live on compiler explorer: https://godbolt.org/z/3xY6qzPTq

We decided for a breaking change, thus there will be no adaptor.

Surface_mesh/include/CGAL/draw_surface_mesh.h Outdated Show resolved Hide resolved
@sloriot
Copy link
Member

sloriot commented May 22, 2024

Successfully tested in CGAL-6.0-Ic-245

@lrineau lrineau added the rm only: ready for master For the release team only: that indicates that a PR is about to be merged in 'master' label May 22, 2024
@lrineau lrineau merged commit 8135785 into CGAL:master May 22, 2024
9 checks passed
@lrineau lrineau removed the rm only: ready for master For the release team only: that indicates that a PR is about to be merged in 'master' label May 22, 2024
@lrineau lrineau self-assigned this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Modern C++ (C++11 and later) Pkg::Point_set_3 Pkg::Surface_mesh rm only: release blocker For the release team only: the next release requires this issue/PR to be solved/merge Tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants