Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Snippets
  • Sign up now
  • Login
  • Sign in / Register
  • GROMACS GROMACS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 306
    • Issues 306
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 88
    • Merge requests 88
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GROMACS
  • GROMACSGROMACS
  • Issues
  • #3951
Closed
Open
Issue created Feb 25, 2021 by Mark Abraham@mark.j.abrahamMaintainer

Replace gmx::Any with std::any or std::variant

We should replace our use of gmx::Any with a std C++17 component, such as potentially either std::any or std::variant. Some of our use cases have a known set of types and are thus suitable for std::variant (which also avoids heap allocation).

The KeyValueTreeValue case is harder because there is a circularity of use. It can contain a KeyValueTreeArray which does contain a vector of KeyValueTreeValue. If KeyValueTreeValue would use a variant, then both would require a complete (not forward) definition of the other, which can't be done. (That issue could be worked around by introducing some heap allocation.)

std::any suits this use case (and likely uses the heap in the solution), however libstdc++ has at least one bug. KeyValueTreeObject needs to make a std::pair (to use with std::map) that contains a KeyValueTreeValue. The bug I've identified relates to being able to tell if KeyValueTreeValue is constructible when it contains a std::any and is fixed in 9.4 or 10.1 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90415). We can work around it e.g. with clang using a buggy libstdc++. But I ran into further problems with gcc 9.3 using buggy libstdc++ with KeyValueTreeArrayBuilderBase being unable to identify KeyValueTreeObject as either being move-insertable or not, in the implementation of the above-mentioned vector. gcc 10 has no problem with anything.

Unfortunately, the gmx::Any used in the KVT stuff needs to interact with the options framework. One can find the typeid of the thing contained in either gmx::Any or std::any/variant but that's not enough to transfer the contained object from one type of any or variant to another. So we can't just leave gmx::Any only for the KVT stuff and convert the rest.

Thus, until we require gcc 9.4 or higher (and libstdc++ 9.4 or higher with clang), we're stuck with gmx::Any. I'll push up a branch with my WIP for that future happy day (https://gitlab.com/gromacs/gromacs/-/tree/3951-replace-gmx-any-with-std-any).

Edited Feb 26, 2021 by Mark Abraham
Assignee
Assign to
Time tracking