sempr-tk / sempr

SEMPR - Semantic Environment Mapping, Processing and Reasoning
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

RDFPropertyMap string-conversion #30

Closed niniemann closed 6 years ago

niniemann commented 6 years ago

Some types are a bit difficult to handle in the (implementation of the) RDFPropertyMap. One of these is std::string since it is easily confused with char*. Hence there are a few explicit definitions of RDFValue::operator = and also a template <> std::string RDFValue::to(void*) const; which should handle the conversion to std::string.

But the latter is buggy!

// RDFPropertyMap::Ptr prop = ....

// version 1:
std::string foo = (*prop)["key_to_a_string_value"]; // okay

// version 2:
std::string bar;
bar = (*prop)["key_to_a_string_value"]; // compiler error: ambiguous sth ....

I guess the difference between both versions is that the first one uses copy initialization while the second one uses the assignment operator... Dunno.

niniemann commented 6 years ago

Also, the often1 wanted equality check

(*prop)["key_to_a_string_value"] == "foobar";

Does not compile, either. But I think this is a more general problem that can be solved by implementing bool RDFValue::operator == ( .... ). Same probably goes for all other operators, too.

1Please don't look at the time between the implementation of RDFPropertyMap and this issue.