samedi 23 mars 2019

Why exception specifiers on overloaded operators '<<' doesn't work to any std::ostream object, but does on those defined in the library?

See this image to understand this post: https://i.stack.imgur.com/VyXjr.jpg

The 'declval()' function "generates a pseudo compile time object" of a given type, even if they are not really contructible. So 'declval()' should produce another object like std::cout, in which the overloaded operator in line 21 should work at compile time (but it doesn't).

I realised that is also works to std::clog and std::cerr, both variable of ostream type.

It should just compile. I mean the exception especifier should be the same to any ostream object, not only for these three obviously.

Aucun commentaire:

Enregistrer un commentaire