Ludovic 'Archivist'
Chat Boss
قَيسٌ sent a huge message, it has been re-uploaded as a file
Hi,
How can implement polymorphic variable?
class Base{
public:
myVariable;
};
class C1: ..
Anonymous
قَيسٌ sent a huge message, it has been re-uploaded as a file
Hi,
How can implement polymorphic variable?
class Base{
public:
myVariable;
};
class C1: ..
C++20 introduced concepts. If there is some specific functionality that you require on your member variable (like here you expect the member variables to have an overloaded operator<<), you can specify such things using concepts.
Pre C++20, you can do something similar with either inheritance (the member variable itself must form a class hierarchy) or using std::variant (assuming you know beforehand all the possible types...any changes here would require recompilation) or using template meta programming hacks. The latter two solutions would be compile time polymorphism while the former will be run time polymorphism.
Danya🔥
trynafindanu
Anyone up for chat? 🥱
trynafindanu
Chill admin
I'm not bot
Just feeling bored that's why i text that
Danya🔥
trynafindanu
Danya🔥
Aditya☺️
Hi apl
AlanCcE
Hi guys, i'm using clang-tidy to check some code that i did using this command:
clang-tidy —checks=all -header-filter=.* (pretty generic i know)
And he keeps pushing me to put (void) before some functions, after some research i saw that its due to some functions returning values or pointers that "would not have anywhere to go", per example:
152 // Clean memory and populate it
153 (void)memset(path_src, 0, sizeof(path_src));
154 (void)memset(path_build, 0, sizeof(path_build));
155 (void)sprintf(path_src, "%s/src", *path_main);
156 (void)sprintf(path_build, "%s/build", *path_main);
These memset and sprintf functions return a pointer and a byte number respectively, so theoretically without these (void) before the functions would cause the returned values to be lost
I don't know if i misunderstood it or if it's even worth it to really put these '(void)' before some functions, can someone en-light me about that?
I know that these values should be used to do some error handling but even a fprintf has a return value, so how can i know when i can ignore it?
Danya🔥
Hi guys, i'm using clang-tidy to check some code that i did using this command:
clang-tidy —checks=all -header-filter=.* (pretty generic i know)
And he keeps pushing me to put (void) before some functions, after some research i saw that its due to some functions returning values or pointers that "would not have anywhere to go", per example:
152 // Clean memory and populate it
153 (void)memset(path_src, 0, sizeof(path_src));
154 (void)memset(path_build, 0, sizeof(path_build));
155 (void)sprintf(path_src, "%s/src", *path_main);
156 (void)sprintf(path_build, "%s/build", *path_main);
These memset and sprintf functions return a pointer and a byte number respectively, so theoretically without these (void) before the functions would cause the returned values to be lost
I don't know if i misunderstood it or if it's even worth it to really put these '(void)' before some functions, can someone en-light me about that?
I know that these values should be used to do some error handling but even a fprintf has a return value, so how can i know when i can ignore it?
What check exactly enforces you to do this?
Danya🔥
Enabling all checks is not a wise solution because there's a lot of specific checks for the specific projects like linux kernel or llvm
AlanCcE
I'm using clang-tidy in C code btw
Danya🔥
https://clang.llvm.org/extra/clang-tidy/checks/list.html
Danya🔥
I recommend you to enable only the checks you need
Danya🔥
The analysis time will be much shorter
Danya🔥
Also, create a separate config file
Danya🔥
https://github.com/halide/Halide/blob/main/.clang-tidy
Here is an example
AlanCcE
Thx
Sa
\Device\NUL
Is there anybody doing Native API programming on windows? I tried phnt but it seems not working
Arthur
/start@MissRose_bot
Юрий
Shina
/start@MissRose_bot
Alexandr
Hi! I have a code which has something like segfault and i know approximate location in code but the problem is that i cannot debug it - it suddenly crash with error and did not hit any breakpoint which located before bad code. However if i comment bad code - breakpoints work very well. Is there some "pre"-run of program before debug or what?
I use CLion, maybe CLion misunderstood gdb..
Guillermo
You can run the program directly from gdb
Alexandr
Ok, seems like i have to learn about it as cli tool
Guillermo
Even more, if the program crashed, It should be some kind coredump there which you should be able to run from gdb
Guillermo
Danya🔥
Danya🔥
Address, Undefined
Alexandr
I'm so used to use IDE/CMake and all of stuff that i think i need more than just google cheatsheet - also compile it by cmd, find gdb, place it to OS Env and i hope it will work 😂
Alexandr
But i will try. Probably this is the only way..
Guillermo
GDB cheat sheet · GitHub
https://gist.github.com/rkubik/b96c23bd8ed58333de37f2b8cd052c30
Guillermo
You don't need anything more
Alexandr
thx!
Guillermo
If you get stuck feel free to paste the source Code in pastebin or any website like that. Maybe someone can help you
Saeed
Hi
What customizable cli linter do you suggest?
𝕱𝖗𝖔𝖟𝖊𝖓
Being a beginner in c++
Anyone wanna start doing project together...
If yes... Please DM me...
Let's start doing before it's too late....
Anonymous
Saeed
Alexandr
Hi! I have my own implementation of vector for polymorphic types which has one buffer for all of the objects in heap(aligned by max size of derived class). I read about custom allocators and tried to do same thing for std::vector + custom allocator but realized that i can do this sort of buffer just for array of pointers but not for storage where real objects are. Am i right that own allocator does not solve this problem(put objects in one memory area)?
Pavel
Alexandr
i have a function to create them in-place, yep!
Alexandr
Today i explored how std::vector was implemented and knew that there is std::__unitialized_copy_a which copy initializer_list to storage allocated by specified allocator but as i see if i pass pointers to vector constructor, it copies just pointers to my storage..
Danya🔥
/ban 5250021565 sketchy link
Saeed
Can I use gnu indent as linter and not beautifier?
Anonymous
I need help in a c++ multithread implementation
klimi
Eugene
Yo! please does anyone have a cracked leetcode account laying around?
Eugene
please i wouldn’t mind getting one, i will really appreciate it
Ibrahim
Hello everyone, i have a project in c++ object oriented. What i need to do is to make a program where i have 4 up to 6 structures in it (struct) does anyone have a helpful source of projects or something that might help? Thank you in advance
Guillermo
You didn't say anything about your project, please, give more details
klimi
Ahmed
Ibrahim
Caught in 4k huh 😂 nvm i will do it and will send here the code
David
hi, everyone, here, can I ask you a question about vc++ mfc dll ?
David
I have an MFC Regular DLL named A.dll, and there is a global variable HINSTANCE g_other_Dll in A.dll, and I load another B.dll using ::LoadlibraryW.
The code is as follows:
g_other_Dll = ::LoadlibraryW(x:\xxxxx\xxx\ b.ll).
Then I added a dialog with a button on A.dll.
Click this button:
::FreeLibray(g_other_Dll).
Result getlasterror() displays 126 error code.
Why? But, this code "::FreeLibray(g_other_Dll)" , as long as it's not executed in the dialog, will succeed.
David
By the way: g_other_Dll = ::LoadlibraryW(x:\xxxxx\xxx\b.dll).
This code is executed inside InitInstance() of the MFC Regular DLL
NAMO AMITABHA
:)
Idris
Can anyone help me with a full c/c++ course. I can learn from
klimi
Idris
I want to learn the programming language
klimi
Idris
Just need the resources
Idris
Not yet
Guillermo
Just need the resources
Buy the book The C++ Programming Language from Bjarne Stroustrup and do all the exercises. ALL OF THEM!!
dimazava
Hello!
Is there's a way I can create template function with enable_if, which can work with vector, list and tuple? Like is_arithmetic for arithmetic types, but in this case, for, kind of, collections?
Say
do_smth(std::vector<double>{1.0, 2.0})
do_smth(std::list...
do_smth(std::make_tuple...
ByteLawd
Danya🔥
dimazava
std::tuple is not a container
so the only possibility is to compose vector and list? How can I achieve that?
UPD Seems like I've found it, thanks
template<typename T>
struct is_container : std::integral_constant<bool, has_const_iterator<T>::value && has_begin_end<T>::beg_value && has_begin_end<T>::end_value>
{ };
Danya🔥