-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to use string_view from std::experimental #2364
Changes from all commits
fba2e9d
df5943d
1943399
5eddcc1
5a0d8f4
f7f75c8
7b627c7
5f566f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2048,6 +2048,25 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |
#define JSON_HAS_CPP_14 | ||
#endif | ||
|
||
namespace nlohmann { | ||
namespace std_aliases { } | ||
using namespace std_aliases; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This introduces a mix of qualified and unqualified names in source code. E.g. we have
This allows regular qualification approach ( |
||
} | ||
|
||
#if defined(JSON_HAS_CPP_17) | ||
#if __has_include(<string_view>) | ||
#include <string_view> | ||
namespace nlohmann::std_aliases { | ||
using std::string_view; | ||
} | ||
#elif __has_include(<experimental/string_view>) | ||
#include <experimental/string_view> | ||
namespace nlohmann::std_aliases { | ||
using std::experimental::string_view; | ||
} | ||
#endif | ||
#endif | ||
|
||
// disable float-equal warnings on GCC/clang | ||
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) | ||
#pragma GCC diagnostic push | ||
|
@@ -19736,7 +19755,7 @@ class basic_json | |
!detail::is_basic_json<ValueType>::value | ||
&& !std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value | ||
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) | ||
&& !std::is_same<ValueType, typename std::string_view>::value | ||
&& !std::is_same<ValueType, string_view>::value | ||
#endif | ||
&& detail::is_detected<detail::get_template_function, const basic_json_t&, ValueType>::value | ||
, int >::type = 0 > | ||
|
@@ -21938,12 +21957,8 @@ class basic_json | |
} | ||
|
||
// add element to array (perfect forwarding) | ||
#ifdef JSON_HAS_CPP_17 | ||
return m_value.array->emplace_back(std::forward<Args>(args)...); | ||
#else | ||
m_value.array->emplace_back(std::forward<Args>(args)...); | ||
return m_value.array->back(); | ||
#endif | ||
} | ||
|
||
/*! | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to specify
CXX_STANDARD=20
, however,cmake
v3.9.2 at Travis doesn't support such option. Anyway, this setting had no effect before.