Commit 2a5b8cad authored by tzik's avatar tzik Committed by Commit Bot

Avoid overloading std::swap around OpenVR's Json::Value

std::swap overloads without exception specification are warned by cl.exe
and clang-cl on C++17 mode, that belongs to -Wmicrosoft-exception-spec:
  ../../third_party/openvr/src/src/json/json.h(1227,13):  error: 'swap<Json::Value, void>' is missing exception specification 'noexcept' [-Werror,-Wmicrosoft-exception-spec]
  inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }

As ADL based dispatch is preferred for this case, and upstream
jsoncpp[1] already does it, this CL adopts it too.

[1]: Upstream jsoncpp commit: https://github.com/open-source-parsers/jsoncpp/commit/1d95628ba84189cd81fbabf70add5c1baf2912c5
OpenVR SDK has not rolled to this.

Change-Id: I82494ef5aca5ff0df431f94f65ae8439c41977b5
Reviewed-on: https://chromium-review.googlesource.com/1179422Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584428}
parent 02dde600
......@@ -18,6 +18,8 @@ of JSON_FAIL_MESSAGE because "cannot use 'throw' with exceptions disabled".
openvr.h has been modified to remove dllimport/dllexport when building a
non-component build so this can be built as a static library.
Redefined VRLog to avoid logspam on startup.
json.h has been modified to convert a std::swap overload to Json::swap, so that
we can avoid -Wmicrosoft-exception-spec warning.
Copy the correct files with these commands:
copy %openvrsdk%\README.md %chromium%\src\third_party\openvr\src
......
......@@ -1218,15 +1218,11 @@ public:
pointer operator->() const { return &deref(); }
};
} // namespace Json
namespace std {
/// Specialize std::swap() for Json::Value.
template<>
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
inline void swap(Value& a, Value& b) {
a.swap(b);
}
} // namespace Json
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop)
......
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