Created ComponentWrapperFactory to make test mocking easier and manual component registration a little less painful
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#ifndef Util_Any_h__
|
||||
#define Util_Any_h__
|
||||
|
||||
#include <memory>
|
||||
|
||||
struct Any
|
||||
{
|
||||
Any() { }
|
||||
|
||||
template <typename T>
|
||||
Any(const T& value)
|
||||
{
|
||||
Data = std::shared_ptr<char>(new char[sizeof(T)]);
|
||||
Size = sizeof(T);
|
||||
memcpy(Data.get(), &value, Size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Any(T&& value)
|
||||
{
|
||||
Data = std::shared_ptr<char>(new char[sizeof(T)]);
|
||||
Size = sizeof(T);
|
||||
memcpy(Data.get(), &value, Size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Any& operator=(const T& value)
|
||||
{
|
||||
return Any(value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Any& operator=(T&& value)
|
||||
{
|
||||
return Any(value);
|
||||
}
|
||||
|
||||
std::shared_ptr<char> Data = nullptr;
|
||||
std::size_t Size = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user