Skip to content

PyROOT cannot handle SFINAE functions with variadic template arguments #14016

Open
@taehyounpark

Description

@taehyounpark

Check duplicate issues.

  • Checked for duplicates

Description

Following from wlav/cppyy#201, it seems there is an issue with (ROOT's) cppyy's handling of SFINAE functions with variadic template arguments.

Reproducer

import ROOT
import cppyy

cppyy.cppdef('''
template <typename T> struct TestSfinae {
  template <typename U, typename V = T,
            std::enable_if_t<std::is_arithmetic_v<V>, bool> = false>
  auto test_single(U arg) {
    std::cout << "good" << std::endl;
    return 0;
  }
  template <typename... Args, typename V = T,
            std::enable_if_t<std::is_arithmetic_v<V>, bool> = false>
  auto test_pack(Args... args) {
    std::cout << "good" << std::endl;
    return 0;
  }
};
''')

# call from cling
cppyy.cppdef('''auto testing = TestSfinae<float>();''')
cppyy.cppdef('''auto single_call = testing.test_single(1);''')  # good
cppyy.cppdef('''auto pack_call = testing.test_pack(1,2,3);''')  # good

# call from bindings
testing = cppyy.gbl.TestSfinae['float']()
testing.test_single(1)  # good
testing.test_pack(1,2,3)  # fails

ROOT version

 ------------------------------------------------------------------
| Welcome to ROOT 6.28/06                        https://root.cern |
| (c) 1995-2023, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for macosx64 on Sep 17 2023, 12:38:14                      |
| From heads/latest-stable@7745d36d                                |
| With Apple clang version 14.0.3 (clang-1403.0.22.14.1)           |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
 ------------------------------------------------------------------

Installation method

build from source

Operating system

MacOS

Additional context

input_line_24:6:70: error: no matching member function for call to 'test_pack'
      new (ret) (int) (((TestSfinae<float>*)obj)->TestSfinae<float>::test_pack<int, int, int, float, false>(*(int*)args[0], *(int*)args[1],
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input_line_18:11:8: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Args'
  auto test_pack(Args... args) {
       ^

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions