#include <iostream>
#include <limits>

template <typename CharT, typename OutIt>
class bin_num_put : public std::num_put<CharT, OutIt> {
  OutIt do_put(OutIt to, std::ios_base& fmt, CharT, unsigned long long v) const
  {
    using std::begin; using std::end;    
    char narrow[] = "01";
    CharT wide[2];
    std::use_facet<std::ctype<CharT> >(fmt.getloc())
      .widen(begin(narrow), end(narrow) - 1, begin(wide));
    CharT buffer[std::numeric_limits<unsigned long long>::digits];
    std::fill(begin(buffer), end(buffer), wide[0]);
    for (CharT* e = end(buffer); v != 0; v /= 2)
      *--e = wide[v % 2];
    return std::copy(begin(buffer), end(buffer), to);
  }
  OutIt do_put(OutIt to, std::ios_base& fmt, CharT fill, long long v) const
  { return do_put(to, fmt, fill, static_cast<unsigned long long>(v)); }
};
template <typename CharT, typename traits>
std::basic_ios<CharT, traits>& bin(std::basic_ios<CharT, traits>& ios)
{
  ios.imbue(std::locale(ios.getloc(),
                        new bin_num_put<CharT, std::ostreambuf_iterator<CharT> >()));
  return ios;
}

int main()
{
  std::cout << bin << 18446744073709551615ull << std::endl;
}