Merge pull request #2347 from nlohmann/no_exceptions
Fix code to work without exceptions
This commit is contained in:
commit
37ce871eeb
1
.github/workflows/ubuntu.yml
vendored
1
.github/workflows/ubuntu.yml
vendored
@ -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 @@
|
|||||||
#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>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|||||||
#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>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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()
|
||||||
|
Loading…
Reference in New Issue
Block a user