0

I have a basic question about the arithmetic inserters; § 27.7.3.6.2/1 [ostream.inserters.arithmetic]:

When val is of type bool, long, unsigned long, long long, unsigned long long, double, long double, or const void*, the formatting conversion occurs as if it performed the following code fragment:

bool failed = use_facet<
  num_put<charT,ostreambuf_iterator<charT,traits> >
    > (getloc()).put(*this, *this, fill(), val).failed()

The question is what exact function performs the conversion from a pointer to type to, as Matt McNabb corrected, const void*? For instance:

int *ip = new int(1);
std::cout << ip; //0xaa33fa67

I'm not concerned in an implementation details, I just would like to know what function produces arithmetic result from the pointer. Is it put in the example above?

Niall
  • 30,036
  • 10
  • 99
  • 142

1 Answers1

1

There's an implicit coversion from any non-pointer to member/member function to void*. After this is passed to the stream, it passes it off to std::num_put::put() which prints it out as a generic pointer as if by using the "%p" format flag.

David G
  • 94,763
  • 41
  • 167
  • 253