Classes also frequently define overloaded insertion and extraction
operators. Since there are no `compound insertion operators' the design shown
so far cannot be used when overloading these operators. Instead using
standardized member function signatures is advocated: tt(void
insert(std::ostream &out) const) to insert an object into an tt(ostream) and
tt(void extract(std::istream &in) const) to extract an object from an
tt(istream). As these functions are only used by, respectively, the insertion
and extraction operators, they can be declared in the tt(Derived) class's
private interface. Instead of declaring the insertion and extraction operators
friends of the class tt(Derived) a single tt(friend Binops<Derived>) is
specified. This allows tt(Binops<Derived>) to define private, inline tt(iWrap)
and tt(eWrap) members, merely calling, respectively, tt(Derived's insert) and
tt(extract) members:
        verb(
    template <typename Derived>
    inline void Binops<Derived>::iWrap(std::ostream &out) const
    {
        static_cast<Derived const &>(*this).insert(out);
    }
        )
    tt(Binops<Derived>) then declares the insertion and extraction operators as
its friends, allowing these operators to call, respectively, tt(iWrap) and
tt(eWrap). Note that the software engineer designing the class tt(Derived)
only has to provide a tt(friend Binops<Derived>) declaration. Here is the
implementation of the overloaded insertion operator:
        verb(
    template <typename Derived>
    std::ostream &operator<<(std::ostream &out, Binops<Derived> const &obj)
    {
        obj.iWrap(out);
        return out;
    }
        )

This completes the coverage of the essentials of a class template tt(Binops)
potentially offering binary operators and insertion/extraction operators for
any class derived from tt(Binops). Finally, as noted at the beginning of this
section, a complete implementation of a class offering addition and insertion
operators is provided in the file
tt(annotations/yo/concrete/examples/binopclasses.cc) in the annotations()'
source archive.

