26
26
#include < cwchar>
27
27
#include < string>
28
28
29
- #ifndef SCN_DEFAULT_LOCALE_TRUE
30
- #define SCN_DEFAULT_LOCALE_TRUE " true"
31
- #endif
32
-
33
- #ifndef SCN_DEFAULT_LOCALE_FALSE
34
- #define SCN_DEFAULT_LOCALE_FALSE " false"
35
- #endif
36
-
37
- #ifndef SCN_DEFAULT_LOCALE_DECIMAL
38
- #define SCN_DEFAULT_LOCALE_DECIMAL ' .'
39
- #endif
40
-
41
- #ifndef SCN_DEFAULT_LOCALE_SEPARATOR
42
- #define SCN_DEFAULT_LOCALE_SEPARATOR ' ,'
43
- #endif
44
-
45
- #ifndef SCN_DEFAULT_LOCALE_TRUE_WIDE
46
- #define SCN_DEFAULT_LOCALE_TRUE_WIDE L" true"
47
- #endif
48
-
49
- #ifndef SCN_DEFAULT_LOCALE_FALSE_WIDE
50
- #define SCN_DEFAULT_LOCALE_FALSE_WIDE L" false"
51
- #endif
52
-
53
- #ifndef SCN_DEFAULT_LOCALE_DECIMAL_WIDE
54
- #define SCN_DEFAULT_LOCALE_DECIMAL_WIDE L' .'
55
- #endif
56
-
57
- #ifndef SCN_DEFAULT_LOCALE_SEPARATOR_WIDE
58
- #define SCN_DEFAULT_LOCALE_SEPARATOR_WIDE L' ,'
59
- #endif
60
-
61
29
namespace scn {
62
30
SCN_BEGIN_NAMESPACE
63
31
@@ -144,38 +112,38 @@ namespace scn {
144
112
struct locale_defaults <char > {
145
113
static constexpr string_view truename ()
146
114
{
147
- return {SCN_DEFAULT_LOCALE_TRUE };
115
+ return {" true " };
148
116
}
149
117
static constexpr string_view falsename ()
150
118
{
151
- return {SCN_DEFAULT_LOCALE_FALSE };
119
+ return {" false " };
152
120
}
153
121
static constexpr char decimal_point () noexcept
154
122
{
155
- return SCN_DEFAULT_LOCALE_DECIMAL ;
123
+ return ' . ' ;
156
124
}
157
125
static constexpr char thousands_separator () noexcept
158
126
{
159
- return SCN_DEFAULT_LOCALE_SEPARATOR ;
127
+ return ' , ' ;
160
128
}
161
129
};
162
130
template <>
163
131
struct locale_defaults <wchar_t > {
164
132
static constexpr wstring_view truename ()
165
133
{
166
- return {SCN_DEFAULT_LOCALE_TRUE_WIDE };
134
+ return {L" true " };
167
135
}
168
136
static constexpr wstring_view falsename ()
169
137
{
170
- return {SCN_DEFAULT_LOCALE_FALSE_WIDE };
138
+ return {L" false " };
171
139
}
172
140
static constexpr wchar_t decimal_point () noexcept
173
141
{
174
- return SCN_DEFAULT_LOCALE_DECIMAL_WIDE ;
142
+ return L ' . ' ;
175
143
}
176
144
static constexpr wchar_t thousands_separator () noexcept
177
145
{
178
- return SCN_DEFAULT_LOCALE_SEPARATOR_WIDE ;
146
+ return L ' , ' ;
179
147
}
180
148
};
181
149
} // namespace detail
@@ -502,6 +470,15 @@ namespace scn {
502
470
503
471
// default
504
472
constexpr basic_locale_ref () = default;
473
+
474
+ // hardcoded "C", constexpr, should be preferred whenever possible
475
+ constexpr static_type get_static () const
476
+ {
477
+ return {};
478
+ }
479
+
480
+ #if !SCN_USE_STATIC_LOCALE
481
+
505
482
// nullptr = global
506
483
constexpr basic_locale_ref (const void * p) : m_payload(p) {}
507
484
@@ -515,12 +492,6 @@ namespace scn {
515
492
return m_payload != nullptr ;
516
493
}
517
494
518
- // hardcoded "C", constexpr, should be preferred whenever possible
519
- constexpr static_type get_static () const
520
- {
521
- return {};
522
- }
523
-
524
495
// hardcoded "C", not constexpr
525
496
default_type& get_default ()
526
497
{
@@ -599,6 +570,7 @@ namespace scn {
599
570
mutable detail::unique_ptr<custom_type> m_custom{nullptr };
600
571
const void * m_payload{nullptr };
601
572
default_type m_default{};
573
+ #endif
602
574
};
603
575
604
576
template <typename CharT, typename Locale>
0 commit comments