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
715f2b4c
Commit
715f2b4c
authored
Sep 21, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove require_wchar and internalize no_formatter_error
parent
ec0cdc46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
26 deletions
+10
-26
include/fmt/core.h
include/fmt/core.h
+8
-22
include/fmt/format.h
include/fmt/format.h
+2
-4
No files found.
include/fmt/core.h
View file @
715f2b4c
...
@@ -233,6 +233,9 @@ FMT_CONSTEXPR size_t length(const Char *s) {
...
@@ -233,6 +233,9 @@ FMT_CONSTEXPR size_t length(const Char *s) {
#if FMT_GCC_VERSION
#if FMT_GCC_VERSION
FMT_CONSTEXPR
size_t
length
(
const
char
*
s
)
{
return
std
::
strlen
(
s
);
}
FMT_CONSTEXPR
size_t
length
(
const
char
*
s
)
{
return
std
::
strlen
(
s
);
}
#endif
#endif
template
<
typename
T
>
struct
no_formatter_error
:
std
::
false_type
{};
}
// namespace internal
}
// namespace internal
/**
/**
...
@@ -340,13 +343,10 @@ class basic_format_arg;
...
@@ -340,13 +343,10 @@ class basic_format_arg;
template
<
typename
Context
>
template
<
typename
Context
>
class
basic_format_args
;
class
basic_format_args
;
template
<
typename
T
>
struct
no_formatter_error
:
std
::
false_type
{};
// A formatter for objects of type T.
// A formatter for objects of type T.
template
<
typename
T
,
typename
Char
=
char
,
typename
Enable
=
void
>
template
<
typename
T
,
typename
Char
=
char
,
typename
Enable
=
void
>
struct
formatter
{
struct
formatter
{
static_assert
(
no_formatter_error
<
T
>::
value
,
static_assert
(
internal
::
no_formatter_error
<
T
>::
value
,
"don't know how to format the type, include fmt/ostream.h if it provides "
"don't know how to format the type, include fmt/ostream.h if it provides "
"an operator<< that should be used"
);
"an operator<< that should be used"
);
...
@@ -472,17 +472,6 @@ struct error_handler {
...
@@ -472,17 +472,6 @@ struct error_handler {
FMT_API
void
on_error
(
const
char
*
message
);
FMT_API
void
on_error
(
const
char
*
message
);
};
};
// Formatting of wide characters and strings into a narrow output is disallowed:
// fmt::format("{}", L"test"); // error
// To fix this, use a wide format string:
// fmt::format(L"{}", L"test");
template
<
typename
Char
>
inline
void
require_wchar
()
{
static_assert
(
std
::
is_same
<
wchar_t
,
Char
>::
value
,
"formatting of wide characters into a narrow output is disallowed"
);
}
template
<
typename
Char
>
template
<
typename
Char
>
struct
named_arg_base
;
struct
named_arg_base
;
...
@@ -639,15 +628,12 @@ FMT_MAKE_VALUE_SAME(long_long_type, long long)
...
@@ -639,15 +628,12 @@ FMT_MAKE_VALUE_SAME(long_long_type, long long)
FMT_MAKE_VALUE_SAME
(
ulong_long_type
,
unsigned
long
long
)
FMT_MAKE_VALUE_SAME
(
ulong_long_type
,
unsigned
long
long
)
FMT_MAKE_VALUE
(
int_type
,
signed
char
,
int
)
FMT_MAKE_VALUE
(
int_type
,
signed
char
,
int
)
FMT_MAKE_VALUE
(
uint_type
,
unsigned
char
,
unsigned
)
FMT_MAKE_VALUE
(
uint_type
,
unsigned
char
,
unsigned
)
FMT_MAKE_VALUE
(
char_type
,
char
,
int
)
FMT_MAKE_VALUE
(
char_type
,
typename
C
::
char_type
,
int
)
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
template
<
typename
C
>
template
<
typename
C
>
inline
init
<
C
,
int
,
char_type
>
make_value
(
wchar_t
val
)
{
FMT_CONSTEXPR
typename
std
::
enable_if
<
require_wchar
<
typename
C
::
char_type
>
();
!
std
::
is_same
<
typename
C
::
char_type
,
char
>::
value
,
return
static_cast
<
int
>
(
val
);
init
<
C
,
int
,
char_type
>>::
type
make_value
(
char
val
)
{
return
val
;
}
}
#endif
FMT_MAKE_VALUE
(
double_type
,
float
,
double
)
FMT_MAKE_VALUE
(
double_type
,
float
,
double
)
FMT_MAKE_VALUE_SAME
(
double_type
,
double
)
FMT_MAKE_VALUE_SAME
(
double_type
,
double
)
...
...
include/fmt/format.h
View file @
715f2b4c
...
@@ -2740,9 +2740,8 @@ class basic_writer {
...
@@ -2740,9 +2740,8 @@ class basic_writer {
void
write
(
char
value
)
{
void
write
(
char
value
)
{
*
reserve
(
1
)
=
value
;
*
reserve
(
1
)
=
value
;
}
}
void
write
(
wchar_t
value
)
{
void
write
(
wchar_t
value
)
{
internal
::
require_wchar
<
char_type
>
(
);
static_assert
(
std
::
is_same
<
char_type
,
wchar_t
>::
value
,
""
);
*
reserve
(
1
)
=
value
;
*
reserve
(
1
)
=
value
;
}
}
...
@@ -2755,9 +2754,8 @@ class basic_writer {
...
@@ -2755,9 +2754,8 @@ class basic_writer {
auto
&&
it
=
reserve
(
value
.
size
());
auto
&&
it
=
reserve
(
value
.
size
());
it
=
std
::
copy
(
value
.
begin
(),
value
.
end
(),
it
);
it
=
std
::
copy
(
value
.
begin
(),
value
.
end
(),
it
);
}
}
void
write
(
wstring_view
value
)
{
void
write
(
wstring_view
value
)
{
internal
::
require_wchar
<
char_type
>
(
);
static_assert
(
std
::
is_same
<
char_type
,
wchar_t
>::
value
,
""
);
auto
&&
it
=
reserve
(
value
.
size
());
auto
&&
it
=
reserve
(
value
.
size
());
it
=
std
::
copy
(
value
.
begin
(),
value
.
end
(),
it
);
it
=
std
::
copy
(
value
.
begin
(),
value
.
end
(),
it
);
}
}
...
...
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