Arithmetic inserts of formatted output

I have a basic question about arithmetic inserts; Β§ 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 *, formatting occurs as if it were executing 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, which function performs the conversion from a pointer to a type, as Matt McNabb corrected, const void* ? For instance:

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

I'm not interested in implementation details, I just wanted to know which function produces the arithmetic result from the pointer. Is it put in the above example?

0
source share
1 answer

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

+1
source

All Articles