Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-9789

Error when calling templated member function

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • High
    • Resolution: Fixed
    • 6.16/00
    • None
    • PyROOT
    • None
    • Centos7, Python2

    Description

      As reported in this forum post:

      https://root-forum.cern.ch/t/pyroot-and-templated-c-member-functions/31515

      PyROOT is not able to lookup templated methods. The following code:

      obj.templatedMember(types)(arguments) 

      only works if previously we have

      ROOT.MyClass.templatedMember 

      Example:

      import ROOT
       
      ROOT.gInterpreter.Declare("""
      struct TestClass {
          template<class T> void templatedMember(const T& value) {
              std::cout << "Argument: " << value << std::endl;
          }
      };
      """)
       
      t = ROOT.TestClass()
      # For me this will print "doesn't work" on first iteration but will work fine
      # on the second so the full output is
      #
      #     doesn't work
      #     Argument: foo
      for i in range(2):
        try:
          t.templatedMember("std::string")("foo")
        except AttributeError:
          print("doesn't work")
        ROOT.TestClass.templatedMember 

       

      Attachments

        Activity

          People

            etejedor Enric Tejedor Saavedra
            etejedor Enric Tejedor Saavedra
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Actual Start:
              Actual End: