Opened 8 years ago
Last modified 8 years ago
#10316 assigned Feature Requests
Thread: add subscription operator if the value provide it.
| Reported by: | Owned by: | viboes | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | thread |
| Version: | Boost 1.55.0 | Severity: | Cosmetic |
| Keywords: | Cc: |
Description (last modified by )
I would like to be able to do
typedef boost::synchronized_value< boost::container::flat_map<int, int> > ValueIndex;
ValueIndex index;
index[0] = 1;
and would expect that last line to be equivalent to
auto locked_index = index.synchronize();
(*locked_index)[0] = 1;
I'm not totally sure it's possible to do but it would help.
Change History (4)
comment:1 by , 8 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 8 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:3 by , 8 years ago
comment:4 by , 8 years ago
I started to consider how to do it at the time I wrote this but right now I'm overloaded with work. I'll try a patch asap but not immediately.
Note:
See TracTickets
for help on using tickets.

The statement
concerns two operations, the operator[] which returns a reference and the assignment operator.
In order to make this work we will need to use expression templates
operator[] would return a proxy reference, let call it at_type, that must store a reference to the synchronized_value instance and the index.
We would need to overload the assignment operator on at_type so that it can do what you want as an atomic operation.
I have not too much time to implement this kind of cosmetic features, but a patch would be welcome. Do you think that you can do it?