Unverified Commit 64873fb5 by Viktor Kirilov Committed by GitHub

Merge branch 'develop' into doctest

parents b4def6dc b21c04c9
...@@ -23,8 +23,7 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF) ...@@ -23,8 +23,7 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
## CONFIGURATION ## CONFIGURATION
## ##
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME}) set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}" set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}" CACHE INTERNAL "")
CACHE INTERNAL "")
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include") set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include")
set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in") set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in")
......
...@@ -13,10 +13,11 @@ template <typename It, typename = void> ...@@ -13,10 +13,11 @@ template <typename It, typename = void>
struct iterator_types {}; struct iterator_types {};
template <typename It> template <typename It>
struct iterator_types< struct iterator_types <
It, It,
void_t<typename It::difference_type, typename It::value_type, typename It::pointer, void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
typename It::reference, typename It::iterator_category>> { typename It::reference, typename It::iterator_category >>
{
using difference_type = typename It::difference_type; using difference_type = typename It::difference_type;
using value_type = typename It::value_type; using value_type = typename It::value_type;
using pointer = typename It::pointer; using pointer = typename It::pointer;
...@@ -32,13 +33,14 @@ struct iterator_traits ...@@ -32,13 +33,14 @@ struct iterator_traits
}; };
template <typename T> template <typename T>
struct iterator_traits<T, enable_if_t<!std::is_pointer<T>::value>> struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
: iterator_types<T> : iterator_types<T>
{ {
}; };
template <typename T> template <typename T>
struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>> { struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
{
using iterator_category = std::random_access_iterator_tag; using iterator_category = std::random_access_iterator_tag;
using value_type = T; using value_type = T;
using difference_type = ptrdiff_t; using difference_type = ptrdiff_t;
......
...@@ -18,6 +18,14 @@ ...@@ -18,6 +18,14 @@
#endif #endif
#endif #endif
// C++ language standard detection
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_14
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
#define JSON_HAS_CPP_14
#endif
// disable float-equal warnings on GCC/clang // disable float-equal warnings on GCC/clang
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push #pragma GCC diagnostic push
...@@ -42,7 +50,11 @@ ...@@ -42,7 +50,11 @@
// allow for portable nodiscard warnings // allow for portable nodiscard warnings
#if defined(__has_cpp_attribute) #if defined(__has_cpp_attribute)
#if __has_cpp_attribute(nodiscard) #if __has_cpp_attribute(nodiscard)
#if defined(__clang__) && !defined(JSON_HAS_CPP_17) // issue #1535
#define JSON_NODISCARD
#else
#define JSON_NODISCARD [[nodiscard]] #define JSON_NODISCARD [[nodiscard]]
#endif
#elif __has_cpp_attribute(gnu::warn_unused_result) #elif __has_cpp_attribute(gnu::warn_unused_result)
#define JSON_NODISCARD [[gnu::warn_unused_result]] #define JSON_NODISCARD [[gnu::warn_unused_result]]
#else #else
...@@ -95,14 +107,6 @@ ...@@ -95,14 +107,6 @@
#define JSON_UNLIKELY(x) x #define JSON_UNLIKELY(x) x
#endif #endif
// C++ language standard detection
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_14
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
#define JSON_HAS_CPP_14
#endif
/*! /*!
@brief macro to briefly define a mapping between an enum and JSON @brief macro to briefly define a mapping between an enum and JSON
@def NLOHMANN_JSON_SERIALIZE_ENUM @def NLOHMANN_JSON_SERIALIZE_ENUM
......
...@@ -24,43 +24,43 @@ using number_integer_function_t = ...@@ -24,43 +24,43 @@ using number_integer_function_t =
template <typename T, typename Unsigned> template <typename T, typename Unsigned>
using number_unsigned_function_t = using number_unsigned_function_t =
decltype(std::declval<T &>().number_unsigned(std::declval<Unsigned>())); decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
template <typename T, typename Float, typename String> template <typename T, typename Float, typename String>
using number_float_function_t = decltype(std::declval<T &>().number_float( using number_float_function_t = decltype(std::declval<T&>().number_float(
std::declval<Float>(), std::declval<const String &>())); std::declval<Float>(), std::declval<const String&>()));
template <typename T, typename String> template <typename T, typename String>
using string_function_t = using string_function_t =
decltype(std::declval<T &>().string(std::declval<String &>())); decltype(std::declval<T&>().string(std::declval<String&>()));
template <typename T> template <typename T>
using start_object_function_t = using start_object_function_t =
decltype(std::declval<T &>().start_object(std::declval<std::size_t>())); decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
template <typename T, typename String> template <typename T, typename String>
using key_function_t = using key_function_t =
decltype(std::declval<T &>().key(std::declval<String &>())); decltype(std::declval<T&>().key(std::declval<String&>()));
template <typename T> template <typename T>
using end_object_function_t = decltype(std::declval<T &>().end_object()); using end_object_function_t = decltype(std::declval<T&>().end_object());
template <typename T> template <typename T>
using start_array_function_t = using start_array_function_t =
decltype(std::declval<T &>().start_array(std::declval<std::size_t>())); decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
template <typename T> template <typename T>
using end_array_function_t = decltype(std::declval<T &>().end_array()); using end_array_function_t = decltype(std::declval<T&>().end_array());
template <typename T, typename Exception> template <typename T, typename Exception>
using parse_error_function_t = decltype(std::declval<T &>().parse_error( using parse_error_function_t = decltype(std::declval<T&>().parse_error(
std::declval<std::size_t>(), std::declval<const std::string &>(), std::declval<std::size_t>(), std::declval<const std::string&>(),
std::declval<const Exception &>())); std::declval<const Exception&>()));
template <typename SAX, typename BasicJsonType> template <typename SAX, typename BasicJsonType>
struct is_sax struct is_sax
{ {
private: private:
static_assert(is_basic_json<BasicJsonType>::value, static_assert(is_basic_json<BasicJsonType>::value,
"BasicJsonType must be of type basic_json<...>"); "BasicJsonType must be of type basic_json<...>");
...@@ -70,7 +70,7 @@ private: ...@@ -70,7 +70,7 @@ private:
using string_t = typename BasicJsonType::string_t; using string_t = typename BasicJsonType::string_t;
using exception_t = typename BasicJsonType::exception; using exception_t = typename BasicJsonType::exception;
public: public:
static constexpr bool value = static constexpr bool value =
is_detected_exact<bool, null_function_t, SAX>::value && is_detected_exact<bool, null_function_t, SAX>::value &&
is_detected_exact<bool, boolean_function_t, SAX>::value && is_detected_exact<bool, boolean_function_t, SAX>::value &&
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
template <typename SAX, typename BasicJsonType> template <typename SAX, typename BasicJsonType>
struct is_sax_static_asserts struct is_sax_static_asserts
{ {
private: private:
static_assert(is_basic_json<BasicJsonType>::value, static_assert(is_basic_json<BasicJsonType>::value,
"BasicJsonType must be of type basic_json<...>"); "BasicJsonType must be of type basic_json<...>");
...@@ -102,7 +102,7 @@ private: ...@@ -102,7 +102,7 @@ private:
using string_t = typename BasicJsonType::string_t; using string_t = typename BasicJsonType::string_t;
using exception_t = typename BasicJsonType::exception; using exception_t = typename BasicJsonType::exception;
public: public:
static_assert(is_detected_exact<bool, null_function_t, SAX>::value, static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
"Missing/invalid function: bool null()"); "Missing/invalid function: bool null()");
static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value, static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
......
...@@ -469,6 +469,14 @@ class other_error : public exception ...@@ -469,6 +469,14 @@ class other_error : public exception
#endif #endif
#endif #endif
// C++ language standard detection
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_14
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
#define JSON_HAS_CPP_14
#endif
// disable float-equal warnings on GCC/clang // disable float-equal warnings on GCC/clang
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push #pragma GCC diagnostic push
...@@ -493,7 +501,11 @@ class other_error : public exception ...@@ -493,7 +501,11 @@ class other_error : public exception
// allow for portable nodiscard warnings // allow for portable nodiscard warnings
#if defined(__has_cpp_attribute) #if defined(__has_cpp_attribute)
#if __has_cpp_attribute(nodiscard) #if __has_cpp_attribute(nodiscard)
#if defined(__clang__) && !defined(JSON_HAS_CPP_17) // issue #1535
#define JSON_NODISCARD
#else
#define JSON_NODISCARD [[nodiscard]] #define JSON_NODISCARD [[nodiscard]]
#endif
#elif __has_cpp_attribute(gnu::warn_unused_result) #elif __has_cpp_attribute(gnu::warn_unused_result)
#define JSON_NODISCARD [[gnu::warn_unused_result]] #define JSON_NODISCARD [[gnu::warn_unused_result]]
#else #else
...@@ -546,14 +558,6 @@ class other_error : public exception ...@@ -546,14 +558,6 @@ class other_error : public exception
#define JSON_UNLIKELY(x) x #define JSON_UNLIKELY(x) x
#endif #endif
// C++ language standard detection
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_14
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
#define JSON_HAS_CPP_14
#endif
/*! /*!
@brief macro to briefly define a mapping between an enum and JSON @brief macro to briefly define a mapping between an enum and JSON
@def NLOHMANN_JSON_SERIALIZE_ENUM @def NLOHMANN_JSON_SERIALIZE_ENUM
......
...@@ -6,7 +6,7 @@ option(JSON_Coverage "Build test suite with coverage information" OFF) ...@@ -6,7 +6,7 @@ option(JSON_Coverage "Build test suite with coverage information" OFF)
if(JSON_Sanitizer) if(JSON_Sanitizer)
message(STATUS "Building test suite with Clang sanitizer") message(STATUS "Building test suite with Clang sanitizer")
if(NOT MSVC) if(NOT MSVC)
set(CMAKE_CXX_FLAGS "-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "-g -O2 -fsanitize=address -fsanitize=undefined -fsanitize=integer -fsanitize=nullability -fno-omit-frame-pointer")
endif() endif()
endif() endif()
...@@ -64,7 +64,6 @@ set_target_properties(doctest_main PROPERTIES ...@@ -64,7 +64,6 @@ set_target_properties(doctest_main PROPERTIES
COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>" COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>" COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
) )
if (${CMAKE_VERSION} VERSION_LESS "3.8.0") if (${CMAKE_VERSION} VERSION_LESS "3.8.0")
target_compile_features(doctest_main PUBLIC cxx_range_for) target_compile_features(doctest_main PUBLIC cxx_range_for)
else() else()
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
#!/bin/sh
wget -N https://raw.githubusercontent.com/cpplint/cpplint/master/cpplint.py
wget -N https://raw.githubusercontent.com/cpplint/cpplint/master/LICENSE
wget -N https://raw.githubusercontent.com/cpplint/cpplint/master/README.rst
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment