About a month ago, I got an interesting pull request for lexy, my new parser combinator library. It fixed a seemingly weird issue relating trivially copyable types and special member function of classes containing unions. While digging into it, I learned a lot about trivial special member functions and made a somewhat surprising realization:
Just because a class is
std::is_trivially_copyable does not mean the class is actually
std::is_trivially_copy_constructible or even
you can have classes that you can’t copy, but they’re still trivially copyable,
and classes where the copy constructor can do arbitrary amounts of non-trivial work, but they’re nonetheless trivially copyable!
Let me explain.» read more »