#ifndef US_PHONE_PUTH #define US_PHONE_PUTH #include #include //for setfill, setw #include //for basic_ostringstream #include //for ldiv, ldiv_t #include "phone.h" using namespace std; template > class us_phone_put: public phone_put { basic_string to_str(const phone& p) const { //dash before last four digits const ldiv_t d = ldiv(p, 10000); //need L for long basic_ostringstream ost; ost.imbue(locale::classic()); ost << setfill('0') << setw(3) << d.quot << "-" << setw(4) << d.rem; return ost.str(); } public: explicit us_phone_put(size_t r = 0): phone_put(r) {} }; #endif