Ananth
2017 has only partial/experimental support for c17. 7 years is a long time anyways... major updates are expected every 3 years or so.
Anakin
Would this be considered reflection g++-14 -fdump-lang-class main.cpp cause it shows classes and member sizes and their alignment
Anakin
also I said reflection because this is at compile time
FriedRice
Is there a way to declare function signatures in a base class but leave the definition for the inherited class to implemented? This is for C++17 and so no concept, and I don't want to use virtual because it has too much overhead.
FriedRice
Something like Traits in Rust
FriedRice
Virtual functions are the worst things that C++ has, and it is impossible to work around it before C++20 concept.
Ziky
you can define your method in whatever cpp file but you will get same behavior for all objects inheriting base class
Ziky
or you can put pointer to method into your objects witch may save you one memory read at the cost of bigger objects
FriedRice
I found this - curiously recurring template pattern, it should work.
FriedRice
Basically I declare a template base class, without implementing all functions. And the derived class must implement it because when it is inherited it is also instantiated at the same time.
klimi
and what is that?
Never Spam Bot
Setting requested by klimi set to false
Rose
Reported Faizan [6862697718] to admins.​​​​​​​​​​
Anunay
/warn off topic
Rose
User Faizan has 1/2 warnings; be careful! Reason: off topic
Rose
Welcome Obsidian! Please read the pinned message 🙂 Click the button below to unmute yourself.
Obsidian
What does object oriented language means
Ziky
What does object oriented language means
If you don't have any detailed question please copy your message to your favourite search engine
Obsidian
I just want more in depth one(explaination)
Ludovic 'Archivist'
Is there a way to declare function signatures in a base class but leave the definition for the inherited class to implemented? This is for C++17 and so no concept, and I don't want to use virtual because it has too much overhead.
The question is, do you need dynamic dispatch or not? If you do, pointer to function or type erasure are your best bets, each with their respective drawbacks. If you do not, you can do C++ style traits or rely on method overloading (with the benefit of allowing some amount of dynamic dispatch with variants for example)
Ludovic 'Archivist'
Virtual functions are the worst things that C++ has, and it is impossible to work around it before C++20 concept.
Concepts relate only to static dispatch and static polymorphism, virtual functions only relate to dynamic polymorphism. Those are almost entirely unrelated
FriedRice
You are right, virtual function provides dynamic polymorphism has runtime cost, which is not what i want. CRTP provides static polymorphism, it does not have any runtime cost but user must deal with generic types, so the code will be larger as more types added. Overall I prefer CRTP.
Obsidian
In C++ 11 library,i couldn't catch up with the <regex> and <thread>, could somebody unpack it to me
Ludovic 'Archivist'
In C++ 11 library,i couldn't catch up with the <regex> and <thread>, could somebody unpack it to me
Do not use the <regex> header because all implementations are dreadfully slow, do not use <thread> if you do not understand what you are doing with multithreading, I recommend you experiment with the examples and to get a feel for multithreading, but there are a lot of pitfalls if you have never done it. Otherwise it is basically pthreads
\Device\NUL
Hey guys, I called WaitOnAddress(&g_counter, &g_counter, sizeof(g_counter), INFINITE) to put the main thread to sleep. On the other threads, WakeByAddressSinglr(&g_counter) will be called if some condition met. Am I doing this right ?
Mohammad
C++ book pdf best book
harmony5 🇺🇳 ⌤
Rose
C++ book pdf best book
Please check out this channel - @Resources for information on learning sources for C and C++ (books and videos) and Frequently Asked Questions.
FriedRice
In C++ 11 library,i couldn't catch up with the <regex> and <thread>, could somebody unpack it to me
I don't think you need to learn a specific C++ library, just learn the universal stuff like what is async, coroutine, and how to write regex. These concepts are pretty much same across all languages.
FriedRice
A library should give you easier way to do something, you can do it without the help of library is also important.
Anakin
Lawrence
/start@MissRose_bot
Rose
/start@MissRose_bot
Heya :) PM me if you have any questions on how to use me!
Lawrence
/start@MissRose_bot
Rose
/start@MissRose_bot
Heya :) PM me if you have any questions on how to use me!
Lawrence
/start@MissRose_bot
Rose
/start@MissRose_bot
Heya :) PM me if you have any questions on how to use me!
\Device\NUL
How?
Originally while (g_counter > 0) WaitOnAddress(&g_counter, &g_counter, sizeof(g_counter), INFINITE); While this work, this is actually not efficient because WaitOnAddress not just sleep but also checking so there's double checking. The correct solution is while (WaitOnAddress(&addr0, &addr1, sizeof(addr0), INFINITE)); if spurious wake up happens, the thread will sleep again since the value on the address hasn't changed yet
Guardian Of The
/start@MissRose_bot
Rose
/start@MissRose_bot
Heya :) PM me if you have any questions on how to use me!
Guardian Of The
How to use vectors
\Device\NUL
Randy
anyone have an idea on embedding javascript using v8 in C++?
ma
/warns
Rose
/warns
User ma has no warnings!
B M
/start@MissRose_bot
Rose
/start@MissRose_bot
Heya :) PM me if you have any questions on how to use me!
FriedRice
BTW could you share your method? I am curious what it does when two extra reads are too much overhead
I can provide a simple example here: Godbolt . If I used virtual function, the derived class will be 16 bytes of size even though it only stores a 4-byte int. (16 bytes = 4 bytes int + 8 bytes vtable address + padding due to alignment)
FriedRice
You don't want to store an int in a way that takes 16 bytes for sure in your code.
arcane
recommend me the best C programming course/playlist on youtube
Ziky
You don't want to store an int in a way that takes 16 bytes for sure in your code.
Depends on ammount. Few dozens milions on current desktop is not a big deal
نصرالدين
In the c language when using The fgets() func and give here a char buffer so did the string that i get have a ending indicator like '/0'
Andrey
/warns
Rose
/warns
User Andrey has 1/2 warnings. Reasons are: - don't click every blue text you see 😐
Susmita
/0
Anakin
anyone have an idea on embedding javascript using v8 in C++?
If you wanna do web programming in c++ I’d recommend emacripten, but if you also want to check out v8 for c++ there’s an api for it, I’ve never used it
Anakin
https://v8 dot dev/docs/embed#:~:text=The%20V8%20API%20provides%20functions,including%20the%20header%20include%2Fv8.
Mohale
Help guys wanna create simple games like stickman with c++
Ludovic 'Archivist'
Realistically, a variant that stores a JSON value for example will never be less than 32 bytes, and should probably be 48 bytes (to not add an extra indirection for strings)
klimi
Gui
https://github.com/fffaraz/awesome-cpp?tab=readme-ov-file#gui
Mr
Hi
Wild
How can I use arduino uno
Wild
I want to do programming
Ziky
How can I use arduino uno
https://duckduckgo.com/?t=ffab&q=How+can+I+use+arduino+uno&ia=web
Anonymous
Hi, has anyone seen copy constructor being used in any project
Anonymous
sure
Do you remember the context for it's usage