add test to compile without exceptions

parent 1b28a582
...@@ -4,7 +4,6 @@ on: [push, pull_request] ...@@ -4,7 +4,6 @@ on: [push, pull_request]
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include <utility> // pair #include <utility> // pair
#include <vector> // vector #include <vector> // vector
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann namespace nlohmann
{ {
...@@ -64,7 +66,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>, ...@@ -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 const T& at(const Key& key) const
...@@ -77,7 +79,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>, ...@@ -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) size_type erase(const Key& key)
......
...@@ -16395,6 +16395,9 @@ class serializer ...@@ -16395,6 +16395,9 @@ class serializer
#include <utility> // pair #include <utility> // pair
#include <vector> // vector #include <vector> // vector
// #include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann namespace nlohmann
{ {
...@@ -16454,7 +16457,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>, ...@@ -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 const T& at(const Key& key) const
...@@ -16467,7 +16470,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>, ...@@ -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) size_type erase(const Key& key)
......
...@@ -11,3 +11,10 @@ target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) ...@@ -11,3 +11,10 @@ target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json)
add_executable(without_namespace_target main.cpp) add_executable(without_namespace_target main.cpp)
target_link_libraries(without_namespace_target nlohmann_json) 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()
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