#ifndef SUPPORT_H_ #define SUPPORT_H_ #include #include #include #include #include // Check assumptions made in binding code. // TODO(ry) re-enable the following // static_assert(sizeof(bool) == sizeof(uint8_t)); // static_assert(sizeof(std::unique_ptr) == sizeof(void*)); namespace support { template using uninit_t = typename std::aligned_storage::type; template class construct_in_place_helper { public: construct_in_place_helper(uninit_t& buf, Args... args) : inner_(std::forward(args)...) {} private: T inner_; }; template void construct_in_place(uninit_t& buf, Args... args) { new (&buf) construct_in_place_helper(buf, std::forward(args)...); } } // namespace support #endif // SUPPORT_H_