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
bdda4d60
Commit
bdda4d60
authored
Oct 28, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify compile-time strings
parent
5ee1a4bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
include/fmt/core.h
include/fmt/core.h
+5
-5
include/fmt/format.h
include/fmt/format.h
+14
-14
No files found.
include/fmt/core.h
View file @
bdda4d60
...
@@ -472,11 +472,11 @@ struct compile_string {};
...
@@ -472,11 +472,11 @@ struct compile_string {};
template
<
typename
S
>
template
<
typename
S
>
struct
is_compile_string
:
std
::
is_base_of
<
compile_string
,
S
>
{};
struct
is_compile_string
:
std
::
is_base_of
<
compile_string
,
S
>
{};
template
<
typename
S
,
typename
Enable
=
typename
std
::
enable_if
<
is_compile_string
<
S
>
::
value
>::
type
>
template
<
inline
auto
to_string_view
(
const
S
&
s
)
->
basic_string_view
<
typename
S
::
char_type
>
{
typename
S
,
type
def
typename
S
::
char_type
char_type
;
type
name
Enable
=
typename
std
::
enable_if
<
is_compile_string
<
S
>
::
value
>::
type
>
return
basic_string_view
<
char_type
>
{
s
.
data
(),
s
.
size
()
-
1
};
FMT_CONSTEXPR
basic_string_view
<
typename
S
::
char_type
>
}
to_string_view
(
const
S
&
s
)
{
return
s
;
}
template
<
typename
Context
>
template
<
typename
Context
>
class
basic_format_arg
;
class
basic_format_arg
;
...
...
include/fmt/format.h
View file @
bdda4d60
...
@@ -2240,13 +2240,12 @@ FMT_CONSTEXPR bool check_format_string(
...
@@ -2240,13 +2240,12 @@ FMT_CONSTEXPR bool check_format_string(
return
true
;
return
true
;
}
}
template
<
typename
...
Args
,
typename
String
>
template
<
typename
...
Args
,
typename
S
>
typename
std
::
enable_if
<
is_compile_string
<
String
>::
value
>::
type
typename
std
::
enable_if
<
is_compile_string
<
S
>::
value
>::
type
check_format_string
(
String
format_str
)
{
check_format_string
(
S
format_str
)
{
typedef
typename
String
::
char_type
char_type
;
typedef
typename
S
::
char_type
char_t
;
FMT_CONSTEXPR_DECL
bool
invalid_format
=
FMT_CONSTEXPR_DECL
bool
invalid_format
=
internal
::
check_format_string
<
internal
::
check_format_string
<
char_type
,
internal
::
error_handler
,
Args
...
>
(
char_t
,
internal
::
error_handler
,
Args
...
>
(
to_string_view
(
format_str
));
basic_string_view
<
char_type
>
(
format_str
.
data
(),
format_str
.
size
()));
(
void
)
invalid_format
;
(
void
)
invalid_format
;
}
}
...
@@ -3649,14 +3648,15 @@ operator"" _a(const wchar_t *s, std::size_t) { return {s}; }
...
@@ -3649,14 +3648,15 @@ operator"" _a(const wchar_t *s, std::size_t) { return {s}; }
FMT_END_NAMESPACE
FMT_END_NAMESPACE
#define FMT_STRING(s) [] { \
#define FMT_STRING(s) [] { \
typedef typename std::decay<decltype(s)>::type pointer; \
typedef typename std::remove_cv<std::remove_pointer< \
struct S : fmt::compile_string { \
typename std::decay<decltype(s)>::type>::type>::type ct; \
typedef typename std::remove_cv<std::remove_pointer<pointer>::type>::type char_type;\
struct str : fmt::compile_string { \
static FMT_CONSTEXPR pointer data() { return s; } \
typedef ct char_type; \
static FMT_CONSTEXPR size_t size() { return sizeof(s) / sizeof(char_type); } \
FMT_CONSTEXPR operator fmt::basic_string_view<ct>() const { \
explicit operator fmt::basic_string_view<char_type>() const { return s; } \
return {s, sizeof(s) / sizeof(ct) - 1}; \
} \
}; \
}; \
return
S
{}; \
return
str
{}; \
}()
}()
#if defined(FMT_STRING_ALIAS) && FMT_STRING_ALIAS
#if defined(FMT_STRING_ALIAS) && FMT_STRING_ALIAS
...
...
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