google / emboss

Emboss is a tool for generating code that reads and writes binary data structures.
Apache License 2.0
68 stars 21 forks source link

The C++ compiler error when using `Write()` (and related methods) on a read-only view type is confusing #100

Open reventlov opened 7 months ago

reventlov commented 7 months ago

The compiler complains about passing the wrong type to memcpy() (passing const char * as the first argument) deep inside Emboss internal template code, which is not clear to an end user.

Using std::enable_if<... backing storage is writeable> on Write() would help. Ideally, we could coerce the C++ compiler to emit a message saying to use the ...Writer type alias instead of ...View.