[libc++] Move numpunct into <__locale_dir/num.h> (#212465)

`numpunct` is part of the `num` family of facets, so it should live in
`num.h`.
This commit is contained in:
Nikolas Klauser 2026-07-30 11:17:44 +02:00 committed by GitHub
parent c27b35739d
commit 98cdcbae77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 117 additions and 98 deletions

View file

@ -52,6 +52,7 @@
# include <__format/write_escaped.h>
# include <__iterator/istreambuf_iterator.h>
# include <__iterator/ostreambuf_iterator.h>
# include <__locale_dir/num.h>
# include <__locale_dir/time.h>
# include <__memory/addressof.h>
# include <__type_traits/is_specialization.h>

View file

@ -32,6 +32,7 @@
#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
#include <__iterator/concepts.h>
#include <__locale_dir/num.h>
#include <__math/traits.h>
#include <__memory/allocator.h>
#include <__system_error/errc.h>

View file

@ -22,6 +22,7 @@
#include <__format/parser_std_format_spec.h>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__locale_dir/num.h>
#include <__memory/pointer_traits.h>
#include <__system_error/errc.h>
#include <__type_traits/make_unsigned.h>

View file

@ -1425,104 +1425,6 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t
}
};
// template <class charT> class numpunct
template <class _CharT>
class numpunct;
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct<char> : public locale::facet {
public:
typedef char char_type;
typedef basic_string<char_type> string_type;
explicit numpunct(size_t __refs = 0);
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type truename() const { return do_truename(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type falsename() const { return do_falsename(); }
static locale::id id;
protected:
~numpunct() override;
virtual char_type do_decimal_point() const;
virtual char_type do_thousands_sep() const;
virtual string do_grouping() const;
virtual string_type do_truename() const;
virtual string_type do_falsename() const;
char_type __decimal_point_;
char_type __thousands_sep_;
string __grouping_;
};
# if _LIBCPP_HAS_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet {
public:
typedef wchar_t char_type;
typedef basic_string<char_type> string_type;
explicit numpunct(size_t __refs = 0);
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type truename() const { return do_truename(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type falsename() const { return do_falsename(); }
static locale::id id;
protected:
~numpunct() override;
virtual char_type do_decimal_point() const;
virtual char_type do_thousands_sep() const;
virtual string do_grouping() const;
virtual string_type do_truename() const;
virtual string_type do_falsename() const;
char_type __decimal_point_;
char_type __thousands_sep_;
string __grouping_;
};
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
// template <class charT> class numpunct_byname
template <class _CharT>
class numpunct_byname;
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char> : public numpunct<char> {
public:
typedef char char_type;
typedef basic_string<char_type> string_type;
explicit numpunct_byname(const char* __nm, size_t __refs = 0);
explicit numpunct_byname(const string& __nm, size_t __refs = 0);
protected:
~numpunct_byname() override;
};
# if _LIBCPP_HAS_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> {
public:
typedef wchar_t char_type;
typedef basic_string<char_type> string_type;
explicit numpunct_byname(const char* __nm, size_t __refs = 0);
explicit numpunct_byname(const string& __nm, size_t __refs = 0);
protected:
~numpunct_byname() override;
};
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
_LIBCPP_END_NAMESPACE_STD

View file

@ -44,6 +44,104 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
// template <class charT> class numpunct
template <class _CharT>
class numpunct;
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct<char> : public locale::facet {
public:
typedef char char_type;
typedef basic_string<char_type> string_type;
explicit numpunct(size_t __refs = 0);
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type truename() const { return do_truename(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type falsename() const { return do_falsename(); }
static locale::id id;
protected:
~numpunct() override;
virtual char_type do_decimal_point() const;
virtual char_type do_thousands_sep() const;
virtual string do_grouping() const;
virtual string_type do_truename() const;
virtual string_type do_falsename() const;
char_type __decimal_point_;
char_type __thousands_sep_;
string __grouping_;
};
# if _LIBCPP_HAS_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet {
public:
typedef wchar_t char_type;
typedef basic_string<char_type> string_type;
explicit numpunct(size_t __refs = 0);
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type truename() const { return do_truename(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type falsename() const { return do_falsename(); }
static locale::id id;
protected:
~numpunct() override;
virtual char_type do_decimal_point() const;
virtual char_type do_thousands_sep() const;
virtual string do_grouping() const;
virtual string_type do_truename() const;
virtual string_type do_falsename() const;
char_type __decimal_point_;
char_type __thousands_sep_;
string __grouping_;
};
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
// template <class charT> class numpunct_byname
template <class _CharT>
class numpunct_byname;
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char> : public numpunct<char> {
public:
typedef char char_type;
typedef basic_string<char_type> string_type;
explicit numpunct_byname(const char* __nm, size_t __refs = 0);
explicit numpunct_byname(const string& __nm, size_t __refs = 0);
protected:
~numpunct_byname() override;
};
# if _LIBCPP_HAS_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> {
public:
typedef wchar_t char_type;
typedef basic_string<char_type> string_type;
explicit numpunct_byname(const char* __nm, size_t __refs = 0);
explicit numpunct_byname(const string& __nm, size_t __refs = 0);
protected:
~numpunct_byname() override;
};
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base {
static const int __num_get_buf_sz = 40;

View file

@ -378,13 +378,17 @@ format cstdint
format cstdio
format cstdlib
format cstring
format ctime
format cwchar
format cwctype
format initializer_list
format ios
format iosfwd
format limits
format optional
format ratio
format stdexcept
format streambuf
format string
format string_view
format text_encoding
@ -769,14 +773,18 @@ print cstdint
print cstdio
print cstdlib
print cstring
print ctime
print cwchar
print cwctype
print format
print initializer_list
print ios
print iosfwd
print limits
print optional
print ratio
print stdexcept
print streambuf
print string
print string_view
print text_encoding

1 algorithm cctype
378 format cstdio
379 format cstdlib
380 format cstring
381 format ctime
382 format cwchar
383 format cwctype
384 format initializer_list
385 format ios
386 format iosfwd
387 format limits
388 format optional
389 format ratio
390 format stdexcept
391 format streambuf
392 format string
393 format string_view
394 format text_encoding
773 print cstdio
774 print cstdlib
775 print cstring
776 print ctime
777 print cwchar
778 print cwctype
779 print format
780 print initializer_list
781 print ios
782 print iosfwd
783 print limits
784 print optional
785 print ratio
786 print stdexcept
787 print streambuf
788 print string
789 print string_view
790 print text_encoding

View file

@ -362,10 +362,12 @@ format cstring
format cwchar
format cwctype
format initializer_list
format ios
format iosfwd
format limits
format optional
format stdexcept
format streambuf
format string
format string_view
format text_encoding
@ -719,10 +721,12 @@ print cwchar
print cwctype
print format
print initializer_list
print ios
print iosfwd
print limits
print optional
print stdexcept
print streambuf
print string
print string_view
print text_encoding
@ -1051,10 +1055,12 @@ thread ctime
thread cwchar
thread cwctype
thread initializer_list
thread ios
thread iosfwd
thread limits
thread ratio
thread stdexcept
thread streambuf
thread string
thread string_view
thread text_encoding

1 algorithm cctype
362 format cwchar
363 format cwctype
364 format initializer_list
365 format ios
366 format iosfwd
367 format limits
368 format optional
369 format stdexcept
370 format streambuf
371 format string
372 format string_view
373 format text_encoding
721 print cwctype
722 print format
723 print initializer_list
724 print ios
725 print iosfwd
726 print limits
727 print optional
728 print stdexcept
729 print streambuf
730 print string
731 print string_view
732 print text_encoding
1055 thread cwchar
1056 thread cwctype
1057 thread initializer_list
1058 thread ios
1059 thread iosfwd
1060 thread limits
1061 thread ratio
1062 thread stdexcept
1063 thread streambuf
1064 thread string
1065 thread string_view
1066 thread text_encoding

View file

@ -33,6 +33,7 @@
// void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
#include <cassert>
#include <locale>
#include <ostream>
#include "test_macros.h"

View file

@ -88,6 +88,7 @@
#include <format>
#include <cassert>
#include <iostream>
#include <locale>
#include <vector>
#include "test_macros.h"