billyquith / ponder

C++ reflection library with Lua binding, and JSON and XML serialisation.
http://billyquith.github.io/ponder/
Other
648 stars 95 forks source link

ponder::Value's comparison operators are not complete #105

Closed shierei closed 5 years ago

shierei commented 6 years ago

The comparison operators include ==, !=, >, <, >=, <=. ponder::Value only overloads operator == and <. Camp works on all of them because camp::Value inherits boost::totally_ordered. I guess the way to work around this for ponder::Value is to overload all comparison operators.

I also find out that ponder::Value's implicit type conversion , i.e. the template method 'operator T()' does not do implicit type conversion for some reason. Camp can convert just fine but I do not know where the problem is from.

shierei commented 6 years ago

The reason that ponder::Value does not do implicit type conversion is because it does not implement 'operator T()'. Is there a reason not to implement it?

billyquith commented 6 years ago

The comparison operators include ==, !=, >, <, >=, <=. ponder::Value only overloads operator == and <.

You can implement all of the other comparisons with the 2 supplied. We could add more though.

The reason that ponder::Value does not do implicit type conversion is because it does not implement 'operator T()'. Is there a reason not to implement it?

I removed it because I consider it bad programming practice. Implicit conversion can do some inadvertent/inefficient work if not understood.

shierei commented 5 years ago

I think we should add more to compare ponder::Value's. Otherwise the code would fail to compile if your code uses a comparison operator which is not == or <.

shierei commented 5 years ago

Enhancement merged. See #114.