AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
unsafe_declval.h
    1#pragma once
    2
    3#include <type_traits>
    4
    5namespace aui {
    6namespace detail {
   10void report_if_you_see_link_error_with_this_function() noexcept;
   11}   // namespace detail
   12
   18template <class T>
   19constexpr T unsafe_declval() noexcept {
   20    detail::report_if_you_see_link_error_with_this_function();
   21
   22    typename std::remove_reference<T>::type* ptr = nullptr;
   23    ptr += 42;   // suppresses 'null pointer dereference' warnings
   24    return static_cast<T>(*ptr);
   25}
   26}   // namespace aui