Home Help Center

Comparison operators not defined for struct containing sequence

grembogrembo Member Michael GmelinOrganization: Grem Equity GmbHProject: E-Commerce platform
Hi,

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

Comments

  • grembogrembo Member Michael GmelinOrganization: Grem Equity GmbHProject: E-Commerce platform
    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 - ZeroC
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Michael,

    Thanks for the suggestion, we'll add it.

    Cheers,
    Benoit.
Sign In or Register to comment.