Hello,
Attribute has (among others) the following c'tor:
template <class T>
Attribute(const T& val);
and an output operator:
std::ostream& operator<<(std::ostream& os, const Attribute& att);
together these two constructs will grab any type that does not have a
operator<< overload of its own and turn it into an infinite recursion at
runtime (because the above c'tor uses setValue<T>(val) which uses a
std::ostringstream to convert val into a string representation.
One possible solution is to make the c'tor template explicit - this has
the downside that the following needs to be adjusted though:
element->setAttribute("att1", 1);
element->setAttribute("att2", "something");
to:
element->setAttribute("att1", Attribute(1));
element->setAttribute("att2", Attribute("something"));
One way to retain the convenience would be to introduce:
template <class T>
Element::setAttribute(const std::string& attName, const T& attVal)
{
setAttribute(attName, Attribute(attVal));
}
Comments? I can create a patch along these lines if desired.
Cheers,
Carsten
|