//======================================================================= // Copyright Baptiste Wicht 2013-2016. // Distributed under the terms of the MIT License. // (See accompanying file LICENSE or copy at // http://www.opensource.org/licenses/MIT) //======================================================================= #ifndef MEMORY_H #define MEMORY_H #include "enable_if.hpp" #include "utility.hpp" namespace std { template< class T > T* addressof(T& arg){ return reinterpret_cast( &const_cast( reinterpret_cast(arg))); } template struct has_overloaded_addressof { template static constexpr bool has_overload(...) { return false; } template ().operator&()) > static constexpr bool has_overload(bool) { return true; } constexpr static bool value = has_overload(true); }; template constexpr typename std::disable_if_t::value, T*> static_addressof(T& ref){ return &ref; } template constexpr typename std::enable_if_t::value, T*> static_addressof(T& ref){ return std::addressof(ref); } } //end of namespace std #endif