|
Boost Users : |
Subject: Re: [Boost-users] [ICL] Can't use an enum as map value
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2014-03-19 08:18:39
2014-03-19 13:11 GMT+01:00 Oodini <svdbg____at_[hidden]>:
> Hello,
>
> I declared an interval_map :
>
> interval_map<uint16_t, SomeEnumType> myMap;
>
> Later, I do :
>
> SomeEnumType enumValue = SOME_ENUM_VALUE;
> myMap.add(std::make_pair(disxrete_interval<uint16_t>(10,17),
> SOME_ENUM_VALUE);
>
> But that doesn't compile.
>
> It seems that ICL wants the += operator must eb defined for value type
> (why ???).
>
> What can I do ?
>
Hi,
If I remember correctly, you need to supply a combiner. The default
combiner uses +=.
A combiner produces a new value for overlapping intervals. Consider
(pseudocode):
myMap.add( [10,17), SOME_ENUM_VALUE );
myMap.add( [16,18), OTHER_ENUM_VALUE );
The combiner decides, what should be the value in [16,17). In this case,
tries to += the OTHER_ENUM_VALUE to the existing SOME_ENUM_VALUE.
HTH,
Kris
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net