Listing 2

template< . . . >
class fast_string_concatenator
{
  . . . // Public interface
private:
  struct Data
  {
    struct CString
    {
      size_t          len;
      char_type const *s;
    };
    union DataRef
    {
      CString           cstring;
      char_type         ch;
      class_type  const *concat;
    };
    enum DataType
    {
        seed    // Argument was the seed type
      , single  // Argument was a single character
      , cstring // Argument was a C-string or string object
      , concat  // Argument was another concatenator
    };
    Data(string_type const &s);
    Data(char_type const *s);
    Data(char_type ch s);
    Data(class_type const &fc);
    Data(fsc_seed const &fc);

    size_t    length() const;
    char_type *write(char_type *s) const;

    DataType const  type;
    DataRef         ref;
  };
  friend struct Data;
private:
  char_type *write(char_type *s) const;
private:
  Data          m_lhs;
  Data          m_rhs;
  . . .
};