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
c2850055
Commit
c2850055
authored
Jan 20, 2022
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FMT_NOEXCEPT -> noexcept
parent
6240d020
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
149 additions
and
170 deletions
+149
-170
include/fmt/color.h
include/fmt/color.h
+32
-39
include/fmt/core.h
include/fmt/core.h
+29
-32
include/fmt/format-inl.h
include/fmt/format-inl.h
+42
-43
include/fmt/format.h
include/fmt/format.h
+11
-19
include/fmt/os.h
include/fmt/os.h
+14
-15
include/fmt/ranges.h
include/fmt/ranges.h
+1
-1
src/format.cc
src/format.cc
+4
-4
src/os.cc
src/os.cc
+10
-10
test/format-test.cc
test/format-test.cc
+1
-1
test/gtest-extra.cc
test/gtest-extra.cc
+1
-1
test/gtest-extra.h
test/gtest-extra.h
+1
-1
test/module-test.cc
test/module-test.cc
+0
-1
test/xchar-test.cc
test/xchar-test.cc
+3
-3
No files found.
include/fmt/color.h
View file @
c2850055
...
...
@@ -214,17 +214,16 @@ FMT_BEGIN_DETAIL_NAMESPACE
// color is a struct of either a rgb color or a terminal color.
struct
color_type
{
FMT_CONSTEXPR
color_type
()
FMT_NOEXCEPT
:
is_rgb
(),
value
{}
{}
FMT_CONSTEXPR
color_type
(
color
rgb_color
)
FMT_NOEXCEPT
:
is_rgb
(
true
),
value
{}
{
FMT_CONSTEXPR
color_type
()
noexcept
:
is_rgb
(),
value
{}
{}
FMT_CONSTEXPR
color_type
(
color
rgb_color
)
noexcept
:
is_rgb
(
true
),
value
{}
{
value
.
rgb_color
=
static_cast
<
uint32_t
>
(
rgb_color
);
}
FMT_CONSTEXPR
color_type
(
rgb
rgb_color
)
FMT_NOEXCEPT
:
is_rgb
(
true
),
value
{}
{
FMT_CONSTEXPR
color_type
(
rgb
rgb_color
)
noexcept
:
is_rgb
(
true
),
value
{}
{
value
.
rgb_color
=
(
static_cast
<
uint32_t
>
(
rgb_color
.
r
)
<<
16
)
|
(
static_cast
<
uint32_t
>
(
rgb_color
.
g
)
<<
8
)
|
rgb_color
.
b
;
}
FMT_CONSTEXPR
color_type
(
terminal_color
term_color
)
FMT_NOEXCEPT
:
is_rgb
(),
value
{}
{
FMT_CONSTEXPR
color_type
(
terminal_color
term_color
)
noexcept
:
is_rgb
(),
value
{}
{
value
.
term_color
=
static_cast
<
uint8_t
>
(
term_color
);
}
bool
is_rgb
;
...
...
@@ -239,10 +238,8 @@ FMT_END_DETAIL_NAMESPACE
/** A text style consisting of foreground and background colors and emphasis. */
class
text_style
{
public:
FMT_CONSTEXPR
text_style
(
emphasis
em
=
emphasis
())
FMT_NOEXCEPT
:
set_foreground_color
(),
set_background_color
(),
ems
(
em
)
{}
FMT_CONSTEXPR
text_style
(
emphasis
em
=
emphasis
())
noexcept
:
set_foreground_color
(),
set_background_color
(),
ems
(
em
)
{}
FMT_CONSTEXPR
text_style
&
operator
|=
(
const
text_style
&
rhs
)
{
if
(
!
set_foreground_color
)
{
...
...
@@ -283,34 +280,32 @@ class text_style {
return
lhs
.
and_assign
(
rhs
);
}
FMT_CONSTEXPR
bool
has_foreground
()
const
FMT_NOEXCEPT
{
FMT_CONSTEXPR
bool
has_foreground
()
const
noexcept
{
return
set_foreground_color
;
}
FMT_CONSTEXPR
bool
has_background
()
const
FMT_NOEXCEPT
{
FMT_CONSTEXPR
bool
has_background
()
const
noexcept
{
return
set_background_color
;
}
FMT_CONSTEXPR
bool
has_emphasis
()
const
FMT_NOEXCEPT
{
FMT_CONSTEXPR
bool
has_emphasis
()
const
noexcept
{
return
static_cast
<
uint8_t
>
(
ems
)
!=
0
;
}
FMT_CONSTEXPR
detail
::
color_type
get_foreground
()
const
FMT_NOEXCEPT
{
FMT_CONSTEXPR
detail
::
color_type
get_foreground
()
const
noexcept
{
FMT_ASSERT
(
has_foreground
(),
"no foreground specified for this style"
);
return
foreground_color
;
}
FMT_CONSTEXPR
detail
::
color_type
get_background
()
const
FMT_NOEXCEPT
{
FMT_CONSTEXPR
detail
::
color_type
get_background
()
const
noexcept
{
FMT_ASSERT
(
has_background
(),
"no background specified for this style"
);
return
background_color
;
}
FMT_CONSTEXPR
emphasis
get_emphasis
()
const
FMT_NOEXCEPT
{
FMT_CONSTEXPR
emphasis
get_emphasis
()
const
noexcept
{
FMT_ASSERT
(
has_emphasis
(),
"no emphasis specified for this style"
);
return
ems
;
}
private:
FMT_CONSTEXPR
text_style
(
bool
is_foreground
,
detail
::
color_type
text_color
)
FMT_NOEXCEPT
:
set_foreground_color
(),
set_background_color
(),
ems
()
{
detail
::
color_type
text_color
)
noexcept
:
set_foreground_color
(),
set_background_color
(),
ems
()
{
if
(
is_foreground
)
{
foreground_color
=
text_color
;
set_foreground_color
=
true
;
...
...
@@ -345,11 +340,11 @@ class text_style {
return
*
this
;
}
friend
FMT_CONSTEXPR_DECL
text_style
fg
(
detail
::
color_type
foreground
)
FMT_NOEXCEPT
;
friend
FMT_CONSTEXPR_DECL
text_style
fg
(
detail
::
color_type
foreground
)
noexcept
;
friend
FMT_CONSTEXPR_DECL
text_style
bg
(
detail
::
color_type
background
)
FMT_NOEXCEPT
;
friend
FMT_CONSTEXPR_DECL
text_style
bg
(
detail
::
color_type
background
)
noexcept
;
detail
::
color_type
foreground_color
;
detail
::
color_type
background_color
;
...
...
@@ -359,17 +354,16 @@ class text_style {
};
/** Creates a text style from the foreground (text) color. */
FMT_CONSTEXPR
inline
text_style
fg
(
detail
::
color_type
foreground
)
FMT_NOEXCEPT
{
FMT_CONSTEXPR
inline
text_style
fg
(
detail
::
color_type
foreground
)
noexcept
{
return
text_style
(
true
,
foreground
);
}
/** Creates a text style from the background color. */
FMT_CONSTEXPR
inline
text_style
bg
(
detail
::
color_type
background
)
FMT_NOEXCEPT
{
FMT_CONSTEXPR
inline
text_style
bg
(
detail
::
color_type
background
)
noexcept
{
return
text_style
(
false
,
background
);
}
FMT_CONSTEXPR
inline
text_style
operator
|
(
emphasis
lhs
,
emphasis
rhs
)
FMT_NOEXCEPT
{
FMT_CONSTEXPR
inline
text_style
operator
|
(
emphasis
lhs
,
emphasis
rhs
)
noexcept
{
return
text_style
(
lhs
)
|
rhs
;
}
...
...
@@ -377,7 +371,7 @@ FMT_BEGIN_DETAIL_NAMESPACE
template
<
typename
Char
>
struct
ansi_color_escape
{
FMT_CONSTEXPR
ansi_color_escape
(
detail
::
color_type
text_color
,
const
char
*
esc
)
FMT_NOEXCEPT
{
const
char
*
esc
)
noexcept
{
// If we have a terminal color, we need to output another escape code
// sequence.
if
(
!
text_color
.
is_rgb
)
{
...
...
@@ -412,7 +406,7 @@ template <typename Char> struct ansi_color_escape {
to_esc
(
color
.
b
,
buffer
+
15
,
'm'
);
buffer
[
19
]
=
static_cast
<
Char
>
(
0
);
}
FMT_CONSTEXPR
ansi_color_escape
(
emphasis
em
)
FMT_NOEXCEPT
{
FMT_CONSTEXPR
ansi_color_escape
(
emphasis
em
)
noexcept
{
uint8_t
em_codes
[
num_emphases
]
=
{};
if
(
has_emphasis
(
em
,
emphasis
::
bold
))
em_codes
[
0
]
=
1
;
if
(
has_emphasis
(
em
,
emphasis
::
faint
))
em_codes
[
1
]
=
2
;
...
...
@@ -433,10 +427,10 @@ template <typename Char> struct ansi_color_escape {
}
buffer
[
index
++
]
=
static_cast
<
Char
>
(
0
);
}
FMT_CONSTEXPR
operator
const
Char
*
()
const
FMT_NOEXCEPT
{
return
buffer
;
}
FMT_CONSTEXPR
operator
const
Char
*
()
const
noexcept
{
return
buffer
;
}
FMT_CONSTEXPR
const
Char
*
begin
()
const
FMT_NOEXCEPT
{
return
buffer
;
}
FMT_CONSTEXPR_CHAR_TRAITS
const
Char
*
end
()
const
FMT_NOEXCEPT
{
FMT_CONSTEXPR
const
Char
*
begin
()
const
noexcept
{
return
buffer
;
}
FMT_CONSTEXPR_CHAR_TRAITS
const
Char
*
end
()
const
noexcept
{
return
buffer
+
std
::
char_traits
<
Char
>::
length
(
buffer
);
}
...
...
@@ -445,32 +439,31 @@ template <typename Char> struct ansi_color_escape {
Char
buffer
[
7u
+
3u
*
num_emphases
+
1u
];
static
FMT_CONSTEXPR
void
to_esc
(
uint8_t
c
,
Char
*
out
,
char
delimiter
)
FMT_NOEXCEPT
{
char
delimiter
)
noexcept
{
out
[
0
]
=
static_cast
<
Char
>
(
'0'
+
c
/
100
);
out
[
1
]
=
static_cast
<
Char
>
(
'0'
+
c
/
10
%
10
);
out
[
2
]
=
static_cast
<
Char
>
(
'0'
+
c
%
10
);
out
[
3
]
=
static_cast
<
Char
>
(
delimiter
);
}
static
FMT_CONSTEXPR
bool
has_emphasis
(
emphasis
em
,
emphasis
mask
)
FMT_NOEXCEPT
{
static
FMT_CONSTEXPR
bool
has_emphasis
(
emphasis
em
,
emphasis
mask
)
noexcept
{
return
static_cast
<
uint8_t
>
(
em
)
&
static_cast
<
uint8_t
>
(
mask
);
}
};
template
<
typename
Char
>
FMT_CONSTEXPR
ansi_color_escape
<
Char
>
make_foreground_color
(
detail
::
color_type
foreground
)
FMT_NOEXCEPT
{
detail
::
color_type
foreground
)
noexcept
{
return
ansi_color_escape
<
Char
>
(
foreground
,
"
\x1b
[38;2;"
);
}
template
<
typename
Char
>
FMT_CONSTEXPR
ansi_color_escape
<
Char
>
make_background_color
(
detail
::
color_type
background
)
FMT_NOEXCEPT
{
detail
::
color_type
background
)
noexcept
{
return
ansi_color_escape
<
Char
>
(
background
,
"
\x1b
[48;2;"
);
}
template
<
typename
Char
>
FMT_CONSTEXPR
ansi_color_escape
<
Char
>
make_emphasis
(
emphasis
em
)
FMT_NOEXCEPT
{
FMT_CONSTEXPR
ansi_color_escape
<
Char
>
make_emphasis
(
emphasis
em
)
noexcept
{
return
ansi_color_escape
<
Char
>
(
em
);
}
...
...
include/fmt/core.h
View file @
c2850055
...
...
@@ -144,9 +144,6 @@
# define FMT_EXCEPTIONS 1
# endif
#endif
#ifndef FMT_NOEXCEPT
# define FMT_NOEXCEPT noexcept
#endif
// [[noreturn]] is disabled on MSVC and NVCC because of bogus unreachable code
// warnings.
...
...
@@ -333,7 +330,7 @@ FMT_BEGIN_DETAIL_NAMESPACE
template
<
typename
...
T
>
FMT_CONSTEXPR
void
ignore_unused
(
const
T
&
...)
{}
constexpr
FMT_INLINE
auto
is_constant_evaluated
(
bool
default_value
=
false
)
FMT_NOEXCEPT
->
bool
{
noexcept
->
bool
{
#ifdef __cpp_lib_is_constant_evaluated
ignore_unused
(
default_value
);
return
std
::
is_constant_evaluated
();
...
...
@@ -435,10 +432,10 @@ template <typename Char> class basic_string_view {
using
value_type
=
Char
;
using
iterator
=
const
Char
*
;
constexpr
basic_string_view
()
FMT_NOEXCEPT
:
data_
(
nullptr
),
size_
(
0
)
{}
constexpr
basic_string_view
()
noexcept
:
data_
(
nullptr
),
size_
(
0
)
{}
/** Constructs a string reference object from a C string and a size. */
constexpr
basic_string_view
(
const
Char
*
s
,
size_t
count
)
FMT_NOEXCEPT
constexpr
basic_string_view
(
const
Char
*
s
,
size_t
count
)
noexcept
:
data_
(
s
),
size_
(
count
)
{}
...
...
@@ -460,29 +457,29 @@ template <typename Char> class basic_string_view {
/** Constructs a string reference from a ``std::basic_string`` object. */
template
<
typename
Traits
,
typename
Alloc
>
FMT_CONSTEXPR
basic_string_view
(
const
std
::
basic_string
<
Char
,
Traits
,
Alloc
>&
s
)
FMT_NOEXCEPT
const
std
::
basic_string
<
Char
,
Traits
,
Alloc
>&
s
)
noexcept
:
data_
(
s
.
data
()),
size_
(
s
.
size
())
{}
template
<
typename
S
,
FMT_ENABLE_IF
(
std
::
is_same
<
S
,
detail
::
std_string_view
<
Char
>
>::
value
)
>
FMT_CONSTEXPR
basic_string_view
(
S
s
)
FMT_NOEXCEPT
:
data_
(
s
.
data
()),
FMT_CONSTEXPR
basic_string_view
(
S
s
)
noexcept
:
data_
(
s
.
data
()),
size_
(
s
.
size
())
{}
/** Returns a pointer to the string data. */
constexpr
auto
data
()
const
FMT_NOEXCEPT
->
const
Char
*
{
return
data_
;
}
constexpr
auto
data
()
const
noexcept
->
const
Char
*
{
return
data_
;
}
/** Returns the string size. */
constexpr
auto
size
()
const
FMT_NOEXCEPT
->
size_t
{
return
size_
;
}
constexpr
auto
size
()
const
noexcept
->
size_t
{
return
size_
;
}
constexpr
auto
begin
()
const
FMT_NOEXCEPT
->
iterator
{
return
data_
;
}
constexpr
auto
end
()
const
FMT_NOEXCEPT
->
iterator
{
return
data_
+
size_
;
}
constexpr
auto
begin
()
const
noexcept
->
iterator
{
return
data_
;
}
constexpr
auto
end
()
const
noexcept
->
iterator
{
return
data_
+
size_
;
}
constexpr
auto
operator
[](
size_t
pos
)
const
FMT_NOEXCEPT
->
const
Char
&
{
constexpr
auto
operator
[](
size_t
pos
)
const
noexcept
->
const
Char
&
{
return
data_
[
pos
];
}
FMT_CONSTEXPR
void
remove_prefix
(
size_t
n
)
FMT_NOEXCEPT
{
FMT_CONSTEXPR
void
remove_prefix
(
size_t
n
)
noexcept
{
data_
+=
n
;
size_
-=
n
;
}
...
...
@@ -629,14 +626,14 @@ class basic_format_parse_context : private ErrorHandler {
Returns an iterator to the beginning of the format string range being
parsed.
*/
constexpr
auto
begin
()
const
FMT_NOEXCEPT
->
iterator
{
constexpr
auto
begin
()
const
noexcept
->
iterator
{
return
format_str_
.
begin
();
}
/**
Returns an iterator past the end of the format string range being parsed.
*/
constexpr
auto
end
()
const
FMT_NOEXCEPT
->
iterator
{
constexpr
auto
end
()
const
noexcept
->
iterator
{
return
format_str_
.
end
();
}
...
...
@@ -765,10 +762,10 @@ template <typename T> class buffer {
protected:
// Don't initialize ptr_ since it is not accessed to save a few cycles.
FMT_MSC_WARNING
(
suppress
:
26495
)
buffer
(
size_t
sz
)
FMT_NOEXCEPT
:
size_
(
sz
),
capacity_
(
sz
)
{}
buffer
(
size_t
sz
)
noexcept
:
size_
(
sz
),
capacity_
(
sz
)
{}
FMT_CONSTEXPR20
buffer
(
T
*
p
=
nullptr
,
size_t
sz
=
0
,
size_t
cap
=
0
)
FMT_NOEXCEPT
:
ptr_
(
p
),
size_t
cap
=
0
)
noexcept
:
ptr_
(
p
),
size_
(
sz
),
capacity_
(
cap
)
{}
...
...
@@ -776,7 +773,7 @@ template <typename T> class buffer {
buffer
(
buffer
&&
)
=
default
;
/** Sets the buffer data and capacity. */
FMT_CONSTEXPR
void
set
(
T
*
buf_data
,
size_t
buf_capacity
)
FMT_NOEXCEPT
{
FMT_CONSTEXPR
void
set
(
T
*
buf_data
,
size_t
buf_capacity
)
noexcept
{
ptr_
=
buf_data
;
capacity_
=
buf_capacity
;
}
...
...
@@ -791,23 +788,23 @@ template <typename T> class buffer {
buffer
(
const
buffer
&
)
=
delete
;
void
operator
=
(
const
buffer
&
)
=
delete
;
auto
begin
()
FMT_NOEXCEPT
->
T
*
{
return
ptr_
;
}
auto
end
()
FMT_NOEXCEPT
->
T
*
{
return
ptr_
+
size_
;
}
auto
begin
()
noexcept
->
T
*
{
return
ptr_
;
}
auto
end
()
noexcept
->
T
*
{
return
ptr_
+
size_
;
}
auto
begin
()
const
FMT_NOEXCEPT
->
const
T
*
{
return
ptr_
;
}
auto
end
()
const
FMT_NOEXCEPT
->
const
T
*
{
return
ptr_
+
size_
;
}
auto
begin
()
const
noexcept
->
const
T
*
{
return
ptr_
;
}
auto
end
()
const
noexcept
->
const
T
*
{
return
ptr_
+
size_
;
}
/** Returns the size of this buffer. */
constexpr
auto
size
()
const
FMT_NOEXCEPT
->
size_t
{
return
size_
;
}
constexpr
auto
size
()
const
noexcept
->
size_t
{
return
size_
;
}
/** Returns the capacity of this buffer. */
constexpr
auto
capacity
()
const
FMT_NOEXCEPT
->
size_t
{
return
capacity_
;
}
constexpr
auto
capacity
()
const
noexcept
->
size_t
{
return
capacity_
;
}
/** Returns a pointer to the buffer data. */
FMT_CONSTEXPR
auto
data
()
FMT_NOEXCEPT
->
T
*
{
return
ptr_
;
}
FMT_CONSTEXPR
auto
data
()
noexcept
->
T
*
{
return
ptr_
;
}
/** Returns a pointer to the buffer data. */
FMT_CONSTEXPR
auto
data
()
const
FMT_NOEXCEPT
->
const
T
*
{
return
ptr_
;
}
FMT_CONSTEXPR
auto
data
()
const
noexcept
->
const
T
*
{
return
ptr_
;
}
/** Clears this buffer. */
void
clear
()
{
size_
=
0
;
}
...
...
@@ -1495,12 +1492,12 @@ class appender : public std::back_insert_iterator<detail::buffer<char>> {
public:
using
std
::
back_insert_iterator
<
detail
::
buffer
<
char
>>::
back_insert_iterator
;
appender
(
base
it
)
FMT_NOEXCEPT
:
base
(
it
)
{}
appender
(
base
it
)
noexcept
:
base
(
it
)
{}
using
_Unchecked_type
=
appender
;
// Mark iterator as checked.
auto
operator
++
()
FMT_NOEXCEPT
->
appender
&
{
return
*
this
;
}
auto
operator
++
()
noexcept
->
appender
&
{
return
*
this
;
}
auto
operator
++
(
int
)
FMT_NOEXCEPT
->
appender
{
return
*
this
;
}
auto
operator
++
(
int
)
noexcept
->
appender
{
return
*
this
;
}
};
// A formatting argument. It is a trivially copyable/constructible type to
...
...
@@ -1546,7 +1543,7 @@ template <typename Context> class basic_format_arg {
constexpr
basic_format_arg
()
:
type_
(
detail
::
type
::
none_type
)
{}
constexpr
explicit
operator
bool
()
const
FMT_NOEXCEPT
{
constexpr
explicit
operator
bool
()
const
noexcept
{
return
type_
!=
detail
::
type
::
none_type
;
}
...
...
@@ -1656,7 +1653,7 @@ class locale_ref {
constexpr
locale_ref
()
:
locale_
(
nullptr
)
{}
template
<
typename
Locale
>
explicit
locale_ref
(
const
Locale
&
loc
);
explicit
operator
bool
()
const
FMT_NOEXCEPT
{
return
locale_
!=
nullptr
;
}
explicit
operator
bool
()
const
noexcept
{
return
locale_
!=
nullptr
;
}
template
<
typename
Locale
>
auto
get
()
const
->
Locale
;
};
...
...
include/fmt/format-inl.h
View file @
c2850055
This diff is collapsed.
Click to expand it.
include/fmt/format.h
View file @
c2850055
...
...
@@ -735,8 +735,7 @@ class basic_memory_buffer final : public detail::buffer<T> {
of the other object to it.
\endrst
*/
FMT_CONSTEXPR20
basic_memory_buffer
(
basic_memory_buffer
&&
other
)
FMT_NOEXCEPT
{
FMT_CONSTEXPR20
basic_memory_buffer
(
basic_memory_buffer
&&
other
)
noexcept
{
move
(
other
);
}
...
...
@@ -745,8 +744,7 @@ class basic_memory_buffer final : public detail::buffer<T> {
Moves the content of the other ``basic_memory_buffer`` object to this one.
\endrst
*/
auto
operator
=
(
basic_memory_buffer
&&
other
)
FMT_NOEXCEPT
->
basic_memory_buffer
&
{
auto
operator
=
(
basic_memory_buffer
&&
other
)
noexcept
->
basic_memory_buffer
&
{
FMT_ASSERT
(
this
!=
&
other
,
""
);
deallocate
();
move
(
other
);
...
...
@@ -820,7 +818,7 @@ class FMT_API format_error : public std::runtime_error {
format_error
&
operator
=
(
const
format_error
&
)
=
default
;
format_error
(
format_error
&&
)
=
default
;
format_error
&
operator
=
(
format_error
&&
)
=
default
;
~
format_error
()
FMT_NOEXCEPT
override
FMT_MSC_DEFAULT
;
~
format_error
()
noexcept
override
FMT_MSC_DEFAULT
;
};
/**
...
...
@@ -1039,15 +1037,11 @@ FMT_CONSTEXPR20 inline auto count_digits(uint32_t n) -> int {
return
count_digits_fallback
(
n
);
}
template
<
typename
Int
>
constexpr
auto
digits10
()
FMT_NOEXCEPT
->
int
{
template
<
typename
Int
>
constexpr
auto
digits10
()
noexcept
->
int
{
return
std
::
numeric_limits
<
Int
>::
digits10
;
}
template
<
>
constexpr
auto
digits10
<
int128_t
>
()
FMT_NOEXCEPT
->
int
{
return
38
;
}
template
<
>
constexpr
auto
digits10
<
uint128_t
>
()
FMT_NOEXCEPT
->
int
{
return
38
;
}
template
<
>
constexpr
auto
digits10
<
int128_t
>
()
noexcept
->
int
{
return
38
;
}
template
<
>
constexpr
auto
digits10
<
uint128_t
>
()
noexcept
->
int
{
return
38
;
}
template
<
typename
Char
>
struct
thousands_sep_result
{
std
::
string
grouping
;
...
...
@@ -1254,8 +1248,7 @@ template <typename T> struct decimal_fp {
int
exponent
;
};
template
<
typename
T
>
FMT_API
auto
to_decimal
(
T
x
)
FMT_NOEXCEPT
->
decimal_fp
<
T
>
;
template
<
typename
T
>
FMT_API
auto
to_decimal
(
T
x
)
noexcept
->
decimal_fp
<
T
>
;
}
// namespace dragonbox
template
<
typename
T
>
...
...
@@ -2435,10 +2428,10 @@ auto vformat(const Locale& loc, basic_string_view<Char> format_str,
using
format_func
=
void
(
*
)(
detail
::
buffer
<
char
>&
,
int
,
const
char
*
);
FMT_API
void
format_error_code
(
buffer
<
char
>&
out
,
int
error_code
,
string_view
message
)
FMT_NOEXCEPT
;
string_view
message
)
noexcept
;
FMT_API
void
report_error
(
format_func
func
,
int
error_code
,
const
char
*
message
)
FMT_NOEXCEPT
;
const
char
*
message
)
noexcept
;
FMT_END_DETAIL_NAMESPACE
FMT_API
auto
vsystem_error
(
int
error_code
,
string_view
format_str
,
...
...
@@ -2484,12 +2477,11 @@ auto system_error(int error_code, format_string<T...> fmt, T&&... args)
\endrst
*/
FMT_API
void
format_system_error
(
detail
::
buffer
<
char
>&
out
,
int
error_code
,
const
char
*
message
)
FMT_NOEXCEPT
;
const
char
*
message
)
noexcept
;
// Reports a system error without throwing an exception.
// Can be used to report errors from destructors.
FMT_API
void
report_system_error
(
int
error_code
,
const
char
*
message
)
FMT_NOEXCEPT
;
FMT_API
void
report_system_error
(
int
error_code
,
const
char
*
message
)
noexcept
;
/** Fast integer formatter. */
class
format_int
{
...
...
include/fmt/os.h
View file @
c2850055
...
...
@@ -141,7 +141,7 @@ template <typename Char> struct formatter<std::error_code, Char> {
};
#ifdef _WIN32
FMT_API
const
std
::
error_category
&
system_category
()
FMT_NOEXCEPT
;
FMT_API
const
std
::
error_category
&
system_category
()
noexcept
;
FMT_BEGIN_DETAIL_NAMESPACE
// A converter from UTF-16 to UTF-8.
...
...
@@ -165,7 +165,7 @@ class utf16_to_utf8 {
};
FMT_API
void
format_windows_error
(
buffer
<
char
>&
out
,
int
error_code
,
const
char
*
message
)
FMT_NOEXCEPT
;
const
char
*
message
)
noexcept
;
FMT_END_DETAIL_NAMESPACE
FMT_API
std
::
system_error
vwindows_error
(
int
error_code
,
string_view
format_str
,
...
...
@@ -207,10 +207,9 @@ std::system_error windows_error(int error_code, string_view message,
// Reports a Windows error without throwing an exception.
// Can be used to report errors from destructors.
FMT_API
void
report_windows_error
(
int
error_code
,
const
char
*
message
)
FMT_NOEXCEPT
;
FMT_API
void
report_windows_error
(
int
error_code
,
const
char
*
message
)
noexcept
;
#else
inline
const
std
::
error_category
&
system_category
()
FMT_NOEXCEPT
{
inline
const
std
::
error_category
&
system_category
()
noexcept
{
return
std
::
system_category
();
}
#endif // _WIN32
...
...
@@ -237,13 +236,13 @@ class buffered_file {
void
operator
=
(
const
buffered_file
&
)
=
delete
;
// Constructs a buffered_file object which doesn't represent any file.
buffered_file
()
FMT_NOEXCEPT
:
file_
(
nullptr
)
{}
buffered_file
()
noexcept
:
file_
(
nullptr
)
{}
// Destroys the object closing the file it represents if any.
FMT_API
~
buffered_file
()
FMT_NOEXCEPT
;
FMT_API
~
buffered_file
()
noexcept
;
public:
buffered_file
(
buffered_file
&&
other
)
FMT_NOEXCEPT
:
file_
(
other
.
file_
)
{
buffered_file
(
buffered_file
&&
other
)
noexcept
:
file_
(
other
.
file_
)
{
other
.
file_
=
nullptr
;
}
...
...
@@ -261,7 +260,7 @@ class buffered_file {
FMT_API
void
close
();
// Returns the pointer to a FILE object representing this file.
FILE
*
get
()
const
FMT_NOEXCEPT
{
return
file_
;
}
FILE
*
get
()
const
noexcept
{
return
file_
;
}
// We place parentheses around fileno to workaround a bug in some versions
// of MinGW that define fileno as a macro.
...
...
@@ -280,7 +279,7 @@ class buffered_file {
#if FMT_USE_FCNTL
// A file. Closed file is represented by a file object with descriptor -1.
// Methods that are not declared with
FMT_NOEXCEPT
may throw
// Methods that are not declared with
noexcept
may throw
// fmt::system_error in case of failure. Note that some errors such as
// closing the file multiple times will cause a crash on Windows rather
// than an exception. You can get standard behavior by overriding the
...
...
@@ -304,7 +303,7 @@ class file {
};
// Constructs a file object which doesn't represent any file.
file
()
FMT_NOEXCEPT
:
fd_
(
-
1
)
{}
file
()
noexcept
:
fd_
(
-
1
)
{}
// Opens a file and constructs a file object representing this file.
FMT_API
file
(
cstring_view
path
,
int
oflag
);
...
...
@@ -313,7 +312,7 @@ class file {
file
(
const
file
&
)
=
delete
;
void
operator
=
(
const
file
&
)
=
delete
;
file
(
file
&&
other
)
FMT_NOEXCEPT
:
fd_
(
other
.
fd_
)
{
other
.
fd_
=
-
1
;
}
file
(
file
&&
other
)
noexcept
:
fd_
(
other
.
fd_
)
{
other
.
fd_
=
-
1
;
}
// Move assignment is not noexcept because close may throw.
file
&
operator
=
(
file
&&
other
)
{
...
...
@@ -324,10 +323,10 @@ class file {
}
// Destroys the object closing the file it represents if any.
FMT_API
~
file
()
FMT_NOEXCEPT
;
FMT_API
~
file
()
noexcept
;
// Returns the file descriptor.
int
descriptor
()
const
FMT_NOEXCEPT
{
return
fd_
;
}
int
descriptor
()
const
noexcept
{
return
fd_
;
}
// Closes the file.
FMT_API
void
close
();
...
...
@@ -352,7 +351,7 @@ class file {
// Makes fd be the copy of this file descriptor, closing fd first if
// necessary.
FMT_API
void
dup2
(
int
fd
,
std
::
error_code
&
ec
)
FMT_NOEXCEPT
;
FMT_API
void
dup2
(
int
fd
,
std
::
error_code
&
ec
)
noexcept
;
// Creates a pipe setting up read_end and write_end file objects for reading
// and writing respectively.
...
...
include/fmt/ranges.h
View file @
c2850055
...
...
@@ -203,7 +203,7 @@ using make_index_sequence = make_integer_sequence<size_t, N>;
#endif
template
<
class
Tuple
,
class
F
,
size_t
...
Is
>
void
for_each
(
index_sequence
<
Is
...
>
,
Tuple
&&
tup
,
F
&&
f
)
FMT_NOEXCEPT
{
void
for_each
(
index_sequence
<
Is
...
>
,
Tuple
&&
tup
,
F
&&
f
)
noexcept
{
using
std
::
get
;
// using free function get<I>(T) now.
const
int
_
[]
=
{
0
,
((
void
)
f
(
get
<
Is
>
(
tup
)),
0
)...};
...
...
src/format.cc
View file @
c2850055
...
...
@@ -70,10 +70,10 @@ int format_float(char* buf, std::size_t size, const char* format, int precision,
:
snprintf_ptr
(
buf
,
size
,
format
,
precision
,
value
);
}
template
FMT_API
dragonbox
::
decimal_fp
<
float
>
dragonbox
::
to_decimal
(
float
x
)
FMT_NOEXCEPT
;
template
FMT_API
dragonbox
::
decimal_fp
<
double
>
dragonbox
::
to_decimal
(
double
x
)
FMT_NOEXCEPT
;
template
FMT_API
dragonbox
::
decimal_fp
<
float
>
dragonbox
::
to_decimal
(
float
x
)
noexcept
;
template
FMT_API
dragonbox
::
decimal_fp
<
double
>
dragonbox
::
to_decimal
(
double
x
)
noexcept
;
}
// namespace detail
// Workaround a bug in MSVC2013 that prevents instantiation of format_float.
...
...
src/os.cc
View file @
c2850055
...
...
@@ -107,7 +107,7 @@ class system_message {
unsigned
long
result_
;
wchar_t
*
message_
;
static
bool
is_whitespace
(
wchar_t
c
)
FMT_NOEXCEPT
{
static
bool
is_whitespace
(
wchar_t
c
)
noexcept
{
return
c
==
L' '
||
c
==
L'\n'
||
c
==
L'\r'
||
c
==
L'\t'
||
c
==
L'\0'
;
}
...
...
@@ -126,15 +126,15 @@ class system_message {
}
}
~
system_message
()
{
LocalFree
(
message_
);
}
explicit
operator
bool
()
const
FMT_NOEXCEPT
{
return
result_
!=
0
;
}
operator
basic_string_view
<
wchar_t
>
()
const
FMT_NOEXCEPT
{
explicit
operator
bool
()
const
noexcept
{
return
result_
!=
0
;
}
operator
basic_string_view
<
wchar_t
>
()
const
noexcept
{
return
basic_string_view
<
wchar_t
>
(
message_
,
result_
);
}
};
class
utf8_system_category
final
:
public
std
::
error_category
{
public:
const
char
*
name
()
const
FMT_NOEXCEPT
override
{
return
"system"
;
}
const
char
*
name
()
const
noexcept
override
{
return
"system"
;
}
std
::
string
message
(
int
error_code
)
const
override
{
system_message
msg
(
error_code
);
if
(
msg
)
{
...
...
@@ -149,7 +149,7 @@ class utf8_system_category final : public std::error_category {
}
// namespace detail
FMT_API
const
std
::
error_category
&
system_category
()
FMT_NOEXCEPT
{
FMT_API
const
std
::
error_category
&
system_category
()
noexcept
{
static
const
detail
::
utf8_system_category
category
;
return
category
;
}
...
...
@@ -161,7 +161,7 @@ std::system_error vwindows_error(int err_code, string_view format_str,
}
void
detail
::
format_windows_error
(
detail
::
buffer
<
char
>&
out
,
int
error_code
,
const
char
*
message
)
FMT_NOEXCEPT
{
const
char
*
message
)
noexcept
{
FMT_TRY
{
system_message
msg
(
error_code
);
if
(
msg
)
{
...
...
@@ -176,12 +176,12 @@ void detail::format_windows_error(detail::buffer<char>& out, int error_code,
format_error_code
(
out
,
error_code
,
message
);
}
void
report_windows_error
(
int
error_code
,
const
char
*
message
)
FMT_NOEXCEPT
{
void
report_windows_error
(
int
error_code
,
const
char
*
message
)
noexcept
{
report_error
(
detail
::
format_windows_error
,
error_code
,
message
);
}
#endif // _WIN32
buffered_file
::~
buffered_file
()
FMT_NOEXCEPT
{
buffered_file
::~
buffered_file
()
noexcept
{
if
(
file_
&&
FMT_SYSTEM
(
fclose
(
file_
))
!=
0
)
report_system_error
(
errno
,
"cannot close file"
);
}
...
...
@@ -225,7 +225,7 @@ file::file(cstring_view path, int oflag) {
FMT_THROW
(
system_error
(
errno
,
"cannot open file {}"
,
path
.
c_str
()));
}
file
::~
file
()
FMT_NOEXCEPT
{
file
::~
file
()
noexcept
{
// Don't retry close in case of EINTR!
// See http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html
if
(
fd_
!=
-
1
&&
FMT_POSIX_CALL
(
close
(
fd_
))
!=
0
)
...
...
@@ -299,7 +299,7 @@ void file::dup2(int fd) {
}
}
void
file
::
dup2
(
int
fd
,
std
::
error_code
&
ec
)
FMT_NOEXCEPT
{
void
file
::
dup2
(
int
fd
,
std
::
error_code
&
ec
)
noexcept
{
int
result
=
0
;
FMT_RETRY
(
result
,
FMT_POSIX_CALL
(
dup2
(
fd_
,
fd
)));
if
(
result
==
-
1
)
ec
=
std
::
error_code
(
errno
,
std
::
generic_category
());
...
...
test/format-test.cc
View file @
c2850055
...
...
@@ -325,7 +325,7 @@ template <typename Allocator, size_t MaxSize>
class
max_size_allocator
:
public
Allocator
{
public:
using
typename
Allocator
::
value_type
;
size_t
max_size
()
const
FMT_NOEXCEPT
{
return
MaxSize
;
}
size_t
max_size
()
const
noexcept
{
return
MaxSize
;
}
value_type
*
allocate
(
size_t
n
)
{
if
(
n
>
max_size
())
{
throw
std
::
length_error
(
"size > max_size"
);
...
...
test/gtest-extra.cc
View file @
c2850055
...
...
@@ -23,7 +23,7 @@ output_redirect::output_redirect(FILE* f) : file_(f) {
write_end
.
dup2
(
fd
);
}
output_redirect
::~
output_redirect
()
FMT_NOEXCEPT
{
output_redirect
::~
output_redirect
()
noexcept
{
try
{
restore
();
}
catch
(
const
std
::
exception
&
e
)
{
...
...
test/gtest-extra.h
View file @
c2850055
...
...
@@ -83,7 +83,7 @@ class output_redirect {
public:
explicit
output_redirect
(
FILE
*
file
);
~
output_redirect
()
FMT_NOEXCEPT
;
~
output_redirect
()
noexcept
;
output_redirect
(
const
output_redirect
&
)
=
delete
;
void
operator
=
(
const
output_redirect
&
)
=
delete
;
...
...
test/module-test.cc
View file @
c2850055
...
...
@@ -36,7 +36,6 @@
#else
# define FMT_USE_FCNTL 0
#endif
#define FMT_NOEXCEPT noexcept
#if defined(_WIN32) && !defined(__MINGW32__)
# define FMT_POSIX(call) _##call
#else
...
...
test/xchar-test.cc
View file @
c2850055
...
...
@@ -236,14 +236,14 @@ namespace fake_qt {
class
QString
{
public:
QString
(
const
wchar_t
*
s
)
:
s_
(
s
)
{}
const
wchar_t
*
utf16
()
const
FMT_NOEXCEPT
{
return
s_
.
data
();
}
int
size
()
const
FMT_NOEXCEPT
{
return
static_cast
<
int
>
(
s_
.
size
());
}
const
wchar_t
*
utf16
()
const
noexcept
{
return
s_
.
data
();
}
int
size
()
const
noexcept
{
return
static_cast
<
int
>
(
s_
.
size
());
}
private:
std
::
wstring
s_
;
};
fmt
::
basic_string_view
<
wchar_t
>
to_string_view
(
const
QString
&
s
)
FMT_NOEXCEPT
{
fmt
::
basic_string_view
<
wchar_t
>
to_string_view
(
const
QString
&
s
)
noexcept
{
return
{
s
.
utf16
(),
static_cast
<
size_t
>
(
s
.
size
())};
}
}
// namespace fake_qt
...
...
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