-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta: fix is_compatible/constructible traits
The previous version relied on the existence of an 'iterator' type. As mentioned in comments, this is not the proper way to do it and causes issues with certain types (e.g. views from range-v3). Add a 'is_range' trait that properly detects the return type of 'begin'/'end', and use it in instead.
- Loading branch information
1 parent
0b345b2
commit 7fb7fc8
Showing
9 changed files
with
792 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <nlohmann/detail/meta/can_call_std.hpp> | ||
|
||
namespace nlohmann | ||
{ | ||
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <nlohmann/detail/meta/can_call_std.hpp> | ||
|
||
namespace nlohmann | ||
{ | ||
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include <nlohmann/detail/meta/detected.hpp> | ||
|
||
// source: https://stackoverflow.com/a/26745591 | ||
|
||
#define CAN_CALL_STD_FUNC_IMPL(std_name) \ | ||
namespace detail { \ | ||
using std::std_name; \ | ||
\ | ||
template<typename... T> \ | ||
using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \ | ||
} \ | ||
\ | ||
namespace detail2 { \ | ||
struct std_name##_tag \ | ||
{ \ | ||
}; \ | ||
\ | ||
template<typename... T> \ | ||
std_name##_tag std_name(T&&...); \ | ||
\ | ||
template<typename... T> \ | ||
using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \ | ||
\ | ||
template<typename... T> \ | ||
struct would_call_std_##std_name \ | ||
{ \ | ||
static constexpr auto const value = ::nlohmann::detail:: \ | ||
is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \ | ||
}; \ | ||
} \ | ||
\ | ||
template<typename... T> \ | ||
struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \ | ||
{ \ | ||
} |
Oops, something went wrong.