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
874d6727
Commit
874d6727
authored
Jun 13, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove workarounds for pre-C++11 compilers
parent
a9940192
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
46 deletions
+16
-46
include/fmt/format.h
include/fmt/format.h
+7
-31
include/fmt/printf.h
include/fmt/printf.h
+5
-7
test/format
test/format
+1
-3
test/format-impl-test.cc
test/format-impl-test.cc
+2
-2
test/format-test.cc
test/format-test.cc
+1
-3
No files found.
include/fmt/format.h
View file @
874d6727
...
...
@@ -265,31 +265,9 @@ inline Dest bit_cast(const Source& source) {
return
dest
;
}
// An implementation of begin and end for pre-C++11 compilers such as gcc 4.
template
<
typename
C
>
FMT_CONSTEXPR
auto
begin
(
const
C
&
c
)
->
decltype
(
c
.
begin
())
{
return
c
.
begin
();
}
template
<
typename
T
,
std
::
size_t
N
>
FMT_CONSTEXPR
T
*
begin
(
T
(
&
array
)[
N
])
FMT_NOEXCEPT
{
return
array
;
}
template
<
typename
C
>
FMT_CONSTEXPR
auto
end
(
const
C
&
c
)
->
decltype
(
c
.
end
())
{
return
c
.
end
();
}
template
<
typename
T
,
std
::
size_t
N
>
FMT_CONSTEXPR
T
*
end
(
T
(
&
array
)[
N
])
FMT_NOEXCEPT
{
return
array
+
N
;
}
// An implementation of iterator_t for pre-C++20 compilers such as gcc 4.
// An implementation of iterator_t for pre-C++20 systems.
template
<
typename
T
>
struct
iterator_t
{
typedef
decltype
(
internal
::
begin
(
std
::
declval
<
const
T
&>
()))
type
;
};
// For std::result_of in gcc 4.4.
template
<
typename
Result
>
struct
function
{
template
<
typename
T
>
struct
result
{
typedef
Result
type
;
};
typedef
decltype
(
std
::
begin
(
std
::
declval
<
const
T
&>
()))
type
;
};
template
<
typename
Allocator
>
...
...
@@ -1531,7 +1509,7 @@ FMT_CONSTEXPR unsigned parse_nonnegative_int(const Char*& begin,
return
value
;
}
template
<
typename
Context
>
class
custom_formatter
:
public
function
<
bool
>
{
template
<
typename
Context
>
class
custom_formatter
{
private:
typedef
typename
Context
::
char_type
char_type
;
...
...
@@ -1558,8 +1536,7 @@ template <typename T> struct is_integer {
};
};
template
<
typename
ErrorHandler
>
class
width_checker
:
public
function
<
unsigned
long
long
>
{
template
<
typename
ErrorHandler
>
class
width_checker
{
public:
explicit
FMT_CONSTEXPR
width_checker
(
ErrorHandler
&
eh
)
:
handler_
(
eh
)
{}
...
...
@@ -1579,8 +1556,7 @@ class width_checker : public function<unsigned long long> {
ErrorHandler
&
handler_
;
};
template
<
typename
ErrorHandler
>
class
precision_checker
:
public
function
<
unsigned
long
long
>
{
template
<
typename
ErrorHandler
>
class
precision_checker
{
public:
explicit
FMT_CONSTEXPR
precision_checker
(
ErrorHandler
&
eh
)
:
handler_
(
eh
)
{}
...
...
@@ -3339,13 +3315,13 @@ arg_join<It, wchar_t> join(It begin, It end, wstring_view sep) {
template
<
typename
Range
>
arg_join
<
typename
internal
::
iterator_t
<
Range
>::
type
,
char
>
join
(
const
Range
&
range
,
string_view
sep
)
{
return
join
(
internal
::
begin
(
range
),
internal
::
end
(
range
),
sep
);
return
join
(
std
::
begin
(
range
),
std
::
end
(
range
),
sep
);
}
template
<
typename
Range
>
arg_join
<
typename
internal
::
iterator_t
<
Range
>::
type
,
wchar_t
>
join
(
const
Range
&
range
,
wstring_view
sep
)
{
return
join
(
internal
::
begin
(
range
),
internal
::
end
(
range
),
sep
);
return
join
(
std
::
begin
(
range
),
std
::
end
(
range
),
sep
);
}
#endif
...
...
include/fmt/printf.h
View file @
874d6727
...
...
@@ -38,7 +38,7 @@ template <> struct int_checker<true> {
static
bool
fits_in_int
(
int
)
{
return
true
;
}
};
class
printf_precision_handler
:
public
function
<
int
>
{
class
printf_precision_handler
{
public:
template
<
typename
T
,
FMT_ENABLE_IF
(
std
::
is_integral
<
T
>
::
value
)
>
int
operator
()(
T
value
)
{
...
...
@@ -55,7 +55,7 @@ class printf_precision_handler : public function<int> {
};
// An argument visitor that returns true iff arg is a zero integer.
class
is_zero_int
:
public
function
<
bool
>
{
class
is_zero_int
{
public:
template
<
typename
T
,
FMT_ENABLE_IF
(
std
::
is_integral
<
T
>
::
value
)
>
bool
operator
()(
T
value
)
{
...
...
@@ -72,8 +72,7 @@ template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
template
<
>
struct
make_unsigned_or_bool
<
bool
>
{
typedef
bool
type
;
};
template
<
typename
T
,
typename
Context
>
class
arg_converter
:
public
function
<
void
>
{
template
<
typename
T
,
typename
Context
>
class
arg_converter
{
private:
typedef
typename
Context
::
char_type
Char
;
...
...
@@ -129,7 +128,7 @@ void convert_arg(basic_format_arg<Context>& arg, Char type) {
}
// Converts an integer argument to char for printf.
template
<
typename
Context
>
class
char_converter
:
public
function
<
void
>
{
template
<
typename
Context
>
class
char_converter
{
private:
basic_format_arg
<
Context
>&
arg_
;
...
...
@@ -148,8 +147,7 @@ template <typename Context> class char_converter : public function<void> {
// Checks if an argument is a valid printf width specifier and sets
// left alignment if it is negative.
template
<
typename
Char
>
class
printf_width_handler
:
public
function
<
unsigned
>
{
template
<
typename
Char
>
class
printf_width_handler
{
private:
typedef
basic_format_specs
<
Char
>
format_specs
;
...
...
test/format
View file @
874d6727
...
...
@@ -489,9 +489,7 @@ namespace detail {
template <typename Range>
class arg_formatter
: public fmt::internal::function<
typename fmt::internal::arg_formatter_base<Range, error_handler>::iterator>,
public fmt::internal::arg_formatter_base<Range, error_handler> {
: public fmt::internal::arg_formatter_base<Range, error_handler> {
private:
using char_type = typename Range::value_type;
using base = fmt::internal::arg_formatter_base<Range, error_handler>;
...
...
test/format-impl-test.cc
View file @
874d6727
...
...
@@ -143,7 +143,7 @@ TEST(FPTest, GrisuFormatCompilesWithNonIEEEDouble) {
grisu_format
(
4.2
f
,
buf
,
-
1
,
false
,
exp
);
}
template
<
typename
T
>
struct
ValueExtractor
:
fmt
::
internal
::
function
<
T
>
{
template
<
typename
T
>
struct
value_extractor
{
T
operator
()(
T
value
)
{
return
value
;
}
template
<
typename
U
>
FMT_NORETURN
T
operator
()(
U
)
{
...
...
@@ -157,7 +157,7 @@ TEST(FormatTest, ArgConverter) {
fmt
::
visit_format_arg
(
fmt
::
internal
::
arg_converter
<
long
long
,
fmt
::
format_context
>
(
arg
,
'd'
),
arg
);
EXPECT_EQ
(
value
,
fmt
::
visit_format_arg
(
ValueE
xtractor
<
long
long
>
(),
arg
));
EXPECT_EQ
(
value
,
fmt
::
visit_format_arg
(
value_e
xtractor
<
long
long
>
(),
arg
));
}
TEST
(
FormatTest
,
FormatNegativeNaN
)
{
...
...
test/format-test.cc
View file @
874d6727
...
...
@@ -1890,9 +1890,7 @@ TEST(FormatTest, FixedEnum) { EXPECT_EQ("0", fmt::format("{}", B)); }
typedef
fmt
::
back_insert_range
<
fmt
::
internal
::
buffer
<
char
>>
buffer_range
;
class
mock_arg_formatter
:
public
fmt
::
internal
::
function
<
fmt
::
internal
::
arg_formatter_base
<
buffer_range
>::
iterator
>
,
public
fmt
::
internal
::
arg_formatter_base
<
buffer_range
>
{
:
public
fmt
::
internal
::
arg_formatter_base
<
buffer_range
>
{
private:
MOCK_METHOD1
(
call
,
void
(
long
long
value
));
...
...
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