[libc++][print] Includes <format>. (#76333)

The overloads of `println` are specified in terms of `format`. The
function `format` is specified to work with ranges.

The implementations for `println` do not include `<format>`, but
libc++'s granularized header. This means the following example does not
work

  #include <vector>
  #include <print>

  int main() {
      std::vector<int> v{1, 2, 3};
      std::println("{}", v);
  }

(The other print functions also require this to work, they are specified
in terms of other format functions.)

Fixes: https://github.com/llvm/llvm-project/issues/71925
This commit is contained in:
Mark de Wever 2024-01-16 17:33:01 +01:00 committed by GitHub
parent a8b3deb2c8
commit 82d21814e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 102 additions and 102 deletions

View File

@ -175,8 +175,6 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
#include <__availability>
#include <__config>
#include <__exception/operations.h>
#include <__format/format_args.h>
#include <__format/format_functions.h>
#include <__fwd/ostream.h>
#include <__memory/shared_ptr.h>
#include <__memory/unique_ptr.h>
@ -188,6 +186,7 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
#include <__utility/declval.h>
#include <bitset>
#include <cstdio>
#include <format>
#include <ios>
#include <locale>
#include <new>

View File

@ -34,17 +34,11 @@ namespace std {
#include <__assert> // all public C++ headers provide the assertion handler
#include <__concepts/same_as.h>
#include <__config>
#include <__format/buffer.h>
#include <__format/format_arg_store.h>
#include <__format/format_args.h>
#include <__format/format_context.h>
#include <__format/format_error.h>
#include <__format/format_functions.h>
#include <__format/unicode.h>
#include <__system_error/system_error.h>
#include <__utility/forward.h>
#include <cerrno>
#include <cstdio>
#include <format>
#include <string>
#include <string_view>
#include <version>

View File

@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: no-filesystem
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
// XFAIL: availability-fp_to_chars-missing
// <ostream>
// The Standard does indirectly require that <ostream> includes <format>.
// However using the granularized headers so it's possible to implement
// <ostream> without <format>. This would be a non-conforming implementation.
//
// See https://github.com/llvm/llvm-project/issues/71925
#include <ostream>
#include <vector>
extern std::ostream& os;
void test() {
std::vector<int> v{1, 2, 3};
std::print(os, "{} {}", 42, v);
}

View File

@ -576,45 +576,38 @@ optional typeinfo
optional utility
optional variant
optional version
ostream array
ostream atomic
ostream bitset
ostream cmath
ostream cerrno
ostream concepts
ostream cstddef
ostream cstdint
ostream cstdio
ostream cstdlib
ostream cstring
ostream format
ostream initializer_list
ostream ios
ostream iosfwd
ostream iterator
ostream limits
ostream locale
ostream new
ostream optional
ostream print
ostream stdexcept
ostream streambuf
ostream string
ostream string_view
ostream tuple
ostream type_traits
ostream typeinfo
ostream version
print array
print cerrno
print cmath
print cstddef
print cstdint
print cstdio
print initializer_list
print limits
print locale
print new
print optional
print format
print stdexcept
print string
print string_view
print tuple
print version
queue compare
queue concepts

1 algorithm atomic
576 optional utility
577 optional variant
578 optional version
ostream array
579 ostream atomic
580 ostream bitset
581 ostream cmath ostream cerrno
582 ostream concepts
583 ostream cstddef
584 ostream cstdint
585 ostream cstdio
586 ostream cstdlib
587 ostream cstring
588 ostream format
589 ostream initializer_list
590 ostream ios
591 ostream iosfwd
592 ostream iterator
593 ostream limits
594 ostream locale
595 ostream new
ostream optional
596 ostream print
597 ostream stdexcept
598 ostream streambuf
599 ostream string
600 ostream string_view
ostream tuple
601 ostream type_traits
602 ostream typeinfo
603 ostream version
print array
604 print cerrno
print cmath
605 print cstddef
print cstdint
606 print cstdio
607 print initializer_list print format
print limits
print locale
print new
print optional
608 print stdexcept
609 print string
610 print string_view
print tuple
611 print version
612 queue compare
613 queue concepts

View File

@ -581,45 +581,38 @@ optional typeinfo
optional utility
optional variant
optional version
ostream array
ostream atomic
ostream bitset
ostream cmath
ostream cerrno
ostream concepts
ostream cstddef
ostream cstdint
ostream cstdio
ostream cstdlib
ostream cstring
ostream format
ostream initializer_list
ostream ios
ostream iosfwd
ostream iterator
ostream limits
ostream locale
ostream new
ostream optional
ostream print
ostream stdexcept
ostream streambuf
ostream string
ostream string_view
ostream tuple
ostream type_traits
ostream typeinfo
ostream version
print array
print cerrno
print cmath
print cstddef
print cstdint
print cstdio
print initializer_list
print limits
print locale
print new
print optional
print format
print stdexcept
print string
print string_view
print tuple
print version
queue compare
queue concepts

1 algorithm atomic
581 optional utility
582 optional variant
583 optional version
ostream array
584 ostream atomic
585 ostream bitset
586 ostream cmath ostream cerrno
587 ostream concepts
588 ostream cstddef
589 ostream cstdint
590 ostream cstdio
591 ostream cstdlib
592 ostream cstring
593 ostream format
594 ostream initializer_list
595 ostream ios
596 ostream iosfwd
597 ostream iterator
598 ostream limits
599 ostream locale
600 ostream new
ostream optional
601 ostream print
602 ostream stdexcept
603 ostream streambuf
604 ostream string
605 ostream string_view
ostream tuple
606 ostream type_traits
607 ostream typeinfo
608 ostream version
print array
609 print cerrno
print cmath
610 print cstddef
print cstdint
611 print cstdio
612 print initializer_list print format
print limits
print locale
print new
print optional
613 print stdexcept
614 print string
615 print string_view
print tuple
616 print version
617 queue compare
618 queue concepts

View File

@ -583,45 +583,38 @@ optional typeinfo
optional utility
optional variant
optional version
ostream array
ostream atomic
ostream bitset
ostream cmath
ostream cerrno
ostream concepts
ostream cstddef
ostream cstdint
ostream cstdio
ostream cstdlib
ostream cstring
ostream format
ostream initializer_list
ostream ios
ostream iosfwd
ostream iterator
ostream limits
ostream locale
ostream new
ostream optional
ostream print
ostream stdexcept
ostream streambuf
ostream string
ostream string_view
ostream tuple
ostream type_traits
ostream typeinfo
ostream version
print array
print cerrno
print cmath
print cstddef
print cstdint
print cstdio
print initializer_list
print limits
print locale
print new
print optional
print format
print stdexcept
print string
print string_view
print tuple
print version
queue compare
queue concepts

1 algorithm atomic
583 optional utility
584 optional variant
585 optional version
ostream array
586 ostream atomic
587 ostream bitset
588 ostream cmath ostream cerrno
589 ostream concepts
590 ostream cstddef
591 ostream cstdint
592 ostream cstdio
593 ostream cstdlib
594 ostream cstring
595 ostream format
596 ostream initializer_list
597 ostream ios
598 ostream iosfwd
599 ostream iterator
600 ostream limits
601 ostream locale
602 ostream new
ostream optional
603 ostream print
604 ostream stdexcept
605 ostream streambuf
606 ostream string
607 ostream string_view
ostream tuple
608 ostream type_traits
609 ostream typeinfo
610 ostream version
print array
611 print cerrno
print cmath
612 print cstddef
print cstdint
613 print cstdio
614 print initializer_list print format
print limits
print locale
print new
print optional
615 print stdexcept
616 print string
617 print string_view
print tuple
618 print version
619 queue compare
620 queue concepts

View File

@ -583,45 +583,38 @@ optional typeinfo
optional utility
optional variant
optional version
ostream array
ostream atomic
ostream bitset
ostream cmath
ostream cerrno
ostream concepts
ostream cstddef
ostream cstdint
ostream cstdio
ostream cstdlib
ostream cstring
ostream format
ostream initializer_list
ostream ios
ostream iosfwd
ostream iterator
ostream limits
ostream locale
ostream new
ostream optional
ostream print
ostream stdexcept
ostream streambuf
ostream string
ostream string_view
ostream tuple
ostream type_traits
ostream typeinfo
ostream version
print array
print cerrno
print cmath
print cstddef
print cstdint
print cstdio
print initializer_list
print limits
print locale
print new
print optional
print format
print stdexcept
print string
print string_view
print tuple
print version
queue compare
queue concepts

1 algorithm atomic
583 optional utility
584 optional variant
585 optional version
ostream array
586 ostream atomic
587 ostream bitset
588 ostream cmath ostream cerrno
589 ostream concepts
590 ostream cstddef
591 ostream cstdint
592 ostream cstdio
593 ostream cstdlib
594 ostream cstring
595 ostream format
596 ostream initializer_list
597 ostream ios
598 ostream iosfwd
599 ostream iterator
600 ostream limits
601 ostream locale
602 ostream new
ostream optional
603 ostream print
604 ostream stdexcept
605 ostream streambuf
606 ostream string
607 ostream string_view
ostream tuple
608 ostream type_traits
609 ostream typeinfo
610 ostream version
print array
611 print cerrno
print cmath
612 print cstddef
print cstdint
613 print cstdio
614 print initializer_list print format
print limits
print locale
print new
print optional
615 print stdexcept
616 print string
617 print string_view
print tuple
618 print version
619 queue compare
620 queue concepts

View File

@ -588,45 +588,38 @@ optional typeinfo
optional utility
optional variant
optional version
ostream array
ostream atomic
ostream bitset
ostream cmath
ostream cerrno
ostream concepts
ostream cstddef
ostream cstdint
ostream cstdio
ostream cstdlib
ostream cstring
ostream format
ostream initializer_list
ostream ios
ostream iosfwd
ostream iterator
ostream limits
ostream locale
ostream new
ostream optional
ostream print
ostream stdexcept
ostream streambuf
ostream string
ostream string_view
ostream tuple
ostream type_traits
ostream typeinfo
ostream version
print array
print cerrno
print cmath
print cstddef
print cstdint
print cstdio
print initializer_list
print limits
print locale
print new
print optional
print format
print stdexcept
print string
print string_view
print tuple
print version
queue compare
queue concepts

1 algorithm atomic
588 optional utility
589 optional variant
590 optional version
ostream array
591 ostream atomic
592 ostream bitset
593 ostream cmath ostream cerrno
594 ostream concepts
595 ostream cstddef
596 ostream cstdint
597 ostream cstdio
598 ostream cstdlib
599 ostream cstring
600 ostream format
601 ostream initializer_list
602 ostream ios
603 ostream iosfwd
604 ostream iterator
605 ostream limits
606 ostream locale
607 ostream new
ostream optional
608 ostream print
609 ostream stdexcept
610 ostream streambuf
611 ostream string
612 ostream string_view
ostream tuple
613 ostream type_traits
614 ostream typeinfo
615 ostream version
print array
616 print cerrno
print cmath
617 print cstddef
print cstdint
618 print cstdio
619 print initializer_list print format
print limits
print locale
print new
print optional
620 print stdexcept
621 print string
622 print string_view
print tuple
623 print version
624 queue compare
625 queue concepts

View File

@ -398,39 +398,31 @@ optional initializer_list
optional limits
optional new
optional version
ostream array
ostream bitset
ostream cmath
ostream cerrno
ostream cstddef
ostream cstdint
ostream cstdio
ostream cstring
ostream format
ostream initializer_list
ostream ios
ostream limits
ostream locale
ostream new
ostream optional
ostream print
ostream stdexcept
ostream streambuf
ostream string
ostream string_view
ostream tuple
ostream typeinfo
ostream version
print array
print cerrno
print cmath
print cstddef
print cstdint
print cstdio
print initializer_list
print limits
print locale
print new
print optional
print format
print stdexcept
print string
print string_view
print tuple
print version
queue compare
queue cstddef

1 algorithm climits
398 optional limits
399 optional new
400 optional version
ostream array
401 ostream bitset
402 ostream cmath ostream cerrno
403 ostream cstddef
404 ostream cstdint
405 ostream cstdio
406 ostream cstring
407 ostream format
408 ostream initializer_list
409 ostream ios
410 ostream limits
411 ostream locale
412 ostream new
ostream optional
413 ostream print
ostream stdexcept
414 ostream streambuf
415 ostream string
416 ostream string_view
417 ostream tuple ostream typeinfo
418 ostream version
print array
419 print cerrno
print cmath
420 print cstddef
print cstdint
421 print cstdio
422 print initializer_list print format
print limits
print locale
print new
print optional
423 print stdexcept
424 print string
425 print string_view
print tuple
426 print version
427 queue compare
428 queue cstddef

View File

@ -398,39 +398,31 @@ optional initializer_list
optional limits
optional new
optional version
ostream array
ostream bitset
ostream cmath
ostream cerrno
ostream cstddef
ostream cstdint
ostream cstdio
ostream cstring
ostream format
ostream initializer_list
ostream ios
ostream limits
ostream locale
ostream new
ostream optional
ostream print
ostream stdexcept
ostream streambuf
ostream string
ostream string_view
ostream tuple
ostream typeinfo
ostream version
print array
print cerrno
print cmath
print cstddef
print cstdint
print cstdio
print initializer_list
print limits
print locale
print new
print optional
print format
print stdexcept
print string
print string_view
print tuple
print version
queue compare
queue cstddef

1 algorithm climits
398 optional limits
399 optional new
400 optional version
ostream array
401 ostream bitset
402 ostream cmath ostream cerrno
403 ostream cstddef
404 ostream cstdint
405 ostream cstdio
406 ostream cstring
407 ostream format
408 ostream initializer_list
409 ostream ios
410 ostream limits
411 ostream locale
412 ostream new
ostream optional
413 ostream print
ostream stdexcept
414 ostream streambuf
415 ostream string
416 ostream string_view
417 ostream tuple ostream typeinfo
418 ostream version
print array
419 print cerrno
print cmath
420 print cstddef
print cstdint
421 print cstdio
422 print initializer_list print format
print limits
print locale
print new
print optional
423 print stdexcept
424 print string
425 print string_view
print tuple
426 print version
427 queue compare
428 queue cstddef

View File

@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: no-filesystem
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
// XFAIL: availability-fp_to_chars-missing
// <print>
// The Standard does indirectly require that <print> includes <format>. However
// using the granularized headers so it's possible to implement <print> without
// <format>. This would be a non-conforming implementation.
//
// See https://github.com/llvm/llvm-project/issues/71925
#include <print>
#include <vector>
void test() {
std::vector<int> v{1, 2, 3};
std::print("{} {}", 42, v);
}