Apache C++ Standard Library User's Guide

## 26.4 An Inserter for Phone Numbers

Now let's take a look at the implementation of the inserter for our phone number class:

    std::ostream& operator<< (std::ostream& os, const PhoneNumber& pn){
      std::locale loc = os.getloc ();                           // 1
      const phone_put& ppFacet
                         = std::use_facet<phone_put> (loc);     // 2
      os << ppFacet.put(pn._cntryName,
                        pn._areaCode, pn._extension);           // 3
      return (os);
    }

`//1` | The inserter function uses the output stream's locale object (obtained via `getloc()`),
`//2` | uses the locale's phone number facet object,
`//3` | and calls the facet object's formatting service `put()`.