QuickCppLib  0.10
Eliminate all the tedious hassle when making state-of-the-art C++ 14 - 23 libraries!
quickcpplib::_xxx::bit_cast Namespace Reference

Namespaces

 detail
 
 traits
 Namespace for user specialised traits.
 

Functions

template<class To , class From , typename std::enable_if<(detail::is_bit_castable< To, From >::value &&detail::is_static_castable< To, From >::value &&!detail::is_union_castable< To, From >::value), bool >::type = true>
constexpr To bit_cast (const From &from, detail::static_cast_overload={}) noexcept
 Bit cast emulation chosen if types are move relocating or trivally copyable, have identical size, and are statically castable. Constexpr. More...
 
template<class To , class From , typename std::enable_if<(detail::is_bit_castable< To, From >::value &&!detail::is_static_castable< To, From >::value &&detail::is_union_castable< To, From >::value), bool >::type = true>
constexpr To bit_cast (const From &from, detail::union_cast_overload={}) noexcept
 Bit cast emulation chosen if types are move relocating or trivally copyable, have identical size, and are union castable. Constexpr. More...
 
template<class To , class From , typename std::enable_if<(detail::is_bit_castable< To, From >::value &&!detail::is_static_castable< To, From >::value &&!detail::is_union_castable< To, From >::value), bool >::type = true>
To bit_cast (const From &from, detail::memmove_overload={}) noexcept
 Bit cast emulation chosen if an array of types which are move relocating or trivally copyable, and have identical size. NOT constexpr. More...
 

Function Documentation

◆ bit_cast() [1/3]

template<class To , class From , typename std::enable_if<(detail::is_bit_castable< To, From >::value &&detail::is_static_castable< To, From >::value &&!detail::is_union_castable< To, From >::value), bool >::type = true>
constexpr To quickcpplib::_xxx::bit_cast::bit_cast ( const From &  from,
detail::static_cast_overload  = {} 
)
inlineconstexprnoexcept

Bit cast emulation chosen if types are move relocating or trivally copyable, have identical size, and are statically castable. Constexpr.

121  {}) noexcept
122  {
123  return static_cast<To>(from);
124  }

◆ bit_cast() [2/3]

template<class To , class From , typename std::enable_if<(detail::is_bit_castable< To, From >::value &&!detail::is_static_castable< To, From >::value &&detail::is_union_castable< To, From >::value), bool >::type = true>
constexpr To quickcpplib::_xxx::bit_cast::bit_cast ( const From &  from,
detail::union_cast_overload  = {} 
)
inlineconstexprnoexcept

Bit cast emulation chosen if types are move relocating or trivally copyable, have identical size, and are union castable. Constexpr.

133  {}) noexcept
134  {
135  return detail::bit_cast_union<To, From>{from}.target;
136  }

◆ bit_cast() [3/3]

template<class To , class From , typename std::enable_if<(detail::is_bit_castable< To, From >::value &&!detail::is_static_castable< To, From >::value &&!detail::is_union_castable< To, From >::value), bool >::type = true>
To quickcpplib::_xxx::bit_cast::bit_cast ( const From &  from,
detail::memmove_overload  = {} 
)
inlinenoexcept

Bit cast emulation chosen if an array of types which are move relocating or trivally copyable, and have identical size. NOT constexpr.

145  {}) noexcept
146  {
147  detail::bit_cast_union<To, From> ret;
148  memmove(&ret.source, &from, sizeof(ret.source));
149  return ret.target;
150  }