Archived
This forum has been archived. Please start a new discussion on GitHub.
Comparison operators not defined for struct containing sequence
Hi,
the following code used to compile using Ice 3.4.2:
Slice:
C++
Using Ice 3.5.0 it won't build:
Is this intentional?
Cheers,
Michael
the following code used to compile using Ice 3.4.2:
Slice:
module M { sequence<string> StringSeq; struct S { StringSeq tags; }; };
C++
#include "Test.h" int main() { M::S a, b; return a == b; }
Using Ice 3.5.0 it won't build:
CXX=g++ main.cpp: In function 'int main()': main.cpp:6: error: no match for 'operator==' in 'a == b' gmake: *** [all] Error 1 CXX=clang++ main.cpp:6:12: error: invalid operands to binary expression ('M::S' and 'M::S') return a == b; ~ ^ ~ 1 error generated. *** [all] Error code 1
Is this intentional?
Cheers,
Michael
0
Comments
-
To answer my own question:
Slice Metadata Directives - Ice 3.5 - ZeroC
So it seems that Ice 3.5.0 there won't be comparison operators for structs that are not valid dictionary keys by default. They can be generated by using the new metadata directive "cpp:comparable"cpp:comparable
This directive applies to structures. It directs the code generator to generate comparison operators for a structure regardless of whether it qualifies as a legal dictionary key type.
I think it would make sense to add this to Upgrading your Application from Ice 3.4 - Ice 3.5 - ZeroC0 -
Hi Michael,
Thanks for the suggestion, we'll add it.
Cheers,
Benoit.0