Fix: compilation error with gcc and clang: error: no matching member function for call to 'set' #5

Manually merged
Brecht Van Lommel merged 1 commits from Pierre-Pontier/cycles:fix/node_set_enum_sfinae into main 2023-06-23 17:05:24 +02:00
Contributor

I use Mageia 8 and compile with gcc 10.4.0 and clang 11.0.1. I use c++17.

When I compile cycles outside my project, I don't have any compilation problems.

When I compile it in my project, the SFINAE signature of the Node::Set function does not identify enumerations. So I've modified it so that it compiles.

This line:

template<class ValueType, typename std::enable_if_t<std::is_enum_v<ValueType>> * = nullptr>

has become:

template<class ValueType, std::enable_if_t<std::is_enum_v<ValueType>, bool> = true>

Here's the substitution failure message under gcc (under clang it's the same):

src/scene/pass.h
error: no matching member function for call to 'set'
  NODE_SOCKET_API(PassMode, mode)
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/cycles/src/graph/node.h:60:11: note: expanded from macro 'NODE_SOCKET_API'
    this->set(*socket, value); \
    ~~~~~~^~~
/cycles/src/graph/node.h:95:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'bool' for 2nd argument
  void set(const SocketType &input, bool value);
       ^
/cycles/src/graph/node.h:96:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'int' for 2nd argument
  void set(const SocketType &input, int value);
       ^
/cycles/src/graph/node.h:97:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'ccl::uint' (aka 'unsigned int') for 2nd argument
  void set(const SocketType &input, uint value);
       ^
/cycles/src/graph/node.h:98:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'float' for 2nd argument
  void set(const SocketType &input, float value);
       ^
/cycles/src/graph/node.h:99:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'ccl::float2' for 2nd argument
  void set(const SocketType &input, float2 value);
       ^
/cycles/src/graph/node.h:100:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'ccl::float3' for 2nd argument
  void set(const SocketType &input, float3 value);
       ^
/cycles/src/graph/node.h:101:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'const char *' for 2nd argument
  void set(const SocketType &input, const char *value);
       ^
/cycles/src/graph/node.h:102:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'OpenImageIO_v2_4::ustring' for 2nd argument
  void set(const SocketType &input, ustring value);
       ^
/cycles/src/graph/node.h:103:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'const ccl::Transform' for 2nd argument
  void set(const SocketType &input, const Transform &value);
       ^
/cycles/src/graph/node.h:104:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'ccl::Node *' for 2nd argument
  void set(const SocketType &input, Node *value);
       ^
/cycles/src/graph/node.h:117:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<bool> &' for 2nd argument
  void set(const SocketType &input, array<bool> &value);
       ^
/cycles/src/graph/node.h:118:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<int> &' for 2nd argument
  void set(const SocketType &input, array<int> &value);
       ^
/cycles/src/graph/node.h:119:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<float> &' for 2nd argument
  void set(const SocketType &input, array<float> &value);
       ^
/cycles/src/graph/node.h:120:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<ccl::float2> &' for 2nd argument
  void set(const SocketType &input, array<float2> &value);
       ^
/cycles/src/graph/node.h:121:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<ccl::float3> &' for 2nd argument
  void set(const SocketType &input, array<float3> &value);
       ^
/cycles/src/graph/node.h:122:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<OpenImageIO_v2_4::ustring> &' for 2nd argument
  void set(const SocketType &input, array<ustring> &value);
       ^
/cycles/src/graph/node.h:123:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<ccl::Transform> &' for 2nd argument
  void set(const SocketType &input, array<Transform> &value);
       ^
/cycles/src/graph/node.h:124:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<ccl::Node *> &' for 2nd argument
  void set(const SocketType &input, array<Node *> &value);
       ^
/cycles/src/graph/node.h:109:8: note: candidate template ignored: substitution failure [with ValueType = ccl::PassMode]: conversion from 'int' to 'typename std::enable_if_t<std::is_enum_v<PassMode>> *' (aka 'void *') is not allowed in a converted constant expression
  void set(const SocketType &input, const ValueType &value)
       ^
I use Mageia 8 and compile with gcc 10.4.0 and clang 11.0.1. I use c++17. When I compile cycles outside my project, I don't have any compilation problems. When I compile it in my project, the SFINAE signature of the Node::Set function does not identify enumerations. So I've modified it so that it compiles. This line: ```template<class ValueType, typename std::enable_if_t<std::is_enum_v<ValueType>> * = nullptr>``` has become: ```template<class ValueType, std::enable_if_t<std::is_enum_v<ValueType>, bool> = true>``` Here's the substitution failure message under gcc (under clang it's the same): ``` src/scene/pass.h error: no matching member function for call to 'set' NODE_SOCKET_API(PassMode, mode) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /cycles/src/graph/node.h:60:11: note: expanded from macro 'NODE_SOCKET_API' this->set(*socket, value); \ ~~~~~~^~~ /cycles/src/graph/node.h:95:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'bool' for 2nd argument void set(const SocketType &input, bool value); ^ /cycles/src/graph/node.h:96:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'int' for 2nd argument void set(const SocketType &input, int value); ^ /cycles/src/graph/node.h:97:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'ccl::uint' (aka 'unsigned int') for 2nd argument void set(const SocketType &input, uint value); ^ /cycles/src/graph/node.h:98:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'float' for 2nd argument void set(const SocketType &input, float value); ^ /cycles/src/graph/node.h:99:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'ccl::float2' for 2nd argument void set(const SocketType &input, float2 value); ^ /cycles/src/graph/node.h:100:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'ccl::float3' for 2nd argument void set(const SocketType &input, float3 value); ^ /cycles/src/graph/node.h:101:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'const char *' for 2nd argument void set(const SocketType &input, const char *value); ^ /cycles/src/graph/node.h:102:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'OpenImageIO_v2_4::ustring' for 2nd argument void set(const SocketType &input, ustring value); ^ /cycles/src/graph/node.h:103:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'const ccl::Transform' for 2nd argument void set(const SocketType &input, const Transform &value); ^ /cycles/src/graph/node.h:104:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'ccl::Node *' for 2nd argument void set(const SocketType &input, Node *value); ^ /cycles/src/graph/node.h:117:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<bool> &' for 2nd argument void set(const SocketType &input, array<bool> &value); ^ /cycles/src/graph/node.h:118:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<int> &' for 2nd argument void set(const SocketType &input, array<int> &value); ^ /cycles/src/graph/node.h:119:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<float> &' for 2nd argument void set(const SocketType &input, array<float> &value); ^ /cycles/src/graph/node.h:120:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<ccl::float2> &' for 2nd argument void set(const SocketType &input, array<float2> &value); ^ /cycles/src/graph/node.h:121:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<ccl::float3> &' for 2nd argument void set(const SocketType &input, array<float3> &value); ^ /cycles/src/graph/node.h:122:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<OpenImageIO_v2_4::ustring> &' for 2nd argument void set(const SocketType &input, array<ustring> &value); ^ /cycles/src/graph/node.h:123:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<ccl::Transform> &' for 2nd argument void set(const SocketType &input, array<Transform> &value); ^ /cycles/src/graph/node.h:124:8: note: candidate function not viable: no known conversion from 'ccl::PassMode' to 'array<ccl::Node *> &' for 2nd argument void set(const SocketType &input, array<Node *> &value); ^ /cycles/src/graph/node.h:109:8: note: candidate template ignored: substitution failure [with ValueType = ccl::PassMode]: conversion from 'int' to 'typename std::enable_if_t<std::is_enum_v<PassMode>> *' (aka 'void *') is not allowed in a converted constant expression void set(const SocketType &input, const ValueType &value) ^ ```
Suryavarman added 1 commit 2023-06-22 20:40:11 +02:00
NODE_SOCKET_API(PassMode, mode)

ode.h:109:8: note: candidate template ignored: substitution failure [with ValueType = ccl::PassMode]: conversion from 'int' to 'typename std::enable_if_t<std::is_enum_v<PassMode>> *' (aka 'void *') is not allowed in a converted constant expression
  void set(const SocketType &input, const ValueType &value)
       ^
Brecht Van Lommel requested review from Brecht Van Lommel 2023-06-22 23:07:32 +02:00
Brecht Van Lommel approved these changes 2023-06-23 17:04:07 +02:00
Brecht Van Lommel left a comment
Owner

Thanks!

Thanks!
Brecht Van Lommel manually merged commit a98f3022cf into main 2023-06-23 17:05:24 +02:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: blender/cycles#5
No description provided.