diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -140,6 +140,7 @@ __format/format_fwd.h __format/format_parse_context.h __format/format_string.h + __format/format_to_n_result.h __format/formatter.h __format/formatter_bool.h __format/formatter_char.h diff --git a/libcxx/include/__format/format_to_n_result.h b/libcxx/include/__format/format_to_n_result.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__format/format_to_n_result.h @@ -0,0 +1,34 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H +#define _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H + +#include <__config> +#include <__iterator/incrementable_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +template +struct _LIBCPP_TEMPLATE_VIS format_to_n_result { + _OutIt out; + iter_difference_t<_OutIt> size; +}; + +#endif //_LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H diff --git a/libcxx/include/format b/libcxx/include/format --- a/libcxx/include/format +++ b/libcxx/include/format @@ -278,6 +278,7 @@ #include <__format/format_fwd.h> #include <__format/format_parse_context.h> #include <__format/format_string.h> +#include <__format/format_to_n_result.h> #include <__format/formatter.h> #include <__format/formatter_bool.h> #include <__format/formatter_char.h> @@ -579,12 +580,6 @@ } #endif -template -struct _LIBCPP_TEMPLATE_VIS format_to_n_result { - _OutIt out; - iter_difference_t<_OutIt> size; -}; - template _OutIt, class... _Args> _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, string_view __fmt, diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -450,6 +450,7 @@ module format_fwd { private header "__format/format_fwd.h" } module format_parse_context { private header "__format/format_parse_context.h" } module format_string { private header "__format/format_string.h" } + module format_to_n_result { private header "__format/format_to_n_result.h } module formatter { private header "__format/formatter.h" } module formatter_bool { private header "__format/formatter_bool.h" } module formatter_char { private header "__format/formatter_char.h" } diff --git a/libcxx/test/libcxx/diagnostics/detail.headers/format/format_to_n_result.module.verify.cpp b/libcxx/test/libcxx/diagnostics/detail.headers/format/format_to_n_result.module.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/diagnostics/detail.headers/format/format_to_n_result.module.verify.cpp @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: modules-build + +// WARNING: This test was generated by 'generate_private_header_tests.py' +// and should not be edited manually. + +// expected-error@*:* {{use of private header from outside its module: '__format/format_to_n_result.h'}} +#include <__format/format_to_n_result.h>