Dhruv
Anyone gave me a certified c++ courses in free anroll?
Alex
Azadi
Anyone gave me a certified c++ courses in free anroll?
Udamy has dome free courses. YouTube exists too. I personally prefer books, like ‘a tour of C++ third edition’
klimi
the url: https://github.com/m2049r/xmrwallet/blob/master/app/src/main/cpp/monerujo.cpp#L1118
Rain Bow
Hi can anyone suggest me software mini project using pic 16F877A?
Gadjet
https://pastebin.com/ZQzkL2wM Do not catch what the error is, it does not count for example (=A1+B4) it also displays =A1+B4
Anonymous
Standalone functions can't be virtual. Only class member functions can be virtual Edit :: errm I didn't realise that you pasted part of your code inside a class definition. We can't comment much without seeing what the actual error is and the rest of your code.
Anonymous
Hi everyone, I am using vcpkg with protobuf, but I found the protobuf on vcpkg is VERY OLD and contain a bug that makes my program works incorrectly. I am asking for help how can solve this problem. Thanks sincerely.
The package that am using on vcpkg seems to be just 2 patches behind the actual release. So there is a difference between just the patch numbers. The minor and the major version numbers are the same as the one that Google has published. I guess you must have mentioned the version number specifically somewhere. I am using protobuf as well from vcpkg and it is picking up the latest version (almost the latest version)
OnetimePlace19
I have a problem when I add a new .cpp file to my project in Visual Studio; the .exe file is not generated. Does anyone know how to solve this?
Sanchin
can someone help me in one on one session to explain me C++ code ?
Sanchin
What code?
thanks for asking bro here is ref link https://developer.nvidia.com/docs/drive/driveworks/latest/nvsdk_dw_html/EgomotionState_8h_source.html
az
Hi everyone. Currently i am digging into DPDK source code rte_ring. This ring allows to enqueu/dequeue lock-free for multiple producers/consumers. The question is, why is there prod_tail atomic? What does it prevent us from?
Azadi
‘atomic’ objects allow access to their value only by one thread at a time
az
‘atomic’ objects allow access to their value only by one thread at a time
Are you familar with rte_ring structure from DPDK framework?
Azadi
No, none of them. What is DPDK?
OnetimePlace19
What is the compile output.
The issue is that only the file generated by the IDE is being compiled, and not the one I manually add. Consequently, no errors are displayed because the IDE is unaware of the existence of the other file.
Alex
I have no visual studio now to run your project. But what is the code. What is the output. In the output you may see what files and where the compiler created.
Anonymous
So you want to implement the exportKeyImages and importKeyImages functions so that they can be called using JNI. What is the problem?
Anonymous
Why dont you test it and see? Do you expect me to understand the full library within the last 5 minutes that I spent on it so as to be able to validate your code?
Anonymous
We are here to help with problems. I thought you had some issues with your JNI implementation. We can't test your code for you.
Anonymous
What code review? Did you just blindly copy paste code? If you had even tried compiling your code, you would have seen that you would get a compiler error for trying to use filename without even defining it. You perhaps meant to have a jstring parameter called filename. What is "all"? If you want your code to be reviewed atleast write it on your own and try compiling it rather than asking around for code from somewhere and getting it validated somewhere else.
az
Are you asking why tail is atomic in a lock free queue? Do you understand how lock free queues are implemented?
No, question was why we need that prod.tail. Now i know, prod.tail used when dequeue happens. It helps to know how many we can to dewueue
Anonymous
By using that u don't have to write gcc etc in terminal just u have to click on run button that's it
Mitsuha
I did see the string in memory, but after ParseFromArray, I found the string pointer points to a wrong memory, which is end of the string.
Gadjet
how to calculate the sum in a csv file if the cell says for example: =A2+C3 for (int i = 0; i < table.size(); i++) { for (int j = 0; j < table[i].size(); j++) { string cell = table[i][j]; // Если ячейка содержит выражение, вычисляем его значение if (cell[0] == '=') { cell = cell.substr(1); // Игнорируем символ "=" int value = evaluateExpression(cell, cellValues); cell = to_string(value); cellValues["" + char('A' + j) + to_string(i + 1)] = value; } .... This is how it doesn't work. Who knows why?
Gadjet
https://pastebin.com/1id5DRDF you can check all my code. I modified it (added calculation by links) but for some reason it does not calculate them ;(
Azadi
https://pastebin.com/1id5DRDF you can check all my code. I modified it (added calculation by links) but for some reason it does not calculate them ;(
I don't have time to read the whole code of everyone when they have a problem with it! Run your program using a debugger and post the error.
Pavel
If I have vector<tuple<void*, void*>> myVec; can I do static_cast<tuple<Data1*, Data2*>*>(myVec.data()), assuming I store data of these types there in corrects items of the tuple? Or is it UB by some rules?
Mitsuha
They are all pointers
Mitsuha
But it will makes your code terrible
Mitsuha
I recommend get void* and then cast to Data*
Pavel
But it will makes your code terrible
It is already terrible (it's a templated helper class for other templated class), I want to make the interface of it a bit better by providing a span with correct types (there's logic that makes sure the types are correct), instead of static-casting each element later
Gadjet
https://pastebin.com/TST7WsQC Help!!! With the calculation of troubles, I don’t understand why it’s always 0 .
Gadjet
Use debugger lol
not helpful
Danya🔥
not helpful
Instead of spamming here wasting your time, better learn how to use a debugger properly - it's a useful skill
Pavel
Oh this is external c interface exposed?
No, it is C++. The class basically stores indexes for a kind of DB (a silly ECS implementation), and I have to store the elements as void* because I don't want to store the type information for each element of the vector, as std::any would do for example. And I can't store the vectors using the real types, because I can't template the class/classes with the types they are going to store (types are dynamic).
Phoenix
Oh are we not supposed to personally message someone?
Phoenix
Got it👍
Anonymous
If I have vector<tuple<void*, void*>> myVec; can I do static_cast<tuple<Data1*, Data2*>*>(myVec.data()), assuming I store data of these types there in corrects items of the tuple? Or is it UB by some rules?
First of all a static_cast won't work. You need to use reinterpret_cast. It is UB anyway. Assume that you use a struct instead of a tuple. There is no way for the compiler to do any verification that the casts are valid. Even if they are valid there are ways for you to break the type system. So the C/C++ standard deems such casts as UB. Ofcourse they may work fine on any compiler that you test it on but it is not guaranteed to work on all compilers. The reason why it won't work on all compilers is because of aliasing rules which again might not seem obvious to you but they are there for a reason.
Anonymous
Is there a way out from these aliasing problems? E.g. if I store it as std::byte pointer for example
No. There is no way out of this. You need to design your code better. Using void* is acceptable when you need to treat memory as a raw collection of bytes like for example how uninitialized_fill, copy or as a more practical example how protobuf use it. For all other cases you are just breaking the type system. So I would suggest going back to the drawing board to a better design
Anonymous
I can store the vectors as std::any I guess, I don't see other ways for now
That again is not a good design. Can you explain your problem in more detail so that I can offer suggestions (maybe not practical as you know your use case better than me) that may be more valid?
Anonymous
Guess you are still formalizing your question. It is pretty late here. So just send in the details. I will reply as soon as I am able to
Pavel
That again is not a good design. Can you explain your problem in more detail so that I can offer suggestions (maybe not practical as you know your use case better than me) that may be more valid?
So the problem that I trying to solve initially. I want to have instances of custom types (called "components") be bound to one or more ids (called "entities"), in a way that a user can bind any type of component to any entity (entity can have 0 or more components, but can't have more than one component of the same type). So basically it is a custom ECS. User should be able to iterate over sets of components bound to entities that have them. E.g. I want to iterate over all the entities that have components Movement and Transform, I do entityManager.forEachComponentSet<Movement, Transform>([](Movement* movement, Transform* transform) { transform->x += movement->speedPerTickX; transform->y += movement->speedPerTickY; }); This will move all the entities that have both components by one step to a direction determined by "movement". So, to be able to do that right now I store components of one type in a vector of void* (they are constructed/destructed using an abstract factory, so the user doesn't need to care about the details, they just need to make sure a component is default constructible and that they didn't forget to call registerComponent<MyComponent>() on the factory). Then I store these vectors mapped by the component type (which is just an ID type, the details don't matter much here), I store them in an unordered_map right now (key is the ID, value is a vector<void*>). And then when I want to get them back, I want to get components from these vectors, using some matching logic. Then right now I'm building a kind of index/cache to have a bit less indirections when iterating over components. I want to store them as tuples of pointers (I have another type of index already, but I want to see if reducing amount of indirections changes anything with how fast it goes on the benchmarks). It is mostly an educational thing, there are already implementations that do mostly what I want, but I want to be able to reason about these things not just assume how it behaves.
The
No, it is C++. The class basically stores indexes for a kind of DB (a silly ECS implementation), and I have to store the elements as void* because I don't want to store the type information for each element of the vector, as std::any would do for example. And I can't store the vectors using the real types, because I can't template the class/classes with the types they are going to store (types are dynamic).
Y can't template? I'm stuck at this part... If completely cpp app .. nothing stopping you correct? I'm way noob but recently in an interview i was doing similar stuff kinda and they gave a templated solution as answer and it was very elegant.. So your entity could use type erasure somehow to bind to any component .. i won't be able to give a hard solution but something around those lines would work..
Alex
No, it is C++. The class basically stores indexes for a kind of DB (a silly ECS implementation), and I have to store the elements as void* because I don't want to store the type information for each element of the vector, as std::any would do for example. And I can't store the vectors using the real types, because I can't template the class/classes with the types they are going to store (types are dynamic).
You never store all or part of information when you store the pointer. In cpp pointer it is a number to the place. What are you toking about? The Class or Struct is for readability. You may do everythung with void pointer. But you will never be able to maintanence this thing. You may cast any pointer to any pointer you want it is a very dangerous and unreadable. But it is your choose. For maintanceability and readability you may try to use UNION. It may help sometimes.
Danya🔥
Can't template because I can theoretically store tens or hundreds of permutations of types, wouldn't want to make all them as template arguments of the class
So that's why you prefer to do UB void* and all or increase runtime cost of your code using std::any which might use RTTI?
Danya🔥
The alternative is the templates which are less error-prone and more performant on the runtime
Pavel
And in case of std::any, it would be used once before starting iterating over the vector, so shouldn't be that costy (would like to avoid that though, yes)
Pavel
The alternative is the templates which are less error-prone and more performant on the runtime
I mean I use templates, but I want the user to run the code as above, I don't want them to go into template hell and make a class with hundreds of template arguments
Alex
The alternative is the templates which are less error-prone and more performant on the runtime
Template it is good solution but it may be also have bad performance. It depends on the architecture and on the page size.... If you have very slow memory and very fat cpu RTTI may be preferable.
Pavel
What tf are you talking about You have 2 `void*`s
That was just an example of a use case
Danya🔥
It's not an example
Pavel
What is a difference for user....
Amount of code to write and support, potentially the duration of compilation
Alex
It's not an example
You have two temolay parameters X and Y it is an all permutations... Compiler will generet the code user just ask for type he need.
Danya🔥
There is less code with templates and there are fewer bugs