0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-28 19:58:53 +02:00

ircd::util: Add involatile_cast() template convenience.

This commit is contained in:
Jason Volk 2022-03-11 18:38:07 -08:00
parent 1165d3e60c
commit 9c7ac98d9a

View file

@ -162,6 +162,28 @@ mutable_cast(T *const t)
return const_cast<type *>(t);
}
//
// Convenience involatile cast template
//
template<class T>
[[using gnu: always_inline, gnu_inline, artificial]]
extern inline typename std::remove_volatile<T>::type &
involatile_cast(T &t)
{
using type = typename std::remove_volatile<T>::type;
return const_cast<type &>(t);
}
template<class T>
[[using gnu: always_inline, gnu_inline, artificial]]
extern inline typename std::remove_volatile<T>::type *
involatile_cast(T *const t)
{
using type = typename std::remove_volatile<T>::type;
return const_cast<type *>(t);
}
//
// Test if type is shared_from_this
//