@@ -24,27 +24,6 @@ struct TFormatAnalyser
24
24
}
25
25
26
26
private:
27
- // Non-constexpr function call will terminate compilation.
28
- // Purposefully undefined and non-constexpr/consteval
29
- template <class T >
30
- static void CrashCompilerNotFormattable (std::string_view /* msg*/ )
31
- { /* Suppress "internal linkage but undefined" warning*/ }
32
- static void CrashCompilerNotEnoughArguments (std::string_view /* msg*/ )
33
- { }
34
-
35
- static void CrashCompilerTooManyArguments (std::string_view /* msg*/ )
36
- { }
37
-
38
- static void CrashCompilerWrongTermination (std::string_view /* msg*/ )
39
- { }
40
-
41
- static void CrashCompilerMissingTermination (std::string_view /* msg*/ )
42
- { }
43
-
44
- static void CrashCompilerWrongFlagSpecifier (std::string_view /* msg*/ )
45
- { }
46
-
47
-
48
27
static consteval bool Contains (std::string_view sv, char symbol)
49
28
{
50
29
return sv.find (symbol) != std::string_view::npos;
@@ -59,10 +38,6 @@ struct TFormatAnalyser
59
38
template <class TArg >
60
39
static consteval auto GetSpecifiers ()
61
40
{
62
- if constexpr (!CFormattable<TArg>) {
63
- CrashCompilerNotFormattable<TArg>(" Your specialization of TFormatArg is broken" );
64
- }
65
-
66
41
return TSpecifiers{
67
42
.Conversion = std::string_view{
68
43
std::data (TFormatArg<TArg>::ConversionSpecifiers),
@@ -103,8 +78,7 @@ struct TFormatAnalyser
103
78
if (symbol == IntroductorySymbol) {
104
79
if (currentMarkerStart + 1 != index) {
105
80
// '%a% detected'
106
- CrashCompilerWrongTermination (" You may not terminate flag sequence other than %% with \' %\' symbol" );
107
- return ;
81
+ throw " You may not terminate flag sequence other than %% with \' %\' symbol" ;
108
82
}
109
83
// '%%' detected --- skip
110
84
currentMarkerStart = -1 ;
@@ -113,9 +87,8 @@ struct TFormatAnalyser
113
87
114
88
// We are inside of marker.
115
89
if (markerCount == std::ssize (markers)) {
116
- // To many markers
117
- CrashCompilerNotEnoughArguments (" Number of arguments supplied to format is smaller than the number of flag sequences" );
118
- return ;
90
+ // Too many markers
91
+ throw " Number of arguments supplied to format is smaller than the number of flag sequences" ;
119
92
}
120
93
121
94
if (Contains (specifiers[markerCount].Conversion , symbol)) {
@@ -130,20 +103,19 @@ struct TFormatAnalyser
130
103
}
131
104
132
105
if (!Contains (specifiers[markerCount].Flags , symbol)) {
133
- CrashCompilerWrongFlagSpecifier ( " Symbol is not a valid flag specifier; See FlagSpecifiers" ) ;
106
+ throw " Symbol is not a valid flag specifier; See FlagSpecifiers" ;
134
107
}
135
108
}
136
109
137
110
if (currentMarkerStart != -1 ) {
138
111
// Runaway marker.
139
- CrashCompilerMissingTermination ( " Unterminated flag sequence detected; Use \' %%\' to type plain %" ) ;
112
+ throw " Unterminated flag sequence detected; Use \' %%\' to type plain %" ;
140
113
return ;
141
114
}
142
115
143
116
if (markerCount < std::ssize (markers)) {
144
117
// Missing markers.
145
- CrashCompilerTooManyArguments (" Number of arguments supplied to format is greater than the number of flag sequences" );
146
- return ;
118
+ throw " Number of arguments supplied to format is greater than the number of flag sequences" ;
147
119
}
148
120
149
121
// TODO(arkady-e1ppa): Consider per-type verification
0 commit comments