Hello everybody,
I am trying to use a class template with a function template in RootCint, and while I can instantiate the class, the function is not being recognized. I am not sure if the problem lies with the LinkDef.h file, or if I am making some other mistake (Root-newbie here), however, rootcint doesn’t complain when generating the dictionary. (I am developing on Visual Studio 2013, with Root 5.34)
The class looks like this:
// flow.h
template<class Value, class Date>
class Flow : public TObject {
public:
Flow() {}
~Flow(){}
template<class DateIterator, class ValueIterator>
bool AddFlow(FlowType flowType, DateIterator dBegin, DateIterator dEnd, ValueIterator vBegin) {
…
}
ClassDef(Flow, 1);
};
//flow.cpp
#include “flow.h”
templateClassImp(Flow);
And the LinkDef.h file:
#ifndef LINKDEF_H_
#define LINKDEF_H_
#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclasses;
#pragma link C++ defined_in “date.h”;
#pragma link C++ enum FlowType;
#pragma link C++ class Flow<double, Date>+;
#pragma link C++ operators std::vector::iterator;
#pragma link C++ operators std::vector::iterator;
#pragma link C++ function Flow<double, Date>::AddFlow(FlowType, std::vector::iterator, std::vector::iterator>, std::vector::iterator);
#endif
#endif
Instantiation in RootCint works like this:
gSystem->Load(“test.dll”);
std::vector dates;
std::vector values;
dates.push_back(TDate(1,1,2015));
dates.push_back(TDate(2,1,2015));
dates.push_back(TDate(3,1,2015));
values.push_back(1.0);
values.push_back(1.1);
values.push_back(1.2);
Flow<double, Date> flow;
flow.AddFlow(FlowType::cashed, dates.begin(), dates.end(), values.begin());
And here I get the error: Can’t call Flow<double, Date>::AddPattern(…) in current scope…,
with no other function-suggestions from Cint.
I guess the fault lies within the dictionary generation, but I am all out of ideas here.
Cheers, Simon