implot_demos icon indicating copy to clipboard operation
implot_demos copied to clipboard

clang-cl error in 'json.hpp'

Open gvanem opened this issue 1 year ago • 0 comments

While compiling tests/benchmark.cpp using clang-cl (ver. 16.0.1), I'm facing this issue: https://github.com/ocornut/imgui/issues/6386 Errors from clang-cl:

In file included from tests/benchmark.cpp:9:
./3rdparty\json.hpp(16773,25): error: variable 'end' with type 'auto *const' has incompatible initializer of type
      'std::_Array_iterator<char, 64>'
            auto* const end = std::remove(number_buffer.begin(),
                        ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./3rdparty\json.hpp(16783,25): error: variable 'dec_pos' with type 'auto *const' has incompatible initializer of type
      'std::_Array_iterator<char, 64>'
            auto* const dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
                        ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This has been fixed in: https://github.com/nlohmann/json/pull/3082/files. The gist of it was simply:

--- a/3rdparty/json.hpp 2022-08-12 10:02:19
+++ b/3rdparty/json.hpp 2023-05-22 08:42:20
@@ -16770,7 +16770,7 @@
         // erase thousands separator
         if (thousands_sep != '\0')
         {
-            auto* const end = std::remove(number_buffer.begin(),
+            const auto end = std::remove(number_buffer.begin(),
                                           number_buffer.begin() + len, thousands_sep);
             std::fill(end, number_buffer.end(), '\0');
             JSON_ASSERT((end - number_buffer.begin()) <= len);
@@ -16780,7 +16780,7 @@
         // convert decimal point to '.'
         if (decimal_point != '\0' && decimal_point != '.')
         {
-            auto* const dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
+            const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
             if (dec_pos != number_buffer.end())
             {
                 *dec_pos = '.';

So can 3rdparty/json.hpp please be updated for this error?

gvanem avatar May 22 '23 06:05 gvanem