Merge pull request #2347 from nlohmann/no_exceptions

Fix code to work without exceptions
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 b8c6d51..bfa5ed6 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -16395,6 +16395,9 @@
 #include <utility> // pair
 #include <vector> // vector
 
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
 namespace nlohmann
 {
 
@@ -16454,7 +16457,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
@@ -16467,7 +16470,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()