Commit 0c31658d authored by Sylvain Thery's avatar Sylvain Thery

add easy type conversions ..continue

parent 6dbae9b2
......@@ -26,6 +26,7 @@
#define __CONVERTTYPE_H_
#include <assert.h>
#include <vector>
namespace CGoGN {
......@@ -85,6 +86,22 @@ inline const OUT* convertPtr(const IN* vec)
template <typename OUT, typename IN>
inline std::vector<OUT>& convertVector(std::vector<IN>& vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return *(reinterpret_cast< std::vector<OUT>* >(&vec));
}
template <typename OUT, typename IN>
inline const std::vector<OUT>& convertVector(const std::vector<IN>& vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return *(reinterpret_cast< const std::vector<OUT>* >(&vec));
}
} // namespace Utils
} // namespace CGoGN
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment