Follow

c++ complaining 

In C++ you can use the address-of operator & to find the address of any lvalue. However, due to operator overloading this is not necessarily true. So what do you if you overload &?

C++, as usual, has introduced a solution for the problem it created with the standard library function std::addressof. How is this implemented, you may ask? Well, as you have to do is write the following elegant, readable, and simple snippet:

template<typename _Tp>
inline _Tp*
__addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
{
return reinterpret_cast<_Tp*>
(&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
}

this is actually a lie. function names are considered lvalues. However, if you overload a function, then the program fails to compile if you provide that name to std::addressof because C++ is a poorly designed language that makes no sense.

re: c++ complaining 

no i do not have any clue how this works at all do not ask me how this works

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.