[Ndn-interest] Problem with Interest and Data structure in c++
Alex Afanasyev
aa at CS.UCLA.EDU
Tue Sep 20 07:16:51 PDT 2016
> On Sep 20, 2016, at 9:41 AM, Matteo Bertolino <Matteo.Bertolino at eurecom.fr> wrote:
>
> Good morning to all,
> I write in order to ask your help with a problem.
> I would like to do a Map <Interest, int>.
>
> So I wrote:
> std::map<Interest, int> myMap;
> but each operation on it fails, like:
> int numbEntries = mappa.count(nack.getInterest());
> or
> std::map<Interest,int>::iterator it = mappa.find (nack.getInterest());
> or
> Interest x: mappa[x] = 5;
>
> The error is always the same:
> /usr/include/c++/4.9/bits/stl_function.h:371:20: error: no match for ‘operator<’ (operand types are ‘const ndn::Interest’ and ‘const ndn::Interest’)
> { return __x < __y; }
>
> Then I think to redefine operator "<" into interest.cpp, writing:
> bool
> operator<(const ndn::Interest ones, const ndn::Interest other)
> {
> return ones.getName().compare(other.getName())<0;
> }
For C++ to find the method, you need to define this operator in the same namespace as Interest, e.g.,
namespace ndn {
bool
operator<(const Interest& i1, const Interest& i2)
{
... // you may need to include additional comparisons in addition to checking names
}
}
---
Alex
> But, also here, no effect.
> Any idea?
> Thank you,
> Matteo
>
>
> -------------------------------------------------------------------------------
> This message was sent using EURECOM Webmail: http://webmail.eurecom.fr
>
>
> _______________________________________________
> Ndn-interest mailing list
> Ndn-interest at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/ndn-interest
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.lists.cs.ucla.edu/pipermail/ndn-interest/attachments/20160920/6f223534/attachment.bin>
More information about the Ndn-interest
mailing list