libstdc++: Constrain formatter for thread::id [PR119918]

This patch add constraint __formatter::__char to _CharT type parameter
of formatter<thread::id, _CharT> specialization, matching the constraint
of formatting of integer/pointers that are used as native handles.

The dependency on <format> header, is changed to <bits/formatfwd.h>.
To achieve that, formatting of pointers is extracted from void const*
specialization to internal __formatter_ptr<_CharT>, that can be forward
declared.

Finally, the handle representation is now printed directly to __fc.out(),
by the formatter for handle type. To support this, internal formatters
can now be constructed from _Spec object as alternative to invoking parse
method.

	PR libstdc++/119918

libstdc++-v3/ChangeLog:

	* include/bits/formatfwd.h (__format::_Align): Moved from std/format.
	(std::__throw_format_error, __format::__formatter_str)
	(__format::__formatter_ptr): Declare.
	* include/std/format (__format::_Align): Moved to bits/formatfwd.h.
	(__formatter_int::__formatter_int): Define.
	(__format::__formatter_ptr): Extracted from formatter for const void*.
	(std::formatter<const void*, _CharT>, formatter<void*, _CharT>)
	(std::formatter<nullptr_t, _CharT>): Delegate to __formatter_ptr<_CharT>.
	* include/std/thread (std::formatter<thread::id, _CharT>): Constrain
	_CharT template parameter.
	(formatter<thread::id, _CharT>::parse): Specify default aligment, and
	qualify __throw_format_error to disable ADL.
	(formatter<thread::id, _CharT>::format): Use formatters to write directly
	to output.
	* testsuite/30_threads/thread/id/output.cc: Tests for formatting thread::id
	representing not-a-thread with padding and formattable concept.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 files changed