|
@@ -164,6 +164,17 @@ namespace std { |
|
|
namespace rack { |
|
|
namespace rack { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Casts a primitive, preserving its bits instead of converting. */ |
|
|
|
|
|
template <typename To, typename From> |
|
|
|
|
|
To bitCast(From from) { |
|
|
|
|
|
static_assert(sizeof(From) == sizeof(To), "Types must be the same size"); |
|
|
|
|
|
To to; |
|
|
|
|
|
// This is optimized out |
|
|
|
|
|
std::memcpy(&to, &from, sizeof(From)); |
|
|
|
|
|
return to; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** C#-style property constructor |
|
|
/** C#-style property constructor |
|
|
Example: |
|
|
Example: |
|
|
|
|
|
|
|
@@ -181,6 +192,7 @@ T* construct(F f, V v, Args... args) { |
|
|
return o; |
|
|
return o; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Defers code until the scope is destructed |
|
|
/** Defers code until the scope is destructed |
|
|
From http://www.gingerbill.org/article/defer-in-cpp.html |
|
|
From http://www.gingerbill.org/article/defer-in-cpp.html |
|
|
Example: |
|
|
Example: |
|
@@ -244,6 +256,7 @@ typename C::mapped_type get(const C& m, const typename C::key_type& key, const t |
|
|
return it->second; |
|
|
return it->second; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// config |
|
|
// config |
|
|
|
|
|
|
|
|
extern const std::string APP_NAME; |
|
|
extern const std::string APP_NAME; |
|
|