22 #ifndef NDN_CXX_UTIL_BACKPORTS_HPP
23 #define NDN_CXX_UTIL_BACKPORTS_HPP
25 #include <type_traits>
28 #include <boost/assert.hpp>
29 #include <boost/predef/compiler/clang.h>
30 #include <boost/predef/compiler/gcc.h>
31 #include <boost/predef/compiler/visualc.h>
39 #if __cpp_lib_to_underlying >= 202102L
43 [[nodiscard]] constexpr std::underlying_type_t<T>
47 static_assert(std::is_enum_v<T>);
48 return static_cast<std::underlying_type_t<T>
>(val);
57 # define NDN_CXX_UNREACHABLE BOOST_ASSERT(false)
58 #elif __cpp_lib_unreachable >= 202202L
59 # define NDN_CXX_UNREACHABLE std::unreachable()
61 # define NDN_CXX_UNREACHABLE ::ndn::detail::unreachable()
63 [[noreturn]]
inline void
66 #if BOOST_COMP_GNUC || BOOST_COMP_CLANG
67 __builtin_unreachable();
constexpr std::underlying_type_t< T > to_underlying(T val) noexcept