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
3730b4f0
Commit
3730b4f0
authored
Jul 25, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup compile implementation
parent
25ff2efc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
58 deletions
+29
-58
include/fmt/compile.h
include/fmt/compile.h
+26
-55
test/compile-test.cc
test/compile-test.cc
+3
-3
No files found.
include/fmt/compile.h
View file @
3730b4f0
...
@@ -8,14 +8,8 @@
...
@@ -8,14 +8,8 @@
#ifndef FMT_COMPILE_H_
#ifndef FMT_COMPILE_H_
#define FMT_COMPILE_H_
#define FMT_COMPILE_H_
#ifndef FMT_HAS_CONSTRUCTIBLE_TRAITS
# define FMT_HAS_CONSTRUCTIBLE_TRAITS \
(FMT_GCC_VERSION >= 407 || FMT_CLANG_VERSION || FMT_MSC_VER)
#endif
#include "format.h"
#include <vector>
#include <vector>
#include "format.h"
FMT_BEGIN_NAMESPACE
FMT_BEGIN_NAMESPACE
...
@@ -506,12 +500,10 @@ struct compiletime_parts_provider {
...
@@ -506,12 +500,10 @@ struct compiletime_parts_provider {
template
<
typename
PartsContainer
>
template
<
typename
PartsContainer
>
struct
parts_container_concept_check
:
std
::
true_type
{
struct
parts_container_concept_check
:
std
::
true_type
{
#if FMT_HAS_CONSTRUCTIBLE_TRAITS
static_assert
(
std
::
is_copy_constructible
<
PartsContainer
>::
value
,
static_assert
(
std
::
is_copy_constructible
<
PartsContainer
>::
value
,
"PartsContainer is not copy constructible"
);
"PartsContainer is not copy constructible"
);
static_assert
(
std
::
is_move_constructible
<
PartsContainer
>::
value
,
static_assert
(
std
::
is_move_constructible
<
PartsContainer
>::
value
,
"PartsContainer is not move constructible"
);
"PartsContainer is not move constructible"
);
#endif
template
<
typename
T
,
typename
=
void
>
template
<
typename
T
,
typename
=
void
>
struct
has_format_part_type
:
std
::
false_type
{};
struct
has_format_part_type
:
std
::
false_type
{};
...
@@ -669,98 +661,77 @@ template <typename Format> struct format_tag {
...
@@ -669,98 +661,77 @@ template <typename Format> struct format_tag {
#if FMT_USE_CONSTEXPR
#if FMT_USE_CONSTEXPR
template
<
typename
Format
,
typename
...
Args
>
template
<
typename
Format
,
typename
...
Args
>
auto
do_
prepar
e
(
runtime_format_tag
,
Format
format
)
{
auto
do_
compil
e
(
runtime_format_tag
,
Format
format
)
{
return
preparator
<
Format
,
Args
...
>::
prepare
(
std
::
move
(
format
));
return
preparator
<
Format
,
Args
...
>::
prepare
(
std
::
move
(
format
));
}
}
template
<
typename
Format
,
typename
...
Args
>
template
<
typename
Format
,
typename
...
Args
>
FMT_CONSTEXPR
auto
do_
prepar
e
(
compiletime_format_tag
,
const
Format
&
format
)
{
FMT_CONSTEXPR
auto
do_
compil
e
(
compiletime_format_tag
,
const
Format
&
format
)
{
return
typename
basic_prepared_format
<
Format
,
void
,
Args
...
>::
type
(
format
);
return
typename
basic_prepared_format
<
Format
,
void
,
Args
...
>::
type
(
format
);
}
}
#else
#else
template
<
typename
Format
,
typename
...
Args
>
template
<
typename
Format
,
typename
...
Args
>
auto
do_
prepar
e
(
const
Format
&
format
)
auto
do_
compil
e
(
const
Format
&
format
)
->
decltype
(
preparator
<
Format
,
Args
...
>::
prepare
(
format
))
{
->
decltype
(
preparator
<
Format
,
Args
...
>::
prepare
(
format
))
{
return
preparator
<
Format
,
Args
...
>::
prepare
(
format
);
return
preparator
<
Format
,
Args
...
>::
prepare
(
format
);
}
}
#endif
#endif
}
// namespace internal
}
// namespace internal
template
<
typename
Char
,
typename
Container
=
std
::
vector
<
format_part
<
Char
>
>>
struct
parts_container
{
typedef
internal
::
parts_container
<
Char
,
Container
>
type
;
};
template
<
typename
Format
,
typename
PartsContainer
,
typename
...
Args
>
struct
basic_prepared_format
{
typedef
typename
internal
::
basic_prepared_format
<
Format
,
PartsContainer
,
Args
...
>::
type
type
;
};
template
<
typename
...
Args
>
struct
prepared_format
{
template
<
typename
...
Args
>
struct
prepared_format
{
typedef
typename
basic_prepared_format
<
typedef
typename
internal
::
basic_prepared_format
<
std
::
string
,
typename
parts_container
<
char
>::
type
,
Args
...
>::
type
type
;
std
::
string
,
internal
::
parts_container
<
char
>
,
Args
...
>::
type
type
;
};
};
template
<
typename
...
Args
>
struct
wprepared_format
{
template
<
typename
...
Args
>
struct
wprepared_format
{
typedef
typedef
typename
internal
::
basic_prepared_format
<
typename
basic_prepared_format
<
std
::
wstring
,
std
::
wstring
,
internal
::
parts_container
<
wchar_t
>
,
Args
...
>::
type
type
;
typename
parts_container
<
wchar_t
>::
type
,
Args
...
>::
type
type
;
};
};
template
<
typename
Char
,
typename
Container
=
std
::
vector
<
format_part
<
Char
>
>>
using
parts_container_t
=
typename
parts_container
<
Char
,
Container
>::
type
;
template
<
typename
Format
,
typename
PreparedPartsContainer
,
typename
...
Args
>
using
basic_prepared_format_t
=
typename
basic_prepared_format
<
Format
,
PreparedPartsContainer
,
Args
...
>::
type
;
template
<
typename
...
Args
>
template
<
typename
...
Args
>
using
prepared_format_t
=
using
prepared_format_t
=
typename
internal
::
basic_prepared_format
<
basic_prepared_format_t
<
std
::
string
,
parts_container
<
char
>
,
Args
...
>
;
std
::
string
,
internal
::
parts_container
<
char
>
,
Args
...
>::
type
;
template
<
typename
...
Args
>
template
<
typename
...
Args
>
using
wprepared_format_t
=
using
wprepared_format_t
=
typename
internal
::
basic_prepared_format
<
basic_prepared_format_t
<
std
::
wstring
,
parts_container
<
wchar_t
>
,
Args
...
>
;
std
::
wstring
,
internal
::
parts_container
<
wchar_t
>
,
Args
...
>::
type
;
#if FMT_USE_CONSTEXPR
#if FMT_USE_CONSTEXPR
template
<
typename
...
Args
,
typename
Format
>
template
<
typename
...
Args
,
typename
S
>
FMT_CONSTEXPR
auto
compile
(
Format
format
)
{
FMT_CONSTEXPR
auto
compile
(
S
format_str
)
{
return
internal
::
do_
prepare
<
Format
,
Args
...
>
(
return
internal
::
do_
compile
<
S
,
Args
...
>
(
typename
internal
::
format_tag
<
Format
>::
type
{},
std
::
move
(
format
));
typename
internal
::
format_tag
<
S
>::
type
{},
std
::
move
(
format_str
));
}
}
#else
#else
template
<
typename
...
Args
,
typename
Format
>
template
<
typename
...
Args
,
typename
S
>
auto
compile
(
Format
format
)
->
auto
compile
(
S
format_str
)
->
typename
internal
::
preparator
<
Format
,
Args
...
>::
prepared_format_type
{
typename
internal
::
preparator
<
S
,
Args
...
>::
prepared_format_type
{
return
internal
::
preparator
<
Format
,
Args
...
>::
prepare
(
std
::
move
(
format
));
return
internal
::
preparator
<
S
,
Args
...
>::
prepare
(
std
::
move
(
format_str
));
}
}
#endif
#endif
template
<
typename
...
Args
,
typename
Char
>
template
<
typename
...
Args
,
typename
Char
>
auto
compile
(
const
Char
*
format
)
->
auto
compile
(
const
Char
*
format
_str
)
->
typename
internal
::
preparator
<
std
::
basic_string
<
Char
>
,
typename
internal
::
preparator
<
std
::
basic_string
<
Char
>
,
Args
...
>::
prepared_format_type
{
Args
...
>::
prepared_format_type
{
return
compile
<
Args
...
>
(
internal
::
to_runtime_format
(
format
));
return
compile
<
Args
...
>
(
internal
::
to_runtime_format
(
format
_str
));
}
}
template
<
typename
...
Args
,
typename
Char
,
unsigned
N
>
template
<
typename
...
Args
,
typename
Char
,
unsigned
N
>
auto
compile
(
const
Char
(
format
)[
N
])
->
auto
compile
(
const
Char
(
format
_str
)[
N
])
->
typename
internal
::
preparator
<
std
::
basic_string
<
Char
>
,
typename
internal
::
preparator
<
std
::
basic_string
<
Char
>
,
Args
...
>::
prepared_format_type
{
Args
...
>::
prepared_format_type
{
const
auto
view
=
basic_string_view
<
Char
>
(
format
,
N
);
const
auto
view
=
basic_string_view
<
Char
>
(
format
_str
,
N
);
return
compile
<
Args
...
>
(
internal
::
to_runtime_format
(
view
));
return
compile
<
Args
...
>
(
internal
::
to_runtime_format
(
view
));
}
}
template
<
typename
...
Args
,
typename
Char
>
template
<
typename
...
Args
,
typename
Char
>
auto
compile
(
basic_string_view
<
Char
>
format
)
->
auto
compile
(
basic_string_view
<
Char
>
format
_str
)
->
typename
internal
::
preparator
<
std
::
basic_string
<
Char
>
,
typename
internal
::
preparator
<
std
::
basic_string
<
Char
>
,
Args
...
>::
prepared_format_type
{
Args
...
>::
prepared_format_type
{
return
compile
<
Args
...
>
(
internal
::
to_runtime_format
(
format
));
return
compile
<
Args
...
>
(
internal
::
to_runtime_format
(
format
_str
));
}
}
FMT_END_NAMESPACE
FMT_END_NAMESPACE
...
...
test/compile-test.cc
View file @
3730b4f0
...
@@ -486,9 +486,9 @@ TEST(PrepareTest, ReusedPreparedFormatType) {
...
@@ -486,9 +486,9 @@ TEST(PrepareTest, ReusedPreparedFormatType) {
TEST
(
PrepareTest
,
UserProvidedPartsContainerUnderlyingContainer
)
{
TEST
(
PrepareTest
,
UserProvidedPartsContainerUnderlyingContainer
)
{
typedef
fmt
::
format_part
<
char
>
format_part
;
typedef
fmt
::
format_part
<
char
>
format_part
;
typedef
fmt
::
parts_container
<
char
,
std
::
list
<
format_part
>>::
type
typedef
fmt
::
internal
::
parts_container
<
char
,
std
::
list
<
format_part
>>
parts_container
;
parts_container
;
typedef
fmt
::
basic_prepared_format
<
std
::
string
,
parts_container
,
std
::
string
,
typedef
fmt
::
internal
::
basic_prepared_format
<
std
::
string
,
parts_container
,
std
::
string
,
int
>::
type
prepared_format
;
int
>::
type
prepared_format
;
prepared_format
prepared
=
fmt
::
compile
<
prepared_format
>
(
"The {} is {}."
);
prepared_format
prepared
=
fmt
::
compile
<
prepared_format
>
(
"The {} is {}."
);
...
@@ -532,7 +532,7 @@ class custom_parts_container {
...
@@ -532,7 +532,7 @@ class custom_parts_container {
};
};
TEST
(
PrepareTest
,
UserProvidedPartsContainer
)
{
TEST
(
PrepareTest
,
UserProvidedPartsContainer
)
{
typedef
fmt
::
basic_prepared_format
<
std
::
string
,
custom_parts_container
,
typedef
fmt
::
internal
::
basic_prepared_format
<
std
::
string
,
custom_parts_container
,
std
::
string
,
int
>::
type
prepared_format
;
std
::
string
,
int
>::
type
prepared_format
;
prepared_format
prepared
=
fmt
::
compile
<
prepared_format
>
(
"The {} is {}."
);
prepared_format
prepared
=
fmt
::
compile
<
prepared_format
>
(
"The {} is {}."
);
...
...
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