Skip to content

Commit a135909

Browse files
committed
[RF] Add missing declarations for JSONInterface template specializations
In the RooFit `JSONInterface` there are some template specializations that are defined in the translation unit but are not declared in the header file. This causes linker errors, because the compiler doesn't know that it has to look for the specializations, as explained here: https://stackoverflow.com/questions/11773960/do-template-specialisations-belong-into-the-header-or-source-file To solve this problem, these small one-line functions are just inlined in the header.
1 parent 7eb3303 commit a135909

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

roofit/jsoninterface/inc/RooFit/Detail/JSONInterface.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,27 @@ std::vector<T> &operator<<(std::vector<T> &v, RooFit::Detail::JSONNode const &n)
223223
return v;
224224
}
225225

226+
template <>
227+
inline int JSONNode::val_t<int>() const
228+
{
229+
return val_int();
230+
}
231+
template <>
232+
inline double JSONNode::val_t<double>() const
233+
{
234+
return val_double();
235+
}
236+
template <>
237+
inline bool JSONNode::val_t<bool>() const
238+
{
239+
return val_bool();
240+
}
241+
template <>
242+
inline std::string JSONNode::val_t<std::string>() const
243+
{
244+
return val();
245+
}
246+
226247
} // namespace Detail
227248
} // namespace RooFit
228249

roofit/jsoninterface/src/JSONInterface.cxx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,6 @@ std::ostream &operator<<(std::ostream &os, JSONNode const &s)
6969
return os;
7070
}
7171

72-
template <>
73-
int JSONNode::val_t<int>() const
74-
{
75-
return val_int();
76-
}
77-
template <>
78-
double JSONNode::val_t<double>() const
79-
{
80-
return val_double();
81-
}
82-
template <>
83-
bool JSONNode::val_t<bool>() const
84-
{
85-
return val_bool();
86-
}
87-
template <>
88-
std::string JSONNode::val_t<std::string>() const
89-
{
90-
return val();
91-
}
92-
9372
std::unique_ptr<JSONTree> JSONTree::create()
9473
{
9574
return std::make_unique<Tree_t>();

0 commit comments

Comments
 (0)