Skip to content
Snippets Groups Projects
Forked from Core Modules / dune-common
Source project has a limited visibility.
  • Steffen Müthing's avatar
    7623a530
    [Utility] Add infrastructure to handle operator->() for both lvalues and proxies · 7623a530
    Steffen Müthing authored
    If an iterator facade (like entity iterators) wants to allow the
    embedded implementation to return either an (internally stored)
    reference or a temporary object and expose these two behaviors to enable
    performance optimizations, operator->() needs special handling: If the
    implementation returns a reference, operator->() in the facade can
    simply return the address of the referenced object, but if the returned
    object is a temporary, we need to capture and store it in a helper
    object to make sure it outlives the member access.
    
    This patch adds a little helper function that tansparently handles both
    cases.
    7623a530
    History
    [Utility] Add infrastructure to handle operator->() for both lvalues and proxies
    Steffen Müthing authored
    If an iterator facade (like entity iterators) wants to allow the
    embedded implementation to return either an (internally stored)
    reference or a temporary object and expose these two behaviors to enable
    performance optimizations, operator->() needs special handling: If the
    implementation returns a reference, operator->() in the facade can
    simply return the address of the referenced object, but if the returned
    object is a temporary, we need to capture and store it in a helper
    object to make sure it outlives the member access.
    
    This patch adds a little helper function that tansparently handles both
    cases.