troubleshooting Question

In C++11 how do I create a map of queues?

Avatar of anAppBuilder
anAppBuilderFlag for United States of America asked on
C++
2 Comments1 Solution243 ViewsLast Modified:
How do I create a map of queues and dynamically add queues to it?  Suppose I have
map<string,queue<string>> myQueues;
 I am doing this from a method in a class so while the following is legal, it doesn't do the job
queue<string> q1;
myQueues["foo"] = q1;
What I really want to do is something like this (not legal tho)
myQueues["bar"] = new queue<string>;
What's the legal way to do this?

Just to be clear this is a simplified and contrived example to make the question simple. In the real code, I have a producer thread managed by a class.  The map is an instance variable of the class. The class needs to sometimes dynamically create a new consumer thread and a queue to communicate with it.  The real queues need to be thread-safe queues and the map variable is actually some kind of a handle, but to keep this question simple I'm posing it with standard classes.
ASKER CERTIFIED SOLUTION
Zoppo

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros