Skip to content

address_of不能获取对象的真实地址 #133

@zgjsxx

Description

@zgjsxx

// 获取对象地址

template <class Tp>
constexpr Tp* address_of(Tp& value) noexcept
{
  return &value;
}

上述代码用于获取对象的真实地址,但是在重载operator&时,上述代码是不work的,下面是我的一个验证:

https://godbolt.org/z/cPd1WMx7h

可能需要使用std::addressof进行修复

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions