add test to compile without exceptions

pull/2347/head
Niels Lohmann 2020-08-10 09:48:11 +02:00
parent 1b28a58280
commit 4080d0b1a4
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
4 changed files with 16 additions and 5 deletions

View File

@ -4,7 +4,6 @@ on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:

View File

@ -5,6 +5,8 @@
#include <utility> // pair
#include <vector> // vector
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
@ -64,7 +66,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
throw std::out_of_range("key not found");
JSON_THROW(std::out_of_range("key not found"));
}
const T& at(const Key& key) const
@ -77,7 +79,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
throw std::out_of_range("key not found");
JSON_THROW(std::out_of_range("key not found"));
}
size_type erase(const Key& key)

View File

@ -16395,6 +16395,9 @@ class serializer
#include <utility> // pair
#include <vector> // vector
// #include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
@ -16454,7 +16457,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
throw std::out_of_range("key not found");
JSON_THROW(std::out_of_range("key not found"));
}
const T& at(const Key& key) const
@ -16467,7 +16470,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
}
}
throw std::out_of_range("key not found");
JSON_THROW(std::out_of_range("key not found"));
}
size_type erase(const Key& key)

View File

@ -11,3 +11,10 @@ target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json)
add_executable(without_namespace_target main.cpp)
target_link_libraries(without_namespace_target nlohmann_json)
if(NOT MSVC)
add_executable(without_exceptions main.cpp)
target_link_libraries(without_exceptions nlohmann_json::nlohmann_json)
target_compile_definitions(without_exceptions PRIVATE JSON_NOEXCEPTION)
target_compile_options(without_exceptions PRIVATE -fno-exceptions)
endif()