Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
dc94010f
Commit
dc94010f
authored
Apr 16, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove char_traits (#1117)
parent
397e8dd9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
63 deletions
+9
-63
include/fmt/format-inl.h
include/fmt/format-inl.h
+4
-13
include/fmt/format.h
include/fmt/format.h
+0
-34
src/format.cc
src/format.cc
+0
-16
test/format-test.cc
test/format-test.cc
+5
-0
No files found.
include/fmt/format-inl.h
View file @
dc94010f
...
...
@@ -254,21 +254,12 @@ template <> FMT_FUNC int count_digits<4>(internal::uintptr_t n) {
}
template
<
typename
T
>
int
char_traits
<
char
>::
format_float
(
char
*
buf
,
std
::
size_t
size
,
const
char
*
format
,
int
precision
,
T
value
)
{
int
format_float
(
char
*
buf
,
std
::
size_t
size
,
const
char
*
format
,
int
precision
,
T
value
)
{
return
precision
<
0
?
FMT_SNPRINTF
(
buf
,
size
,
format
,
value
)
:
FMT_SNPRINTF
(
buf
,
size
,
format
,
precision
,
value
);
}
template
<
typename
T
>
int
char_traits
<
wchar_t
>::
format_float
(
wchar_t
*
buf
,
std
::
size_t
size
,
const
wchar_t
*
format
,
int
precision
,
T
value
)
{
return
precision
<
0
?
FMT_SWPRINTF
(
buf
,
size
,
format
,
value
)
:
FMT_SWPRINTF
(
buf
,
size
,
format
,
precision
,
value
);
}
template
<
typename
T
>
const
char
basic_data
<
T
>::
DIGITS
[]
=
"0001020304050607080910111213141516171819"
...
...
@@ -758,8 +749,8 @@ void sprintf_format(Double value, internal::buffer<char>& buf,
for
(;;)
{
std
::
size_t
buffer_size
=
buf
.
capacity
();
start
=
&
buf
[
0
];
int
result
=
internal
::
char_traits
<
char
>::
format_float
(
start
,
buffer_size
,
format
,
spec
.
precision
,
value
);
int
result
=
format_float
(
start
,
buffer_size
,
format
,
spec
.
precision
,
value
);
if
(
result
>=
0
)
{
unsigned
n
=
internal
::
to_unsigned
(
result
);
if
(
n
<
buf
.
capacity
())
{
...
...
include/fmt/format.h
View file @
dc94010f
...
...
@@ -552,40 +552,6 @@ typedef basic_memory_buffer<wchar_t> wmemory_buffer;
namespace
internal
{
template
<
typename
Char
>
struct
char_traits
;
template
<
>
struct
char_traits
<
char
>
{
// Formats a floating-point number.
template
<
typename
T
>
FMT_API
static
int
format_float
(
char
*
buffer
,
std
::
size_t
size
,
const
char
*
format
,
int
precision
,
T
value
);
};
template
<
>
struct
char_traits
<
wchar_t
>
{
template
<
typename
T
>
FMT_API
static
int
format_float
(
wchar_t
*
buffer
,
std
::
size_t
size
,
const
wchar_t
*
format
,
int
precision
,
T
value
);
};
#if FMT_USE_EXTERN_TEMPLATES
extern
template
int
char_traits
<
char
>
::
format_float
<
double
>
(
char
*
buffer
,
std
::
size_t
size
,
const
char
*
format
,
int
precision
,
double
value
);
extern
template
int
char_traits
<
char
>
::
format_float
<
long
double
>
(
char
*
buffer
,
std
::
size_t
size
,
const
char
*
format
,
int
precision
,
long
double
value
);
extern
template
int
char_traits
<
wchar_t
>
::
format_float
<
double
>
(
wchar_t
*
buffer
,
std
::
size_t
size
,
const
wchar_t
*
format
,
int
precision
,
double
value
);
extern
template
int
char_traits
<
wchar_t
>
::
format_float
<
long
double
>
(
wchar_t
*
buffer
,
std
::
size_t
size
,
const
wchar_t
*
format
,
int
precision
,
long
double
value
);
#endif
// A workaround for std::string not having mutable data() until C++17.
template
<
typename
Char
>
inline
Char
*
get_data
(
std
::
basic_string
<
Char
>&
s
)
{
return
&
s
[
0
];
...
...
src/format.cc
View file @
dc94010f
...
...
@@ -28,16 +28,6 @@ template FMT_API void internal::buffer<char>::append(const char*, const char*);
template
FMT_API
void
internal
::
arg_map
<
format_context
>
::
init
(
const
basic_format_args
<
format_context
>
&
args
);
template
FMT_API
int
internal
::
char_traits
<
char
>
::
format_float
(
char
*
,
std
::
size_t
,
const
char
*
,
int
,
double
);
template
FMT_API
int
internal
::
char_traits
<
char
>
::
format_float
(
char
*
,
std
::
size_t
,
const
char
*
,
int
,
long
double
);
template
FMT_API
std
::
string
internal
::
vformat
<
char
>(
string_view
,
basic_format_args
<
format_context
>);
...
...
@@ -60,12 +50,6 @@ template FMT_API void internal::buffer<wchar_t>::append(const wchar_t*,
template
FMT_API
void
internal
::
arg_map
<
wformat_context
>
::
init
(
const
basic_format_args
<
wformat_context
>
&
);
template
FMT_API
int
internal
::
char_traits
<
wchar_t
>
::
format_float
(
wchar_t
*
,
std
::
size_t
,
const
wchar_t
*
,
int
,
double
);
template
FMT_API
int
internal
::
char_traits
<
wchar_t
>
::
format_float
(
wchar_t
*
,
std
::
size_t
,
const
wchar_t
*
,
int
,
long
double
);
template
FMT_API
std
::
wstring
internal
::
vformat
<
wchar_t
>(
wstring_view
,
basic_format_args
<
wformat_context
>
);
FMT_END_NAMESPACE
test/format-test.cc
View file @
dc94010f
...
...
@@ -2538,3 +2538,8 @@ TEST(FormatTest, EmphasisNonHeaderOnly) {
EXPECT_EQ
(
fmt
::
format
(
fmt
::
emphasis
::
bold
,
"bold error"
),
"
\x1b
[1mbold error
\x1b
[0m"
);
}
TEST
(
FormatTest
,
CharTraitsIsNotAmbiguous
)
{
using
namespace
std
;
char_traits
<
char
>::
char_type
c
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment