Skip to content

Conversation

@mingxwa
Copy link
Member

@mingxwa mingxwa commented Jul 1, 2024

Motivation

Dereferencing a pointer with std::to_address() is feasible, but throws away cv-ref qualifiers. It is acceptable in many cases, but has certain limitations comparing to std::move_only_function (C++23) and std::copyable_function (C++26). Therefore, we have made a major decision to switch from std::to_address() to operator* when dereferencing a pointer that is potentially qualified. Consequently, we also decided to remove the direction semantics in reflection types (added in #121) because the result type of operator* relies on the qualifier of a pointer.

Changes

  • Revised semantics of concept facade.
  • Removed constraints on reflection types.
  • Moved check for field static constexpr bool is_direct from dispatch types to convention types.
  • Changed dependent type of proxy_invoke from the combination of dispatch and overload types into one convention type.
  • Changed dependent type of access_proxy from an instantiation of proxy into one facade type.
  • Added operator* to proxy.
  • Added operator* to the 3 pointer implementations: inplace_ptr, allocated_ptr and compact_ptr.
  • Added another two APIs in facade_builder: add_indirect_convention and add_direct_convention. The existing add_convention is equivalent to add_indirect_convention.
  • Removed DIRECT and INDIRECT macros of dispatch definition introduced in Implement indirection syntax #121, specifically:
PRO_DEF_INDIRECT_MEM_DISPATCH(__NAME, ...)
PRO_DEF_DIRECT_MEM_DISPATCH(__NAME, ...)
PRO_DEF_INDIRECT_FREE_DISPATCH(__NAME, ...)
PRO_DEF_DIRECT_FREE_DISPATCH(__NAME, ...)
PRO_DEF_INDIRECT_OPERATOR_DISPATCH(__NAME, ...)
PRO_DEF_DIRECT_OPERATOR_DISPATCH(__NAME, ...)
PRO_DEF_INDIRECT_PREFIX_OPERATOR_DISPATCH(__NAME, ...)
PRO_DEF_DIRECT_PREFIX_OPERATOR_DISPATCH(__NAME, ...)
PRO_DEF_INDIRECT_POSTFIX_OPERATOR_DISPATCH(__NAME, ...)
PRO_DEF_DIRECT_POSTFIX_OPERATOR_DISPATCH(__NAME, ...)
PRO_DEF_INDIRECT_CONVERSION_DISPATCH(__NAME, ...)
PRO_DEF_DIRECT_CONVERSION_DISPATCH(__NAME, ...)

@mingxwa mingxwa added this to the P3086R3 milestone Jul 1, 2024
@mingxwa mingxwa requested review from guominrui and tian-lt July 1, 2024 15:46
@mingxwa mingxwa self-assigned this Jul 1, 2024
guominrui
guominrui previously approved these changes Jul 2, 2024
@tian-lt tian-lt merged commit 26483ac into microsoft:main Jul 3, 2024
@mingxwa mingxwa deleted the user/mingxwa/move-direction-semantics branch July 15, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants