@@ -19,51 +19,14 @@ namespace std {
19
19
explicit format_error(const string& what_arg);
20
20
explicit format_error(const char* what_arg);
21
21
};
22
-
23
- // [format.parse.ctx], class template basic_format_parse_context
24
- template<class charT>
25
- class basic_format_parse_context {
26
- public:
27
- using char_type = charT;
28
- using const_iterator = typename basic_string_view<charT>::const_iterator;
29
- using iterator = const_iterator;
30
-
31
- private:
32
- iterator begin_; // exposition only
33
- iterator end_; // exposition only
34
- enum indexing { unknown, manual, automatic }; // exposition only
35
- indexing indexing_; // exposition only
36
- size_t next_arg_id_; // exposition only
37
- size_t num_args_; // exposition only
38
-
39
- public:
40
- constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt,
41
- size_t num_args = 0) noexcept;
42
- basic_format_parse_context(const basic_format_parse_context&) = delete;
43
- basic_format_parse_context& operator=(const basic_format_parse_context&) = delete;
44
-
45
- constexpr const_iterator begin() const noexcept;
46
- constexpr const_iterator end() const noexcept;
47
- constexpr void advance_to(const_iterator it);
48
-
49
- constexpr size_t next_arg_id();
50
- constexpr void check_arg_id(size_t id);
51
- };
52
- using format_parse_context = basic_format_parse_context<char>;
53
- using wformat_parse_context = basic_format_parse_context<wchar_t>;
54
22
}
55
23
56
24
*/
57
25
58
26
#include < __config>
59
27
#include < stdexcept>
60
- #include < string_view>
61
28
#include < version>
62
29
63
- #ifdef _LIBCPP_NO_EXCEPTIONS
64
- #include < cstdlib>
65
- #endif
66
-
67
30
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68
31
# pragma GCC system_header
69
32
#endif
@@ -84,88 +47,6 @@ public:
84
47
virtual ~format_error () noexcept ;
85
48
};
86
49
87
- _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void
88
- __throw_format_error (const char * __s) {
89
- #ifndef _LIBCPP_NO_EXCEPTIONS
90
- throw format_error (__s);
91
- #else
92
- (void )__s;
93
- _VSTD::abort ();
94
- #endif
95
- }
96
-
97
- template <class _CharT >
98
- class _LIBCPP_TEMPLATE_VIS basic_format_parse_context {
99
- public:
100
- using char_type = _CharT;
101
- using const_iterator =
102
- typename _VSTD::basic_string_view<_CharT>::const_iterator;
103
- using iterator = const_iterator;
104
-
105
- public:
106
- _LIBCPP_INLINE_VISIBILITY
107
- constexpr explicit basic_format_parse_context (
108
- _VSTD::basic_string_view<_CharT> __fmt, size_t __num_args = 0 ) noexcept
109
- : __begin_(__fmt.begin()),
110
- __end_(__fmt.end()),
111
- __indexing_(__unknown),
112
- __next_arg_id_(0 ),
113
- __num_args_(__num_args) {}
114
-
115
- basic_format_parse_context (const basic_format_parse_context&) = delete ;
116
- basic_format_parse_context&
117
- operator =(const basic_format_parse_context&) = delete ;
118
-
119
- _LIBCPP_INLINE_VISIBILITY constexpr const_iterator begin () const noexcept {
120
- return __begin_;
121
- }
122
- _LIBCPP_INLINE_VISIBILITY constexpr const_iterator end () const noexcept {
123
- return __end_;
124
- }
125
- _LIBCPP_INLINE_VISIBILITY constexpr void advance_to (const_iterator __it) {
126
- __begin_ = __it;
127
- }
128
-
129
- _LIBCPP_INLINE_VISIBILITY constexpr size_t next_arg_id () {
130
- if (__indexing_ == __manual)
131
- __throw_format_error (" Using automatic argument numbering in manual "
132
- " argument numbering mode" );
133
-
134
- if (__indexing_ == __unknown)
135
- __indexing_ = __automatic;
136
- return __next_arg_id_++;
137
- }
138
- _LIBCPP_INLINE_VISIBILITY constexpr void check_arg_id (size_t __id) {
139
- if (__indexing_ == __automatic)
140
- __throw_format_error (" Using manual argument numbering in automatic "
141
- " argument numbering mode" );
142
-
143
- if (__indexing_ == __unknown)
144
- __indexing_ = __manual;
145
-
146
- // Throws an exception to make the expression a non core constant
147
- // expression as required by:
148
- // [format.parse.ctx]/11
149
- // Remarks: Call expressions where id >= num_args_ are not core constant
150
- // expressions ([expr.const]).
151
- // Note: the Throws clause [format.parse.ctx]/10 doesn't specify the
152
- // behavior when id >= num_args_.
153
- if (_VSTD::is_constant_evaluated () && __id >= __num_args_)
154
- __throw_format_error (" Argument index outside the valid range" );
155
- }
156
-
157
- private:
158
- iterator __begin_;
159
- iterator __end_;
160
- enum _Indexing { __unknown, __manual, __automatic };
161
- _Indexing __indexing_;
162
- size_t __next_arg_id_;
163
- size_t __num_args_;
164
- };
165
-
166
- using format_parse_context = basic_format_parse_context<char >;
167
- using wformat_parse_context = basic_format_parse_context<wchar_t >;
168
-
169
50
#endif // _LIBCPP_STD_VER > 17
170
51
171
52
_LIBCPP_END_NAMESPACE_STD
0 commit comments