Section 19.3 presents a string representation in a chapter whose main focus is operator overloading, specifically the special operators [] , ->, and (). It implements copy_from() as an ancillary function as follows:
void String::copy_from(const String &x)
    // make *this a copy of x
{
    if (x.sz <= short_max)
    {
        memcpy(this, &x, sizeof(x);
        ptr = ch;
    }
    else
    {
        ptr = expand(x.ptr, x.sz+1);
        sz = x.sz;
        space = 0;
    }
}
The class interface looks like this:
#ifndef STRING_EXERCISE_H
#define STRING_EXERCISE_H
namespace simple_string
{
    class String;
    char *expand(const char *ptr, int n);
}
class String
{
    public:
        String(); // default constructor x{""}
        explicit String(const char *p); // constructor from C-style string
        String(const String &s); // copy constructor
        String &operator=(const String& s); // copy assignment
        String(String &&s) // move constructor
        String &operator=(String &&s) // move assignement
        ~String() // destructor
        char &operator[](int n); // unchecked element access
        char operator[](int n) const;
        char &at(int n); // checked element access
        char at(int n) const;
        String &operator+=(char c) // add char c to the end
        const char *c_str(); // c-style string access
        const char *c_str() const;
        int size() const; // number of elements
        int capacity() const; // elements plus available space
    private:
        static const short short_max = 15;
        int sz;
        char *ptr;
        union
        {
            int space; // unused allocated space
            char ch[short_max+1]; // leave space for terminating 0
        };
        void check(int n) const; // range check
        void copy_from(const String &x);
        void move_from(String &x);
}
#endif
How can String::copy_from() use memcpy() to copy the class? I thought the class copied had to be trivially copyable (which it is not, because String has user-defined constructors, copy operations, move operations, and destructors). 
 
     
    