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
8ca6e76d
Commit
8ca6e76d
authored
Nov 04, 2017
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect user-defined literal templates
parent
a7e98616
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
include/fmt/format.h
include/fmt/format.h
+29
-0
test/format-test.cc
test/format-test.cc
+6
-0
No files found.
include/fmt/format.h
View file @
8ca6e76d
...
...
@@ -79,6 +79,10 @@
# endif
#endif
#ifdef __clang__
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
#endif
#if defined(__INTEL_COMPILER)
# define FMT_ICC_VERSION __INTEL_COMPILER
#elif defined(__ICL)
...
...
@@ -88,6 +92,7 @@
#if defined(__clang__) && !defined(FMT_ICC_VERSION)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
# pragma clang diagnostic ignored "-Wgnu-string-literal-operator-template"
# pragma clang diagnostic ignored "-Wpadded"
#endif
...
...
@@ -185,6 +190,13 @@
# endif
#endif
#if FMT_USE_USER_DEFINED_LITERALS && \
(FMT_GCC_VERSION >= 600 || FMT_CLANG_VERSION >= 304)
# define FMT_UDL_TEMPLATE 1
#else
# define FMT_UDL_TEMPLATE 0
#endif
#ifndef FMT_ASSERT
# define FMT_ASSERT(condition, message) assert((condition) && message)
#endif
...
...
@@ -3839,10 +3851,27 @@ operator"" _a(const char *s, std::size_t) { return {s}; }
inline
internal
::
UdlArg
<
wchar_t
>
operator
""
_a
(
const
wchar_t
*
s
,
std
::
size_t
)
{
return
{
s
};
}
# if FMT_UDL_TEMPLATE
template
<
typename
Char
,
Char
...
CHARS
>
struct
udl_formatter
{
template
<
typename
...
Args
>
std
::
string
operator
()(
const
Args
&
...
args
)
const
{
const
Char
s
[]
=
{
CHARS
...};
// TODO
return
s
;
}
};
template
<
typename
Char
,
Char
...
CHARS
>
constexpr
auto
operator
""
_format
()
{
return
udl_formatter
<
Char
,
CHARS
...
>
();
}
# endif
}
// inline namespace literals
}
// namespace fmt
#endif // FMT_USE_USER_DEFINED_LITERALS
#ifdef FMT_HEADER_ONLY
# define FMT_FUNC inline
# include "format.cc"
...
...
test/format-test.cc
View file @
8ca6e76d
...
...
@@ -1812,3 +1812,9 @@ TEST(FormatTest, ConstexprParseFormatString) {
static_assert
(
parse_string
(
"{foo}"
),
""
);
static_assert
(
parse_string
(
"{:}"
),
""
);
}
#if FMT_UDL_TEMPLATE
TEST
(
FormatTest
,
UdlTemplate
)
{
EXPECT_EQ
(
"foo"
,
"foo"
_format
());
}
#endif
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