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
dcd282bb
Commit
dcd282bb
authored
Oct 09, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace qualify calls to get
parent
9c14474d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
include/fmt/compile.h
include/fmt/compile.h
+7
-4
test/compile-test.cc
test/compile-test.cc
+17
-0
No files found.
include/fmt/compile.h
View file @
dcd282bb
...
@@ -190,7 +190,7 @@ constexpr const auto& get([[maybe_unused]] const T& first,
...
@@ -190,7 +190,7 @@ constexpr const auto& get([[maybe_unused]] const T& first,
if
constexpr
(
N
==
0
)
if
constexpr
(
N
==
0
)
return
first
;
return
first
;
else
else
return
get
<
N
-
1
>
(
rest
...);
return
detail
::
get
<
N
-
1
>
(
rest
...);
}
}
template
<
typename
Char
,
typename
...
Args
>
template
<
typename
Char
,
typename
...
Args
>
...
@@ -202,7 +202,8 @@ constexpr int get_arg_index_by_name(basic_string_view<Char> name,
...
@@ -202,7 +202,8 @@ constexpr int get_arg_index_by_name(basic_string_view<Char> name,
template
<
int
N
,
typename
>
struct
get_type_impl
;
template
<
int
N
,
typename
>
struct
get_type_impl
;
template
<
int
N
,
typename
...
Args
>
struct
get_type_impl
<
N
,
type_list
<
Args
...
>>
{
template
<
int
N
,
typename
...
Args
>
struct
get_type_impl
<
N
,
type_list
<
Args
...
>>
{
using
type
=
remove_cvref_t
<
decltype
(
get
<
N
>
(
std
::
declval
<
Args
>
()...))
>
;
using
type
=
remove_cvref_t
<
decltype
(
detail
::
get
<
N
>
(
std
::
declval
<
Args
>
()...))
>
;
};
};
template
<
int
N
,
typename
T
>
template
<
int
N
,
typename
T
>
...
@@ -242,7 +243,7 @@ template <typename Char> struct code_unit {
...
@@ -242,7 +243,7 @@ template <typename Char> struct code_unit {
// This ensures that the argument type is convertible to `const T&`.
// This ensures that the argument type is convertible to `const T&`.
template
<
typename
T
,
int
N
,
typename
...
Args
>
template
<
typename
T
,
int
N
,
typename
...
Args
>
constexpr
const
T
&
get_arg_checked
(
const
Args
&
...
args
)
{
constexpr
const
T
&
get_arg_checked
(
const
Args
&
...
args
)
{
const
auto
&
arg
=
get
<
N
>
(
args
...);
const
auto
&
arg
=
detail
::
get
<
N
>
(
args
...);
if
constexpr
(
detail
::
is_named_arg
<
remove_cvref_t
<
decltype
(
arg
)
>>
())
{
if
constexpr
(
detail
::
is_named_arg
<
remove_cvref_t
<
decltype
(
arg
)
>>
())
{
return
arg
.
value
;
return
arg
.
value
;
}
else
{
}
else
{
...
@@ -399,7 +400,9 @@ template <typename Char> struct arg_id_handler {
...
@@ -399,7 +400,9 @@ template <typename Char> struct arg_id_handler {
return
0
;
return
0
;
}
}
constexpr
void
on_error
(
const
char
*
message
)
{
FMT_THROW
(
format_error
(
message
));
}
constexpr
void
on_error
(
const
char
*
message
)
{
FMT_THROW
(
format_error
(
message
));
}
};
};
template
<
typename
Char
>
struct
parse_arg_id_result
{
template
<
typename
Char
>
struct
parse_arg_id_result
{
...
...
test/compile-test.cc
View file @
dcd282bb
...
@@ -59,6 +59,23 @@ TEST(compile_test, compile_fallback) {
...
@@ -59,6 +59,23 @@ TEST(compile_test, compile_fallback) {
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
42
));
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
42
));
}
}
struct
type_with_get
{
template
<
int
>
friend
void
get
(
type_with_get
);
};
FMT_BEGIN_NAMESPACE
template
<
>
struct
formatter
<
type_with_get
>
:
formatter
<
int
>
{
template
<
typename
FormatContext
>
auto
format
(
type_with_get
,
FormatContext
&
ctx
)
->
decltype
(
ctx
.
out
())
{
return
formatter
<
int
>::
format
(
42
,
ctx
);
}
};
FMT_END_NAMESPACE
TEST
(
compile_test
,
compile_type_with_get
)
{
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
type_with_get
()));
}
#ifdef __cpp_if_constexpr
#ifdef __cpp_if_constexpr
struct
test_formattable
{};
struct
test_formattable
{};
...
...
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