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

Fix address_of for overloaded operator& #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

frederick-vs-ja
Copy link
Contributor

Fixes #133.

策略:

  • 如果编译器支持 __builtin_addressof 则使用;
  • 否则,使用 SFINAE
    • 对函数使用内建 operator&
    • 对对象使用 reinterpret_cast 到字节类型再取地址的策略(与 constexpr 不兼容)。

为了避免 addressof<const int>(42) 之类取临时对象的代码通过编译,对右值提供被删除的重载(实现 LWG2598)。

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.

address_of不能获取对象的真实地址
1 participant