AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Apache License 2.0
2.71k stars 660 forks source link

[BUG] NanoVDB line fails with syntax error in /std:c++20 #1521

Open wilkesreid opened 2 years ago

wilkesreid commented 2 years ago

Environment

Operating System: Windows 10 Pro Version / Commit SHA: current master HEAD Other: Visual Studio 2022 using C++20

Describe the bug

Using ISO C++20 Standard (/std:c++20) causes the following errors in Visual Studio 2022:

Error C2760 syntax error: ')' was unexpected here; expected ';' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255  
Error C2760 syntax error: 'const' was unexpected here; expected ')' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255  
Error C3329 syntax error: expected 'identifier' not ')' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255  
Error C3878 syntax error: unexpected token ')' following 'expression_statement' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255  
Error C3878 syntax error: unexpected token '>' following 'simple_declaration' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255    

The actual line in GridBuilder.h causing the syntax error

I believe this documentation is related to the error.

To Reproduce

Steps to reproduce the behavior:

  1. Using the environment specified above, attempt to build a C++ file having #include <nanovdb/util/GridBuilder.h>, or in my case, #include <nanovdb/util/OpenToNanoVDB.h> which eventually includes GridBuilder.h.

Expected behavior

No syntax errors, as is seen on C++17 and earlier

kmuseth commented 2 years ago

Isn’t it simply the fact that std::result_of is removed in C++20?

For C++20:

using ReturnType = typename std::result_of<MethodPtr(Class*)>::type; should be replaced with:

using ReturnType = typename std::invoke_result_t<MethodPtr, Class*>;

Cheers, Ken

On Nov 11, 2022, at 9:46 PM, Samuel Reid @.***> wrote:

 Environment

Operating System: Windows 10 Pro Version / Commit SHA: current master HEAD Other: Visual Studio 2022 using C++20

Describe the bug

Using ISO C++20 Standard (/std:c++20) causes the following errors in Visual Studio 2022:

Error C2760 syntax error: ')' was unexpected here; expected ';' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
Error C2760 syntax error: 'const' was unexpected here; expected ')' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
Error C3329 syntax error: expected 'identifier' not ')' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
Error C3878 syntax error: unexpected token ')' following 'expression_statement' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
Error C3878 syntax error: unexpected token '>' following 'simple_declaration' Project1 C:\vcpkg\installed\x64-windows\include\nanovdb\util\GridBuilder.h 255
The actual line in GridBuilder.h. causing the syntax error

I believe this documentation is related to the error.

To Reproduce

Steps to reproduce the behavior:

Using the environment specified above, attempt to build a C++ file having #include <nanovdb/util/GridBuilder.h>, or in my case, #include <nanovdb/util/OpenToNanoVDB.h> which eventually includes GridBuilder.h. Expected behavior

No syntax errors, as is seen on C++17 and earlier

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

wilkesreid commented 2 years ago

Manually making that change myself does cause it to compile successfully in C++20