Skip to content

Commit

Permalink
[RF] Add missing declarations for JSONInterface template specializations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guitargeek committed May 30, 2023
1 parent 7eb3303 commit a135909
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
21 changes: 21 additions & 0 deletions roofit/jsoninterface/inc/RooFit/Detail/JSONInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,27 @@ std::vector<T> &operator<<(std::vector<T> &v, RooFit::Detail::JSONNode const &n)
return v;
}

template <>
inline int JSONNode::val_t<int>() const
{
return val_int();
}
template <>
inline double JSONNode::val_t<double>() const
{
return val_double();
}
template <>
inline bool JSONNode::val_t<bool>() const
{
return val_bool();
}
template <>
inline std::string JSONNode::val_t<std::string>() const
{
return val();
}

} // namespace Detail
} // namespace RooFit

Expand Down
21 changes: 0 additions & 21 deletions roofit/jsoninterface/src/JSONInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,6 @@ std::ostream &operator<<(std::ostream &os, JSONNode const &s)
return os;
}

template <>
int JSONNode::val_t<int>() const
{
return val_int();
}
template <>
double JSONNode::val_t<double>() const
{
return val_double();
}
template <>
bool JSONNode::val_t<bool>() const
{
return val_bool();
}
template <>
std::string JSONNode::val_t<std::string>() const
{
return val();
}

std::unique_ptr<JSONTree> JSONTree::create()
{
return std::make_unique<Tree_t>();
Expand Down

0 comments on commit a135909

Please sign in to comment.