HandmadeHero/project/platform/generics.hpp

22 lines
582 B
C++
Raw Normal View History

2023-09-17 18:20:11 -07:00
#pragma once
template< class Type >
void swap( Type& a, Type& b )
{
Type
temp = a;
a = b;
b = temp;
}
#define Zero( type ) tmpl_zero<type>()
template< class Type >
constexpr Type tmpl_zero();
2023-10-28 14:10:30 -07:00
// Custom casting trait for when you cannot define an implicit cast ergonomically.
#define cast( type, obj ) tmpl_cast<type, decltype(obj)>( obj )
template< class Type, class OtherType >
constexpr Type tmpl_cast( OtherType obj ) {
static_assert( false, "No overload templated cast defined for type combination. Define this using an overload of tmpl_cast specialization." );
}