Home Help Center

sequence to set mapping

peterpeter Member Peter JaxyOrganization: Reihnisch Westfälisch technische HochschuleProject: Integrative Production Technologie ✭✭
Is this possible?

// In file CCU.ice
"cpp:include:set"

module example {
["cpp:type:std::set<std::string>"] sequence<string> SET;

};
// end of file CCU.ice

Because if I compile with:
c++ -I. -I/usr/include -c server.cpp CCU.cpp CCUIS.cpp

I get the following error message:
CCU.cpp: In function ‘void CCU::__readSET(IceInternal::BasicStream*, CCU::SET&)’:
CCU.cpp:88: error: no matching function for call to ‘std::set<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::set(Ice::Int&)’

Comments

  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    No, std::set cannot be used as an alternative mapping for sequences.
  • peterpeter Member Peter JaxyOrganization: Reihnisch Westfälisch technische HochschuleProject: Integrative Production Technologie ✭✭
    alternativ to set

    What can I use in Ice and I can map to a set::set??

    greetings
    Peter
  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    Ice does not provide any type that maps to std::set.
  • blairblair Member Blair ZajacOrganization: Sony Pictures ImageworksProject: VnP ✭✭
    Could one have a wrapper class that just ignores the size constructor:

    template<typename T>
    class my_set: public std::set<T>
    {
    my_set(const Ice::Int size)
    : std::set()
    {
    }
    }
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Blair,

    You should be able to use any class that satisfies the requirements listed in the manual. (I don't think the un-marshaling code checks the size of the un-marshaled mapped sequence.)

    However, it is also desirable for the mapped C++ (Java ...) type to match the semantics of the underlying Slice type.

    A sequence is an ordered list, with possibly duplicate values, and not a set. A dictionary would be a better match for a set.

    Best regards,
    Bernard
  • blairblair Member Blair ZajacOrganization: Sony Pictures ImageworksProject: VnP ✭✭
    Never mind, in inspecting the generated C++ code the way the items are added to the std::vector is incompatible with std::set. So it looks like it's not possible.
Sign In or Register to comment.