Skip to content

[PyROOT] Problem with templated binary operator implementations like operator+ #15378

Description

@guitargeek

Description

Operators like operator+ don't work in cppyy if they are implemented as template functions.

Reproducer

import cppyy

cppyy.cppdef("""

template<class T>
struct Foo {
    Foo(T v) : val{v} {}
    T val;
};

template <class T>
Foo<T> operator+(Foo<T> const &a, Foo<T> const &b)
{
   return Foo<T>{a.val + b.val};
}

""")

klass = cppyy.gbl.Foo["int"]

a = klass(4)
b = klass(7)

a + b

ROOT version

At least ROOT 6.04 according to original Jira ticket:
https://its.cern.ch/jira/browse/ROOT-7717

Installation method

Build master from source

Operating system

Arch Linux

Additional context

  • same problem as reported in ROOT-7717, but with a simplified reproducer
  • reproducer works with upstream cppyy, so the problem is likely related to the cppyy-backend (e.g. ROOT meta or CallFunc)

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions