mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 15:00:51 +01:00
ircd::util: Add involatile_cast() template convenience.
This commit is contained in:
parent
1165d3e60c
commit
9c7ac98d9a
1 changed files with 22 additions and 0 deletions
|
@ -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
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue