ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hello, I am trying to store the data in my program in a map of priority_queues an I am having a bit of trouble doing it.
basically I am storing activities (ie watching tv, eating dinner, playing ping-pong, etc) and I want these event grouped by the day that they happened on.
my first thought was to use a multimap where the key is the date, and the value is the activity, however I would like to keep the activities in a specific order.
I have tried to find the proper syntax for this but have frustratingly come up empty. Even google provided little assistance.
could anyone here point me in the right direction?
Although that would work, I don't believe it has any advantage to my current design. The idea is to group activities together by which day thy were performed on, not by the type of activity that was performed. and in that respect, a "day" object would server no purpose except to encapsulate a queue. This would be extra complexity that is unneeded.
Though I could technically just have one big chrolological list of all the activites that have ever been performed, however, because the list could potentially get quite large, I need to consider running time and efficiency constraints. being able to break the list up into days, or months, or whatever, could greatly improve performance in some use cases.
If i have misunderstood you, or if i could clarify my problem better, let me know.
thanks.
Hello, I am trying to store the data in my program in a map of priority_queues an I am having a bit of trouble doing it.
basically I am storing activities (ie watching tv, eating dinner, playing ping-pong, etc) and I want these event grouped by the day that they happened on.
my first thought was to use a multimap where the key is the date, and the value is the activity, however I would like to keep the activities in a specific order.
I have tried to find the proper syntax for this but have frustratingly come up empty. Even google provided little assistance.
could anyone here point me in the right direction?
Does this compile for you? It shouldn't; it should be > >. I've seen this in other code and I'm wondering if some compilers allow it. Aside from that, I agree with your recommendation.
Kevin Barry
Can you quote C++ standard saying so? (I understand that ">>" is technically a shift operator token).
More importantly, can you quote the standard saying that >> is ever other-than an operator? Does this compile for you in MS?
Code:
#include <vector>
template <int Value>
struct constant
{ static const int value = Value; };
const int index = 1;
int main()
{
std::vector <constant <1024 >> index> > instance;
}
The code in red would be a complete and valid definition statement if >> denoted the end of nested template instantiations, making the code in blue an error.
Note that a 2011 draft of the standard (14.1.1, 14.2.3) allows the syntax you used; however, it's not a part of the 2003 standard. That means you shouldn't expect it to compile with compilers that don't yet implement the 2011 standard (C++0x). Not to mention it will cause anyone using g++ problems.
Kevin Barry
edit: Also note that my example is invalid for C++0x but valid for C++03 (see 14.2.3).
More importantly, can you quote the standard saying that >> is ever other-than an operator? Does this compile for you in MS?
It doesn't unless put "1024 >> index" into () brackets.
Quote:
Originally Posted by ta0kira
That means you shouldn't expect it to compile with compilers that don't yet implement the 2011 standard (C++0x). Not to mention it will cause anyone using g++ problems.
I have not asked for assistance, so please refrain from telling me what to do or expect. Errors like this are quickly found during the first attempt to compile on different compiler, and are easy to deal with. Another thing is that I prefer to use typedefs for readability so it is unlikely that I'll run into this situation.
I have not asked for assistance, so please refrain from telling me what to do or expect. Errors like this are quickly found during the first attempt to compile on different compiler, and are easy to deal with. Another thing is that I prefer to use typedefs for readability so it is unlikely that I'll run into this situation.
Noted, but I wasn't providing you with assistance. I was more concerned with you providing a solution that won't compile on g++; such an error might not be obvious to a beginner, especially if it comes recommended by someone with experience.
Kevin Barry
I was more concerned with you providing a solution that won't compile on g++; such an error might not be obvious to a beginner, especially if it comes recommended by someone with experience.
Kevin Barry
Agreed. Thank you both for your help. I have it working now.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.