Merge pull request #2349 from nlohmann/issue2348
Remove -Wimplicit-fallthrough warning
diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml
index 2eefc1c..1a47a88 100644
--- a/.github/workflows/ubuntu.yml
+++ b/.github/workflows/ubuntu.yml
@@ -4,7 +4,6 @@
jobs:
build:
-
runs-on: ubuntu-latest
steps:
diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp
index 5767909..7dd6445 100644
--- a/include/nlohmann/ordered_map.hpp
+++ b/include/nlohmann/ordered_map.hpp
@@ -5,6 +5,8 @@
#include <utility> // pair
#include <vector> // vector
+#include <nlohmann/detail/macro_scope.hpp>
+
namespace nlohmann
{
@@ -64,7 +66,7 @@
}
}
- 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 @@
}
}
- throw std::out_of_range("key not found");
+ JSON_THROW(std::out_of_range("key not found"));
}
size_type erase(const Key& key)
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index 07ced71..7d107f2 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -16397,6 +16397,9 @@
#include <utility> // pair
#include <vector> // vector
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
namespace nlohmann
{
@@ -16456,7 +16459,7 @@
}
}
- throw std::out_of_range("key not found");
+ JSON_THROW(std::out_of_range("key not found"));
}
const T& at(const Key& key) const
@@ -16469,7 +16472,7 @@
}
}
- throw std::out_of_range("key not found");
+ JSON_THROW(std::out_of_range("key not found"));
}
size_type erase(const Key& key)
diff --git a/test/cmake_add_subdirectory/project/CMakeLists.txt b/test/cmake_add_subdirectory/project/CMakeLists.txt
index 21357b6..caab6c4 100644
--- a/test/cmake_add_subdirectory/project/CMakeLists.txt
+++ b/test/cmake_add_subdirectory/project/CMakeLists.txt
@@ -11,3 +11,10 @@
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()