Archived
This forum has been archived. Please start a new discussion on GitHub.
sequence to set mapping
in Help Center
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&)’
// 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&)’
0
Comments
-
No, std::set cannot be used as an alternative mapping for sequences.0
-
alternativ to set
What can I use in Ice and I can map to a set::set??
greetings
Peter0 -
Ice does not provide any type that maps to std::set.0
-
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()
{
}
}0 -
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,
Bernard0 -
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.0