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
0fc7bd15
Commit
0fc7bd15
authored
Sep 28, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ambiguity for types with dodgy conversions
parent
b4f1988c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
include/fmt/ranges.h
include/fmt/ranges.h
+2
-1
test/ranges-test.cc
test/ranges-test.cc
+17
-4
No files found.
include/fmt/ranges.h
View file @
0fc7bd15
...
@@ -246,7 +246,8 @@ template <typename T, typename Char> struct is_range {
...
@@ -246,7 +246,8 @@ template <typename T, typename Char> struct is_range {
static
FMT_CONSTEXPR_DECL
const
bool
value
=
static
FMT_CONSTEXPR_DECL
const
bool
value
=
internal
::
is_range_
<
T
>::
value
&&
internal
::
is_range_
<
T
>::
value
&&
!
internal
::
is_like_std_string
<
T
>::
value
&&
!
internal
::
is_like_std_string
<
T
>::
value
&&
!
std
::
is_convertible
<
T
,
std
::
basic_string
<
Char
>>::
value
;
!
std
::
is_convertible
<
T
,
std
::
basic_string
<
Char
>>::
value
&&
!
std
::
is_constructible
<
internal
::
std_string_view
<
Char
>
,
T
>::
value
;
};
};
template
<
typename
RangeT
,
typename
Char
>
template
<
typename
RangeT
,
typename
Char
>
...
...
test/ranges-test.cc
View file @
0fc7bd15
...
@@ -9,13 +9,13 @@
...
@@ -9,13 +9,13 @@
// All Rights Reserved
// All Rights Reserved
// {fmt} support for ranges, containers and types tuple interface.
// {fmt} support for ranges, containers and types tuple interface.
/// Check if 'if constexpr' is supported.
#include "fmt/ranges.h"
#include "gtest.h"
// Check if 'if constexpr' is supported.
#if (__cplusplus > 201402L) || \
#if (__cplusplus > 201402L) || \
(defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910)
(defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910)
# include "fmt/ranges.h"
# include "gtest.h"
# include <array>
# include <array>
# include <map>
# include <map>
# include <string>
# include <string>
...
@@ -119,3 +119,16 @@ TEST(RangesTest, PathLike) {
...
@@ -119,3 +119,16 @@ TEST(RangesTest, PathLike) {
#endif // (__cplusplus > 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >
#endif // (__cplusplus > 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >
// 201402L && _MSC_VER >= 1910)
// 201402L && _MSC_VER >= 1910)
#ifdef FMT_USE_STRING_VIEW
struct
string_like
{
const
char
*
begin
();
const
char
*
end
();
explicit
operator
fmt
::
string_view
()
const
{
return
"foo"
;
}
explicit
operator
std
::
string_view
()
const
{
return
"foo"
;
}
};
TEST
(
RangesTest
,
FormatStringLike
)
{
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
"{}"
,
string_like
()));
}
#endif // FMT_USE_STRING_VIEW
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