Anonymous
hm, then it will be Container<int>::U, same as we need to change typedef T value_type to typedef U value_type now. And same as we need to change value_type everywhere outside template if we rename it for example to type_value. I still don't see any reason for the forbid that. Unless, as you say, the parser will be more complicated
It is meaningless like I said. So you are enforcing a dependency on a template parameter in your code when in reality those parameters are meaningful only during compilation stage. That is why it is ok to define a class with template parameter T in one place and the same class token for token with template parameter U in a different place. This won't violate ODR. Moreover the standard allows type definitions to be accessed using scope operator only through typedefs or using statements. This maintains uniformity. Moreover placing the requirement that such typedefs use names like value_type, reference and so on makes it easier to use containers seamlessly.
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.
trynafindanu
Anyone up for chat? 🥱
trynafindanu
Chill admin I'm not bot Just feeling bored that's why i text that
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🔥
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
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
Hum, I thought that these tests were a little bit more "generic" if you understand me, can you provide me some document or link about it?
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
\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
Danya🔥
Sure look up kendryte 510k
I'm interested in detailed architecture overview
Юрий
I'm interested in detailed architecture overview
External links aren’t well tolerated in this chat, check canaan dot io website
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
Ok, seems like i have to learn about it as cli tool
Just find gdb cheatsheet in Google :)
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....
Saeed
clang-tidy
Thank you 🙏
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
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)?
It depends on how you create the objects, if you have a function to create them in-place in the vector, and the function can be templated with the actual type and constructor arguments, then you probably can still use custom allocators. However you probably won't be able to make your vector copyable then, and reusing space in the vector (after removing objects) is going to be painful.
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
Anonymous
Can I use gnu indent as linter and not beautifier?
Gnu indent is a code formatter and not a lint tool. Lint tools basically do static analysis of your code. gnu indent doesn't.
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
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
Idris
I want to learn the programming language
Idris
Just need the resources
klimi
Just need the resources
have you checked the pinned 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
Buy the book The C++ Programming Language from Bjarne Stroustrup and do all the exercises. ALL OF THEM!!
How many total study hours would that take for a noob to C/C++ do you think
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> { };
Guillermo
How many total study hours would that take for a noob to C/C++ do you think
You will get a basic level in 3 months studying 1 hour every day. The important thing is to practice, I mean, do every exercises and practice. The more you practice the more you will learn.