Skip to content
Snippets Groups Projects
Commit 727c0348 authored by Carsten Gräser's avatar Carsten Gräser
Browse files

[!689] Impove Std::variant implementation

Merge branch 'feature/improve-std-variant' into 'master'

ref:core/dune-common This fixes several bugs/incompatibilities and makes the
code (hopefully) a little more robust and better to understand. It's the
result of the discussion with @lasse.hinrichsen.

This should also fix the problem in [core/dune-localfunctions!113]

-   Remove explicit Buffer class and use aligned_storage directly
-   Use a single TypeStorage implementation for all types
-   Rename variant_union_ to \`VariadicUnion\*
-   Clean up interfaces and implementation of TypeStorage and VariadicUnion
    -   Only allow (default) construction of empty objects
    -   Only allow move assignment. The rhs must be empty, but this can
        neither be checked statically nor dynamically.
    -   All construction and assignment is done using special construct() and
        assign() methods.
    -   Destruction is only done using the destruct() method.
-   Impl::variant_ does no longer rely on standard construction and assignment
    operators (despite the two exceptions) but uses the new special methods

This fixes several bugs and incompatibilities of the old implementation:

-   Non-trivial types are no longer copied binary.
-   Destructors are now called properly.
-   Copy/move assignment now decays to copy/move assignment of the stored
    value if it already has the target type.
-   Unnecessary copies are avoided.

See merge request [core/dune-common!689]

  [core/dune-localfunctions!113]: gitlab.dune-project.org/core/dune-localfunctions/merge_requests/113
  [core/dune-common!689]: gitlab.dune-project.org/core/dune-common/merge_requests/689
parents df9583f7 7d2fa8c3
Branches
Tags
Loading
Checking pipeline status
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment