summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/putil.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/plib/putil.h')
-rw-r--r--src/lib/netlist/plib/putil.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/netlist/plib/putil.h b/src/lib/netlist/plib/putil.h
index 20ea01e890e..8ceec3d7151 100644
--- a/src/lib/netlist/plib/putil.h
+++ b/src/lib/netlist/plib/putil.h
@@ -249,6 +249,24 @@ namespace plib
list_t m_collection;
};
+ /// \brief copy type S to type D byte by byte
+ ///
+ /// The purpose of this copy function is to suppress compiler warnings.
+ /// Use at your own risk. This is dangerous.
+ ///
+ /// \param s Source object
+ /// \param d Destination object
+ /// \tparam S Type of source object
+ /// \tparam D Type of destination object
+ template <typename S, typename D>
+ void reinterpret_copy(S &s, D &d)
+ {
+ static_assert(sizeof(D) >= sizeof(S), "size mismatch");
+ auto *dp = reinterpret_cast<std::uint8_t *>(&d);
+ const auto *sp = reinterpret_cast<std::uint8_t *>(&s);
+ std::copy(sp, sp + sizeof(S), dp);
+ }
+
namespace util
{
pstring basename(const pstring &filename, const pstring &suffix = "");