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
ccd3e8bb
Commit
ccd3e8bb
authored
Oct 27, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make is_constructible public (#918)
parent
43731538
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
49 deletions
+50
-49
include/fmt/core.h
include/fmt/core.h
+10
-10
test/core-test.cc
test/core-test.cc
+40
-0
test/format-test.cc
test/format-test.cc
+0
-39
No files found.
include/fmt/core.h
View file @
ccd3e8bb
...
@@ -208,14 +208,6 @@ FMT_CONSTEXPR typename std::make_unsigned<Int>::type to_unsigned(Int value) {
...
@@ -208,14 +208,6 @@ FMT_CONSTEXPR typename std::make_unsigned<Int>::type to_unsigned(Int value) {
return
static_cast
<
typename
std
::
make_unsigned
<
Int
>::
type
>
(
value
);
return
static_cast
<
typename
std
::
make_unsigned
<
Int
>::
type
>
(
value
);
}
}
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 405
template
<
typename
...
T
>
struct
is_constructible
:
std
::
false_type
{};
#else
template
<
typename
...
T
>
struct
is_constructible
:
std
::
is_constructible
<
T
...
>
{};
#endif
/** A contiguous memory buffer with an optional growing ability. */
/** A contiguous memory buffer with an optional growing ability. */
template
<
typename
T
>
template
<
typename
T
>
class
basic_buffer
{
class
basic_buffer
{
...
@@ -337,6 +329,14 @@ template <typename T>
...
@@ -337,6 +329,14 @@ template <typename T>
struct
no_formatter_error
:
std
::
false_type
{};
struct
no_formatter_error
:
std
::
false_type
{};
}
// namespace internal
}
// namespace internal
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 405
template
<
typename
...
T
>
struct
is_constructible
:
std
::
false_type
{};
#else
template
<
typename
...
T
>
struct
is_constructible
:
std
::
is_constructible
<
T
...
>
{};
#endif
/**
/**
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
subset of the API. ``fmt::basic_string_view`` is used for format strings even
subset of the API. ``fmt::basic_string_view`` is used for format strings even
...
@@ -725,7 +725,7 @@ inline typename std::enable_if<
...
@@ -725,7 +725,7 @@ inline typename std::enable_if<
template
<
typename
C
,
typename
T
,
typename
Char
=
typename
C
::
char_type
>
template
<
typename
C
,
typename
T
,
typename
Char
=
typename
C
::
char_type
>
inline
typename
std
::
enable_if
<
inline
typename
std
::
enable_if
<
i
nternal
::
i
s_constructible
<
basic_string_view
<
Char
>
,
T
>::
value
&&
is_constructible
<
basic_string_view
<
Char
>
,
T
>::
value
&&
!
internal
::
is_string
<
T
>::
value
,
!
internal
::
is_string
<
T
>::
value
,
init
<
C
,
basic_string_view
<
Char
>
,
string_type
>>::
type
init
<
C
,
basic_string_view
<
Char
>
,
string_type
>>::
type
make_value
(
const
T
&
val
)
{
return
basic_string_view
<
Char
>
(
val
);
}
make_value
(
const
T
&
val
)
{
return
basic_string_view
<
Char
>
(
val
);
}
...
@@ -734,7 +734,7 @@ template <typename C, typename T, typename Char = typename C::char_type>
...
@@ -734,7 +734,7 @@ template <typename C, typename T, typename Char = typename C::char_type>
inline
typename
std
::
enable_if
<
inline
typename
std
::
enable_if
<
!
convert_to_int
<
T
,
Char
>::
value
&&
!
std
::
is_same
<
T
,
Char
>::
value
&&
!
convert_to_int
<
T
,
Char
>::
value
&&
!
std
::
is_same
<
T
,
Char
>::
value
&&
!
std
::
is_convertible
<
T
,
basic_string_view
<
Char
>>::
value
&&
!
std
::
is_convertible
<
T
,
basic_string_view
<
Char
>>::
value
&&
!
i
nternal
::
i
s_constructible
<
basic_string_view
<
Char
>
,
T
>::
value
&&
!
is_constructible
<
basic_string_view
<
Char
>
,
T
>::
value
&&
!
internal
::
is_string
<
T
>::
value
,
!
internal
::
is_string
<
T
>::
value
,
// Implicit conversion to std::string is not handled here because it's
// Implicit conversion to std::string is not handled here because it's
// unsafe: https://github.com/fmtlib/fmt/issues/729
// unsafe: https://github.com/fmtlib/fmt/issues/729
...
...
test/core-test.cc
View file @
ccd3e8bb
...
@@ -569,3 +569,43 @@ TEST(CoreTest, FormatForeignStrings) {
...
@@ -569,3 +569,43 @@ TEST(CoreTest, FormatForeignStrings) {
EXPECT_EQ
(
fmt
::
format
(
QString
(
L"{}"
),
my_string
<
wchar_t
>
(
L"42"
)),
L"42"
);
EXPECT_EQ
(
fmt
::
format
(
QString
(
L"{}"
),
my_string
<
wchar_t
>
(
L"42"
)),
L"42"
);
EXPECT_EQ
(
fmt
::
format
(
my_string
<
wchar_t
>
(
L"{}"
),
QString
(
L"42"
)),
L"42"
);
EXPECT_EQ
(
fmt
::
format
(
my_string
<
wchar_t
>
(
L"{}"
),
QString
(
L"42"
)),
L"42"
);
}
}
struct
implicitly_convertible_to_string_view
{
operator
fmt
::
string_view
()
const
{
return
"foo"
;
}
};
TEST
(
FormatterTest
,
FormatImplicitlyConvertibleToStringView
)
{
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
"{}"
,
implicitly_convertible_to_string_view
()));
}
// std::is_constructible is broken in MSVC until version 2015.
#if FMT_USE_EXPLICIT && (!FMT_MSC_VER || FMT_MSC_VER >= 1900)
struct
explicitly_convertible_to_string_view
{
explicit
operator
fmt
::
string_view
()
const
{
return
"foo"
;
}
};
TEST
(
FormatterTest
,
FormatExplicitlyConvertibleToStringView
)
{
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
"{}"
,
explicitly_convertible_to_string_view
()));
}
struct
explicitly_convertible_to_wstring_view
{
explicit
operator
fmt
::
wstring_view
()
const
{
return
L"foo"
;
}
};
TEST
(
FormatterTest
,
FormatExplicitlyConvertibleToWStringView
)
{
EXPECT_EQ
(
L"foo"
,
fmt
::
format
(
L"{}"
,
explicitly_convertible_to_wstring_view
()));
}
struct
explicitly_convertible_to_string_like
{
template
<
typename
String
,
typename
=
typename
std
::
enable_if
<
std
::
is_constructible
<
String
,
const
char
*
,
std
::
size_t
>
::
value
>::
type
>
FMT_EXPLICIT
operator
String
()
const
{
return
String
(
"foo"
,
3u
);
}
};
TEST
(
FormatterTest
,
FormatExplicitlyConvertibleToStringLike
)
{
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
"{}"
,
explicitly_convertible_to_string_like
()));
}
#endif
test/format-test.cc
View file @
ccd3e8bb
...
@@ -1549,45 +1549,6 @@ TEST(FormatterTest, FormatStdStringView) {
...
@@ -1549,45 +1549,6 @@ TEST(FormatterTest, FormatStdStringView) {
}
}
#endif
#endif
struct
implicitly_convertible_to_string_view
{
operator
fmt
::
string_view
()
const
{
return
"foo"
;
}
};
TEST
(
FormatterTest
,
FormatImplicitlyConvertibleToStringView
)
{
EXPECT_EQ
(
"foo"
,
format
(
"{}"
,
implicitly_convertible_to_string_view
()));
}
// std::is_constructible is broken in MSVC until version 2015.
#if FMT_USE_EXPLICIT && (!FMT_MSC_VER || FMT_MSC_VER >= 1900)
struct
explicitly_convertible_to_string_view
{
explicit
operator
fmt
::
string_view
()
const
{
return
"foo"
;
}
};
TEST
(
FormatterTest
,
FormatExplicitlyConvertibleToStringView
)
{
EXPECT_EQ
(
"foo"
,
format
(
"{}"
,
explicitly_convertible_to_string_view
()));
}
struct
explicitly_convertible_to_wstring_view
{
explicit
operator
fmt
::
wstring_view
()
const
{
return
L"foo"
;
}
};
TEST
(
FormatterTest
,
FormatExplicitlyConvertibleToWStringView
)
{
EXPECT_EQ
(
L"foo"
,
format
(
L"{}"
,
explicitly_convertible_to_wstring_view
()));
}
struct
explicitly_convertible_to_string_like
{
template
<
typename
String
,
typename
=
typename
std
::
enable_if
<
std
::
is_constructible
<
String
,
const
char
*
,
std
::
size_t
>
::
value
>::
type
>
FMT_EXPLICIT
operator
String
()
const
{
return
String
(
"foo"
,
3u
);
}
};
TEST
(
FormatterTest
,
FormatExplicitlyConvertibleToStringLike
)
{
EXPECT_EQ
(
"foo"
,
format
(
"{}"
,
explicitly_convertible_to_string_like
()));
}
#endif
FMT_BEGIN_NAMESPACE
FMT_BEGIN_NAMESPACE
template
<
>
template
<
>
struct
formatter
<
Date
>
{
struct
formatter
<
Date
>
{
...
...
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