Why I can't take the address of the std::addressof
when I explicitly specify the type?
To make it more weird, when I c/p the implementation from cppreference I can take address of that function.
#include <memory>
template<typename T>
void templ_fn();
template<class T>
typename std::enable_if<std::is_object<T>::value, T*>::type xaddressof(T& arg) noexcept
{
return reinterpret_cast<T*>(
&const_cast<char&>(
reinterpret_cast<const volatile char&>(arg)));
}
template<class T>
typename std::enable_if<!std::is_object<T>::value, T*>::type xaddressof(T& arg) noexcept
{
return &arg;
}
int main() {
auto fn_1 = xaddressof<int>; // works
(void) fn_1;
auto fn_a = std::addressof<int>; // does not work
(void) fn_a;
}
note: I know it may be illegal to do this, since function is in std::
, but I care about language/implementation limitations, not UB since I am doing something evil.