Search found 78 matches
- March 29th, 2020, 7:57 am
- Forum: Everything
- Topic: List of subclass pointers...
- Replies: 12
- Views: 4466
Re: List of subclass pointers...
Ok. I'm a little disappointed that the DoWork of B2 cannot appear somehow in B2 member (also in B2.cpp file, more convenient and lisible). Another question (let's go back to the list stuff) : Let say I would like external functions (not a class member of A, B1, B2, etc...), called FindB1 (or FindB2,...
- March 28th, 2020, 9:55 pm
- Forum: Everything
- Topic: List of subclass pointers...
- Replies: 12
- Views: 4466
Re: List of subclass pointers...
Thanks man. This is clever. It's not for the parser (which is quite finished), but for the game data. The problem I have with your solution is : B1 and B2 will have some specific unique data that I do not want to put into A, and each Doworks located in A cannot "see" these data and do the specific w...
- March 28th, 2020, 10:40 am
- Forum: Everything
- Topic: List of subclass pointers...
- Replies: 12
- Views: 4466
List of subclass pointers...
Hi there, a little question. I have class A; class B0 : A class B1 : A class B2 : A std::list<A*> listPA; in listPA, I store pointers on B0, B1 or B2 objects. but when I parse listPA, I retrieve A* items. then I have a function f() that I want to call on these A* that I retrieve from the list, but I...
- March 25th, 2020, 6:50 am
- Forum: Everything
- Topic: Auto cast an iterator into its base pointer type ?
- Replies: 25
- Views: 10828
Re: Auto cast an iterator into its base pointer type ?
coming back to a thing you said before : for parsing a list, you suggested parsing the items, hiding the iterator stuff from for (auto i = list.begin(), e = list.end(); i != e; ++i) to for ( auto& i : list) which is a nice idea that I used. but if I want to erase one element of the list, do I have t...
- March 25th, 2020, 5:39 am
- Forum: Everything
- Topic: Multithreading and threads sync ?
- Replies: 6
- Views: 2987
Re: Multithreading and threads sync ?
It's still my robot programming game : On one map, each robot is driven by a user-written script that is stored as a N-tree. Running one script = recursively parsing the tree with a recursive function. To ease things (and at the end, also to have a MT game, taking advantage of actual multicores CPU)...
- March 24th, 2020, 5:53 am
- Forum: Everything
- Topic: Auto cast an iterator into its base pointer type ?
- Replies: 25
- Views: 10828
Re: Auto cast an iterator into its base pointer type ?
Thanks for your answer albinopapa. I'm looking forward to see what you will earn on the MT subject. I just wonder if you have the permission to move the MT answers from this thread to my MT thread on the forum. It would be clearer for everyone, and future MT users...
- March 24th, 2020, 5:51 am
- Forum: Everything
- Topic: Multithreading and threads sync ?
- Replies: 6
- Views: 2987
Re: Multithreading and threads sync ?
As said with albinopapa in another thread, I would like to use the notify_all command, and maybe only one mutex for all waiting threads, but I do not know how. I suppose that I should use a condition_variable testing part with (waiting_threads < launched_threads) but I cannot figure out how to make ...
- March 23rd, 2020, 7:53 pm
- Forum: Everything
- Topic: Auto cast an iterator into its base pointer type ?
- Replies: 25
- Views: 10828
Re: Auto cast an iterator into its base pointer type ?
Not sure exactly what you mean there. What checking is there in C++ that you wouldn't have in a C program? Hard to explain in english : when CPU was an issue, we often tried to avoid explicit checkings, trying to rely on the inner safety of the code, "the way it should work", which was of course ha...
- March 23rd, 2020, 1:57 pm
- Forum: Everything
- Topic: Multithreading and threads sync ?
- Replies: 6
- Views: 2987
Re: Multithreading and threads sync ?
Well, I went even further, because, as I said, I want to use recursive concurrent threads that sync at regular intervals. So I changed all to recursive_mutex and condition_variable_any here is the code. Try it, you will see, it's funny to watch it run in parallel and sync back from time to time. Guy...
- March 23rd, 2020, 1:41 pm
- Forum: Everything
- Topic: Auto cast an iterator into its base pointer type ?
- Replies: 25
- Views: 10828
Re: Auto cast an iterator into its base pointer type ?
Yes, I totally agree with all you said. I see all the benefits of an intelligent C++ approach. But the fact is that most of the time I'm lazy to program this way. Which , I admit, is a poor calculation, because investing some time in class/methods design can avoid a lot of problems that C programmer...