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
cf5ebf20
Commit
cf5ebf20
authored
Jul 07, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup
parent
9c20e72d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
25 deletions
+26
-25
include/fmt/format.h
include/fmt/format.h
+26
-25
No files found.
include/fmt/format.h
View file @
cf5ebf20
...
@@ -1834,7 +1834,7 @@ FMT_CONSTEXPR unsigned parse_nonnegative_int(const Char*& begin,
...
@@ -1834,7 +1834,7 @@ FMT_CONSTEXPR unsigned parse_nonnegative_int(const Char*& begin,
template
<
typename
Context
>
class
custom_formatter
{
template
<
typename
Context
>
class
custom_formatter
{
private:
private:
typedef
typename
Context
::
char_type
char_type
;
using
char_type
=
typename
Context
::
char_type
;
basic_parse_context
<
char_type
>&
parse_ctx_
;
basic_parse_context
<
char_type
>&
parse_ctx_
;
Context
&
ctx_
;
Context
&
ctx_
;
...
@@ -1852,12 +1852,11 @@ template <typename Context> class custom_formatter {
...
@@ -1852,12 +1852,11 @@ template <typename Context> class custom_formatter {
template
<
typename
T
>
bool
operator
()(
T
)
const
{
return
false
;
}
template
<
typename
T
>
bool
operator
()(
T
)
const
{
return
false
;
}
};
};
template
<
typename
T
>
struct
is_integer
{
template
<
typename
T
>
enum
{
using
is_integer
=
value
=
std
::
is_integral
<
T
>::
value
&&
!
std
::
is_same
<
T
,
bool
>::
value
&&
bool_constant
<
std
::
is_integral
<
T
>::
value
&&
!
std
::
is_same
<
T
,
bool
>::
value
&&
!
std
::
is_same
<
T
,
char
>::
value
&&
!
std
::
is_same
<
T
,
wchar_t
>::
value
!
std
::
is_same
<
T
,
char
>::
value
&&
};
!
std
::
is_same
<
T
,
wchar_t
>::
value
>
;
};
template
<
typename
ErrorHandler
>
class
width_checker
{
template
<
typename
ErrorHandler
>
class
width_checker
{
public:
public:
...
@@ -2031,7 +2030,7 @@ FMT_CONSTEXPR typename Context::format_arg get_arg(Context& ctx, unsigned id) {
...
@@ -2031,7 +2030,7 @@ FMT_CONSTEXPR typename Context::format_arg get_arg(Context& ctx, unsigned id) {
template
<
typename
ParseContext
,
typename
Context
>
template
<
typename
ParseContext
,
typename
Context
>
class
specs_handler
:
public
specs_setter
<
typename
Context
::
char_type
>
{
class
specs_handler
:
public
specs_setter
<
typename
Context
::
char_type
>
{
public:
public:
typedef
typename
Context
::
char_type
char_type
;
using
char_type
=
typename
Context
::
char_type
;
FMT_CONSTEXPR
specs_handler
(
basic_format_specs
<
char_type
>&
specs
,
FMT_CONSTEXPR
specs_handler
(
basic_format_specs
<
char_type
>&
specs
,
ParseContext
&
parse_ctx
,
Context
&
ctx
)
ParseContext
&
parse_ctx
,
Context
&
ctx
)
...
@@ -2053,7 +2052,7 @@ class specs_handler : public specs_setter<typename Context::char_type> {
...
@@ -2053,7 +2052,7 @@ class specs_handler : public specs_setter<typename Context::char_type> {
private:
private:
// This is only needed for compatibility with gcc 4.4.
// This is only needed for compatibility with gcc 4.4.
typedef
typename
Context
::
format_arg
format_arg
;
using
format_arg
=
typename
Context
::
format_arg
;
FMT_CONSTEXPR
format_arg
get_arg
(
auto_id
)
{
FMT_CONSTEXPR
format_arg
get_arg
(
auto_id
)
{
return
internal
::
get_arg
(
context_
,
parse_context_
.
next_arg_id
());
return
internal
::
get_arg
(
context_
,
parse_context_
.
next_arg_id
());
...
@@ -2090,23 +2089,25 @@ struct string_view_metadata {
...
@@ -2090,23 +2089,25 @@ struct string_view_metadata {
std
::
size_t
size_
;
std
::
size_t
size_
;
};
};
enum
class
arg_id_kind
{
none
,
index
,
name
};
// An argument reference.
// An argument reference.
template
<
typename
Char
>
struct
arg_ref
{
template
<
typename
Char
>
struct
arg_ref
{
enum
Kind
{
NONE
,
INDEX
,
NAME
};
typedef
Char
char_type
;
typedef
Char
char_type
;
FMT_CONSTEXPR
arg_ref
()
:
kind
(
NONE
),
val
()
{}
FMT_CONSTEXPR
arg_ref
()
:
kind
(
arg_id_kind
::
none
),
val
()
{}
FMT_CONSTEXPR
explicit
arg_ref
(
unsigned
index
)
:
kind
(
INDEX
),
val
(
index
)
{}
FMT_CONSTEXPR
explicit
arg_ref
(
unsigned
index
)
:
kind
(
arg_id_kind
::
index
),
val
(
index
)
{}
FMT_CONSTEXPR
explicit
arg_ref
(
string_view_metadata
name
)
FMT_CONSTEXPR
explicit
arg_ref
(
string_view_metadata
name
)
:
kind
(
NAME
),
val
(
name
)
{}
:
kind
(
arg_id_kind
::
name
),
val
(
name
)
{}
FMT_CONSTEXPR
arg_ref
&
operator
=
(
unsigned
idx
)
{
FMT_CONSTEXPR
arg_ref
&
operator
=
(
unsigned
idx
)
{
kind
=
INDEX
;
kind
=
arg_id_kind
::
index
;
val
.
index
=
idx
;
val
.
index
=
idx
;
return
*
this
;
return
*
this
;
}
}
K
ind
kind
;
arg_id_k
ind
kind
;
union
value
{
union
value
{
FMT_CONSTEXPR
value
()
:
index
(
0u
)
{}
FMT_CONSTEXPR
value
()
:
index
(
0u
)
{}
FMT_CONSTEXPR
value
(
unsigned
id
)
:
index
(
id
)
{}
FMT_CONSTEXPR
value
(
unsigned
id
)
:
index
(
id
)
{}
...
@@ -2537,19 +2538,19 @@ template <template <typename> class Handler, typename Spec, typename Context>
...
@@ -2537,19 +2538,19 @@ template <template <typename> class Handler, typename Spec, typename Context>
void
handle_dynamic_spec
(
Spec
&
value
,
arg_ref
<
typename
Context
::
char_type
>
ref
,
void
handle_dynamic_spec
(
Spec
&
value
,
arg_ref
<
typename
Context
::
char_type
>
ref
,
Context
&
ctx
,
Context
&
ctx
,
const
typename
Context
::
char_type
*
format_str
)
{
const
typename
Context
::
char_type
*
format_str
)
{
typedef
typename
Context
::
char_type
char_type
;
switch
(
ref
.
kind
)
{
switch
(
ref
.
kind
)
{
case
arg_
ref
<
char_type
>
:
:
NONE
:
case
arg_
id_kind
:
:
none
:
break
;
break
;
case
arg_
ref
<
char_type
>
:
:
INDEX
:
case
arg_
id_kind
:
:
index
:
internal
::
set_dynamic_spec
<
Handler
>
(
value
,
ctx
.
arg
(
ref
.
val
.
index
),
internal
::
set_dynamic_spec
<
Handler
>
(
value
,
ctx
.
arg
(
ref
.
val
.
index
),
ctx
.
error_handler
());
ctx
.
error_handler
());
break
;
break
;
case
arg_
ref
<
char_type
>
:
:
NAME
:
{
case
arg_
id_kind
:
:
name
:
{
const
auto
arg_id
=
ref
.
val
.
name
.
to_view
(
format_str
);
const
auto
arg_id
=
ref
.
val
.
name
.
to_view
(
format_str
);
internal
::
set_dynamic_spec
<
Handler
>
(
value
,
ctx
.
arg
(
arg_id
),
internal
::
set_dynamic_spec
<
Handler
>
(
value
,
ctx
.
arg
(
arg_id
),
ctx
.
error_handler
());
ctx
.
error_handler
());
}
break
;
break
;
}
}
}
}
}
}
// namespace internal
}
// namespace internal
...
@@ -2838,13 +2839,13 @@ class format_int {
...
@@ -2838,13 +2839,13 @@ class format_int {
private:
private:
// Buffer should be large enough to hold all digits (digits10 + 1),
// Buffer should be large enough to hold all digits (digits10 + 1),
// a sign and a null character.
// a sign and a null character.
enum
{
BUFFER_SIZE
=
std
::
numeric_limits
<
unsigned
long
long
>::
digits10
+
3
};
enum
{
buffer_size
=
std
::
numeric_limits
<
unsigned
long
long
>::
digits10
+
3
};
mutable
char
buffer_
[
BUFFER_SIZE
];
mutable
char
buffer_
[
buffer_size
];
char
*
str_
;
char
*
str_
;
// Formats value in reverse and returns a pointer to the beginning.
// Formats value in reverse and returns a pointer to the beginning.
char
*
format_decimal
(
unsigned
long
long
value
)
{
char
*
format_decimal
(
unsigned
long
long
value
)
{
char
*
ptr
=
buffer_
+
(
BUFFER_SIZE
-
1
);
// Parens to workaround MSVC bug.
char
*
ptr
=
buffer_
+
(
buffer_size
-
1
);
// Parens to workaround MSVC bug.
while
(
value
>=
100
)
{
while
(
value
>=
100
)
{
// Integer division is slow so do it for a group of two digits instead
// Integer division is slow so do it for a group of two digits instead
// of for every digit. The idea comes from the talk by Alexandrescu
// of for every digit. The idea comes from the talk by Alexandrescu
...
@@ -2882,7 +2883,7 @@ class format_int {
...
@@ -2882,7 +2883,7 @@ class format_int {
/** Returns the number of characters written to the output buffer. */
/** Returns the number of characters written to the output buffer. */
std
::
size_t
size
()
const
{
std
::
size_t
size
()
const
{
return
internal
::
to_unsigned
(
buffer_
-
str_
+
BUFFER_SIZE
-
1
);
return
internal
::
to_unsigned
(
buffer_
-
str_
+
buffer_size
-
1
);
}
}
/**
/**
...
@@ -2896,7 +2897,7 @@ class format_int {
...
@@ -2896,7 +2897,7 @@ class format_int {
character appended.
character appended.
*/
*/
const
char
*
c_str
()
const
{
const
char
*
c_str
()
const
{
buffer_
[
BUFFER_SIZE
-
1
]
=
'\0'
;
buffer_
[
buffer_size
-
1
]
=
'\0'
;
return
str_
;
return
str_
;
}
}
...
...
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