Simple Sorcerer
Yes, I tested it on a simple class.
Manav
alright, now to your allocation issue
Manav
you have different var1, var2, etc for different functions, yes?
Simple Sorcerer
yes
Manav
yes
and you want to somehow use just one variable for var1, var2 and so on?
Simple Sorcerer
no
Manav
okay, so what is it you want with these var1, var2 and ...?
Manav
you want var1 var2 and var3 to somehow have just one allocation instead of three?
Simple Sorcerer
okay, so what is it you want with these var1, var2 and ...?
These are heavy classes that only need to be created once and then used throughout the life of the object. This is very similar to simply using variables of type int or any other type. but since they take a lot of resources to create, I don't want to waste CPU time doing this every time
Simple Sorcerer
you want var1 var2 and var3 to somehow have just one allocation instead of three?
I don't understand the question. Can you rephrase it?
Manav
I don't understand the question. Can you rephrase it?
i was thinking about tagged unions but i doubt you want that
Manav
unions allow you to keep multiple things in one place but only one thing can exist at a time
Simple Sorcerer
so what's the issue with having them as member variables?
There's no problem with that. But I'd like the code to be optimised.
Manav
There's no problem with that. But I'd like the code to be optimised.
last question, by heavy objects do you mean var1, var2 var3, .. or a1, a2, a3, ...?
Simple Sorcerer
var<n>
Simple Sorcerer
they're also classes
Manav
var<n>
well then there' not much you can do since each a1 needs it's own var1, var2, ...
harmony5 🇺🇳 ⌤
they're also classes
Do you need objects or classes in varn?
Simple Sorcerer
I just need to use these objects as ordinary variables and I use them in several functions. And it would be great that after the function is finished they are not destroyed, but remain in memory, so that the next call of the function does not have to create them anew
Manav
and these objects need to be unique for each a1, a2 and a3. And their lifetime is the same as a1, a2, a3, ...?
Simple Sorcerer
yes
Manav
keep them as member functions and for performance, i'd worry about why these objects are so heavy.
Simple Sorcerer
okey)
Manav
i'd also suggest setting up a profiler see how many different a's you have in one time. Let's assume you have 100 different objects of type A, then vars will be 300 (3 for each A).
Manav
if each of var is like 1mb in size, that's at least 300mb of stuff that'll need to exist in one time.
Manav
struct obj1 { double heavy_stuff[1000]; // used by a int lighter_stuff; // used by a }; struct obj2 { double heavy_stuff[1000]; // not used by a int lighter_stuff; // used by a }; struct obj3 { double heavy_stuff[1000]; // not used by a int lighter_stuff; // used by a }; struct A { void fun1() { for(var1.heavy_stuff) { // do some stuff } var1.light_stuff = ... } void fun2() { var2.light_stuff = ... } void fun3() { var3.light_stuff = ... } obj1 var1; obj2 var2; obj3 var3; };
Hasna
#include <stdio.h> int main() { char test; test = -1; /* how come is this possible ? */ if (test == -1) printf("confuse !\n"); }
harmony5 🇺🇳 ⌤
1 byte can hold negs too
Hasna
Ok
Ziky
But I guess compiler gave you at least two warnings
Ludovic 'Archivist'
But I guess compiler gave you at least two warnings
The warnings here would be platform dependent, char may or may not be signed, left to implementer's whim
Ziky
Basic types are always a lot of fun...
Software
Hey I'm a c++ developer.where can I get a pdf to learn more about c++20?
Lyper
@Hackchefs Are you a hacker?
Somehow a Script Kiddie
Ludovic 'Archivist'
Hey I'm a c++ developer.where can I get a pdf to learn more about c++20?
That is quite a hard question, because a lot of the changes on the standard are discussed behind closed doors, but the following link https://en.cppreference.com/w/cpp/compiler_support#cpp20 will lead you to a table where every C++20 change has an associated document as the second column of the table If you don't care about the details, you can watch what feels interesting among the different talks of CppCon and C++OnSea on Youtube on the respective channels of these conferences
Ludovic 'Archivist'
Somehow a Script Kiddie
Self awareness is a great first step at least
Mehrad
hello everybody how can i call copy constructor of a class with rvalue given in the argument ? i mean it will show the effect const reference impact
Ayomide
Hello everybody, I have an assignment i was given, I'm trying to build a replica of printf function.. Please how do i go about all these requirement,
Ayomide
Hello everybody, I have an assignment i was given, I'm trying to build a replica of printf function.. Please how do i go about all these requirement,
Handle the following length modifiers for non-custom conversion specifiers: l h Conversion specifiers to handle: d, i, u, o, x, X
Ayomide
Hello everybody, I have an assignment i was given, I'm trying to build a replica of printf function.. Please how do i go about all these requirement,
Handle the field width for non-custom conversion specifiers Handle the precision for non-custom conversion specifiers. Handle the 0 flag character for non-custom conversion specifiers. Handle the - flag character for non-custom conversion specifiers.
Ayomide
Is collaboration allowed in your assignment?
Yes... It is a collaborative project from a learning platform i currently learning c programming language, but my partner hasn't been responding
Ludovic 'Archivist'
Hello everybody, I have an assignment i was given, I'm trying to build a replica of printf function.. Please how do i go about all these requirement,
Start by making a version of printf that supports no specifiers and just uses putchar to print the string, then handle specifiers one by one while testing
Ayomide
Start by making a version of printf that supports no specifiers and just uses putchar to print the string, then handle specifiers one by one while testing
Okay... I figured that out already though!!!.. just thinking about how to handle the flags, width, precision, and size with it
Ayomide
That's the firs assignment I have seen that has allowed 3rd party collaboration, wow
Well just two though... I'm asking questions here to see if i can get idea moving forward
Ludovic 'Archivist'
Okay... I figured that out already though!!!.. just thinking about how to handle the flags, width, precision, and size with it
one at a time, don't try to solve the problem all at once, handle the flags in the order in which they may appear, and have a default value setup in case they do not
Ludovic 'Archivist'
Okay... I figured that out already though!!!.. just thinking about how to handle the flags, width, precision, and size with it
You can even try to make the flags work before you parse them, by using the default values to manipulate them first
Ya deway
It has nothing to do with the compiler, It's the header. My recommendation is using this header for Windows Internals Programming https://github.com/MiroKaku/Veil
I was wondering if it was possible to directly use the offsets available on the website www.geoffchappell.com so as to avoid the github repo
Ya deway
I have to change few values in the structure
Ya deway
What offsets? KUSER_SHARED_DATA ?
I'm currently looking at the ETHREAD structure: I should change: CreateTime, StartAddress, CLIENT_ID Cid struct, probably DeadThread or HasTerminated, ThreadsProcess, StartAddress ThreadListEntry, And probably others
Ya deway
The goal would be to detach the thread from the parent process and change the position in the list where it is located and other small information
Ya deway
Very Instable
Gaitham
okay
Ибраги́м
https://dogbolt.org/
Rose
Another one bites the dust...! Banned Xpro. Reason: ad spam
Devil
I need codes for making array in c++
Kenshin
I need codes for making array in c++
C Style: int64_t arr[128]; Using C++ std lib: import std; //Or #include <array> std::array<int64_t, 128> arr; Also, std::array arr{1, 2, 3, 4, 5};
Kenshin
C++ style bro
Read my message again. There is a section for C++ std lib. That, and built-in arrays in C++ are created same as in C.
Kenshin
Ohh sorry
Change the int64_t data type and size of array in my snippet to whatever you desire. If you desire a dynamic array though, consider std::vector.
Peppe289
Hi guys, I'm creating a dynamic library to control the system. is there a way to see the cpu frequency without going to read the node in /sys or /proc? Some syscalls or something via assembly? I'm creating it in C / C++ I have already created a syscall to clean the cache, do I have to do another one for this information?
Eldos
Hi everyone
Eldos
Could you give me some websites to practice our skill in Standart Template Library
zahra
I get this error in the output of the vscode program when it comes to fixing what to do? /usr/include/c++/11/bits/stl_iterator_base_types.h:249:11: error: no type named ‘iterator_category’ in ‘struct std::iterator_traits<my_namespace::Point3>’ 249 | using _RequireInputIter =