+template<class T>
+class Remote {
+private:
+ // If we use a union, it won't work with abstract types:
+ char buffer[sizeof(T)];
+public:
+ // HACK, some code currently cast this to T* which is **not** legal.
+ void* data() { return buffer; }
+ const void* data() const { return buffer; }
+ constexpr std::size_t size() const { return sizeof(T); }
+ operator T() const {
+ static_assert(std::is_trivial<T>::value, "Cannot convert non trivial type");
+ T res;
+ std::memcpy(&res, buffer, sizeof(T));
+ return res;
+ }
+ Remote() {}
+ Remote(T const& x)
+ {
+ std::memcpy(&x, buffer, sizeof(T));
+ }
+ Remote& operator=(T const& x)
+ {
+ std::memcpy(&x, buffer, sizeof(T));
+ }
+};