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
f19d8f96
Commit
f19d8f96
authored
Aug 14, 2016
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error reporting (#357)
parent
2bf59a97
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
34 deletions
+46
-34
fmt/format.h
fmt/format.h
+38
-7
fmt/ostream.h
fmt/ostream.h
+2
-2
fmt/posix.h
fmt/posix.h
+0
-19
fmt/time.h
fmt/time.h
+2
-2
test/format-test.cc
test/format-test.cc
+2
-2
test/util-test.cc
test/util-test.cc
+2
-2
No files found.
fmt/format.h
View file @
f19d8f96
...
...
@@ -1115,13 +1115,16 @@ template<class T, class F>
struct
Conditional
<
false
,
T
,
F
>
{
typedef
F
type
;
};
// For bcc32 which doesn't understand ! in template arguments.
template
<
bool
>
template
<
bool
>
struct
Not
{
enum
{
value
=
0
};
};
template
<
>
template
<
>
struct
Not
<
false
>
{
enum
{
value
=
1
};
};
template
<
typename
T
,
T
>
struct
LConvCheck
{
template
<
typename
T
>
struct
False
{
enum
{
value
=
0
};
};
template
<
typename
T
,
T
>
struct
LConvCheck
{
LConvCheck
(
int
)
{}
};
...
...
@@ -1136,6 +1139,35 @@ inline StringRef thousands_sep(
inline
fmt
::
StringRef
thousands_sep
(...)
{
return
""
;
}
#define FMT_CONCAT(a, b) a##b
#if FMT_GCC_VERSION >= 407
# define FMT_UNUSED __attribute__((unused))
#else
# define FMT_UNUSED
#endif
#ifndef FMT_USE_STATIC_ASSERT
# define FMT_USE_STATIC_ASSERT 0
#endif
#if FMT_USE_STATIC_ASSERT || FMT_HAS_FEATURE(cxx_static_assert) || \
(FMT_GCC_VERSION >= 403 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1600
# define FMT_STATIC_ASSERT(cond, message) static_assert(cond, message)
#else
# define FMT_CONCAT_(a, b) FMT_CONCAT(a, b)
# define FMT_STATIC_ASSERT(cond, message) \
typedef int FMT_CONCAT_(Assert, __LINE__)[(cond) ? 1 : -1] FMT_UNUSED
#endif
template
<
typename
Formatter
,
typename
Char
,
typename
T
>
void
format_arg
(
Formatter
&
,
const
Char
*
,
const
T
&
)
{
FMT_STATIC_ASSERT
(
False
<
T
>::
value
,
"Cannot format argument. To enable the use of ostream "
"operator<< include fmt/ostream.h. Otherwise provide "
"an overload of format_arg."
);
}
// Makes an Arg object from any type.
template
<
typename
Formatter
>
class
MakeValue
:
public
Arg
{
...
...
@@ -1179,9 +1211,9 @@ class MakeValue : public Arg {
template
<
typename
T
>
static
void
format_custom_arg
(
void
*
formatter
,
const
void
*
arg
,
void
*
format_str_ptr
)
{
format
(
*
static_cast
<
Formatter
*>
(
formatter
),
*
static_cast
<
const
Char
**>
(
format_str_ptr
),
*
static_cast
<
const
T
*>
(
arg
));
format
_arg
(
*
static_cast
<
Formatter
*>
(
formatter
),
*
static_cast
<
const
Char
**>
(
format_str_ptr
),
*
static_cast
<
const
T
*>
(
arg
));
}
public:
...
...
@@ -3323,7 +3355,6 @@ void arg(WStringRef, const internal::NamedArg<Char>&) FMT_DELETED_OR_UNDEFINED;
#define FMT_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define FMT_RSEQ_N() 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
#define FMT_CONCAT(a, b) a##b
#define FMT_FOR_EACH_(N, f, ...) \
FMT_EXPAND(FMT_CONCAT(FMT_FOR_EACH, N)(f, __VA_ARGS__))
#define FMT_FOR_EACH(f, ...) \
...
...
fmt/ostream.h
View file @
f19d8f96
...
...
@@ -73,8 +73,8 @@ void write(std::ostream &os, Writer &w);
// Formats a value.
template
<
typename
Char
,
typename
ArgFormatter
,
typename
T
>
void
format
(
BasicFormatter
<
Char
,
ArgFormatter
>
&
f
,
const
Char
*&
format_str
,
const
T
&
value
)
{
void
format
_arg
(
BasicFormatter
<
Char
,
ArgFormatter
>
&
f
,
const
Char
*&
format_str
,
const
T
&
value
)
{
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
internal
::
FormatBuf
<
Char
>
format_buf
(
buffer
);
...
...
fmt/posix.h
View file @
f19d8f96
...
...
@@ -51,25 +51,6 @@
# endif
#endif
#if FMT_GCC_VERSION >= 407
# define FMT_UNUSED __attribute__((unused))
#else
# define FMT_UNUSED
#endif
#ifndef FMT_USE_STATIC_ASSERT
# define FMT_USE_STATIC_ASSERT 0
#endif
#if FMT_USE_STATIC_ASSERT || FMT_HAS_FEATURE(cxx_static_assert) || \
(FMT_GCC_VERSION >= 403 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1600
# define FMT_STATIC_ASSERT(cond, message) static_assert(cond, message)
#else
# define FMT_CONCAT_(a, b) FMT_CONCAT(a, b)
# define FMT_STATIC_ASSERT(cond, message) \
typedef int FMT_CONCAT_(Assert, __LINE__)[(cond) ? 1 : -1] FMT_UNUSED
#endif
// Retries the expression while it evaluates to error_result and errno
// equals to EINTR.
#ifndef _WIN32
...
...
fmt/time.h
View file @
f19d8f96
...
...
@@ -15,8 +15,8 @@
namespace
fmt
{
template
<
typename
ArgFormatter
>
void
format
(
BasicFormatter
<
char
,
ArgFormatter
>
&
f
,
const
char
*&
format_str
,
const
std
::
tm
&
tm
)
{
void
format
_arg
(
BasicFormatter
<
char
,
ArgFormatter
>
&
f
,
const
char
*&
format_str
,
const
std
::
tm
&
tm
)
{
if
(
*
format_str
==
':'
)
++
format_str
;
const
char
*
end
=
format_str
;
...
...
test/format-test.cc
View file @
f19d8f96
...
...
@@ -1366,7 +1366,7 @@ TEST(FormatterTest, FormatCStringRef) {
EXPECT_EQ
(
"test"
,
format
(
"{0}"
,
CStringRef
(
"test"
)));
}
void
format
(
fmt
::
BasicFormatter
<
char
>
&
f
,
const
char
*
,
const
Date
&
d
)
{
void
format
_arg
(
fmt
::
BasicFormatter
<
char
>
&
f
,
const
char
*
,
const
Date
&
d
)
{
f
.
writer
()
<<
d
.
year
()
<<
'-'
<<
d
.
month
()
<<
'-'
<<
d
.
day
();
}
...
...
@@ -1379,7 +1379,7 @@ TEST(FormatterTest, FormatCustom) {
class
Answer
{};
template
<
typename
Char
>
void
format
(
fmt
::
BasicFormatter
<
Char
>
&
f
,
const
Char
*
,
Answer
)
{
void
format
_arg
(
fmt
::
BasicFormatter
<
Char
>
&
f
,
const
Char
*
,
Answer
)
{
f
.
writer
()
<<
"42"
;
}
...
...
test/util-test.cc
View file @
f19d8f96
...
...
@@ -64,7 +64,7 @@ namespace {
struct
Test
{};
template
<
typename
Char
>
void
format
(
fmt
::
BasicFormatter
<
Char
>
&
f
,
const
Char
*
,
Test
)
{
void
format
_arg
(
fmt
::
BasicFormatter
<
Char
>
&
f
,
const
Char
*
,
Test
)
{
f
.
writer
()
<<
"test"
;
}
...
...
@@ -581,7 +581,7 @@ struct CustomFormatter {
typedef
char
Char
;
};
void
format
(
CustomFormatter
&
,
const
char
*&
s
,
const
Test
&
)
{
void
format
_arg
(
CustomFormatter
&
,
const
char
*&
s
,
const
Test
&
)
{
s
=
"custom_format"
;
}
...
...
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