Created on 2022-01-31.00:00:00 last changed 27 months ago
Proposed resolution:
This wording is relative to N4901.
Modify [ostream.general], class template basic_ostream synopsis, as indicated:
namespace std { […] template<class traits> basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete; template<class traits> basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete; template<class charT, class traits, class T, class C> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, T C::*) = delete; }
[ 2022-08-23 Status changed: Tentatively NAD → NAD. ]
[ 2022-03-04; Reflector poll; Status changed: New → Tentatively NAD ]
Needs a paper to LEWG if anything should change here.
At present, the program
#include <iostream> struct X { void f() {} }; int main() { std::cout << &X::f; }
prints 1. That's because member pointers implicitly convert to bool, and there's operator<< overload for bool in [ostream.inserters.arithmetic].
This behavior is rarely useful. In C++20, we added deleted overloads to prevent a similar counter-intuitive output for the case in which e.g. L"str" is output to std::cout, which used to print the pointer value using the operator<< overload for const void*. We should similarly consider adding a deleted overload for member pointers.History | |||
---|---|---|---|
Date | User | Action | Args |
2022-08-23 13:55:25 | admin | set | messages: + msg12681 |
2022-03-04 14:32:50 | admin | set | messages: + msg12388 |
2022-03-04 14:32:50 | admin | set | status: new -> nad |
2022-02-05 13:04:51 | admin | set | messages: + msg12338 |
2022-01-31 00:00:00 | admin | create |