Anonymous
Well in my case I don't use clang (just because of this one problem, because I don't want to uglify my code). In generic case you would need to build your code on three major compilers anyway before submitting it to the codebase, if you care about portability, because there's always something broken between compilers anyway (intentionally or not).
Lol. You mean to say you don't use Clang only because it doesn't allow capture by value in structured bindings? How about it's Thin LTO support (much better than WPO in GCC as far as both optimisations and memory usage is concerned)? Anyway you don't have a point to make regarding what I originally said. My point is that a compiler should allow people the option of disabling an extension which is not standard compliant. This doesn't prevent a compiler from providing extensions. It also doesn't prevent people from using these extensions. Infact it makes it clear to the person using that extension that his code will not be portable. This is the main reason for making usage of non standard compliant extensions clearer to the programmer. As far as I can tell, you didn't have anything to say about this.
Anonymous
Yes exactly that, a lot of my code working with tuples, and ability to capture structured bindings helps a lot. I'm not concerned about clang-specific features as for now, I will use it as soon as they support the C++20 feature which is missing for my case. I agree with you, MSVC should have made this optional, but in my personal opinion how clang addressed it is worse.
If that is the only feature you are missing, why don't you upgrade Clang to the trunk version? It supports this feature in backwards compatible mode i.e. even when you compile with -std=c++17. That is because Clang addressed this as a Defect Report for C++17 instead of as a new feature in C++20. Even otherwise, auto [x,y] = <code like std::tie that generates a destructurable object>; auto callable = [x=x](<params>){<body>}; doesn't seem to be so bad so as to completely avoid Clang compiler 😃😃. But I understand that it is a personal choice. Just want you to know that Clang has so many other features that are being slowly migrated to GCC and MSVC that you are missing out on.
Anonymous
Why are you using generalized capture?
Read the posts above that to understand the context.
Mahmoud
input function 3 name with there age and print only age under 20
DaviChan
Hey, someone here written some custom clang-tidy plugins? Im working with a transformer clang tidy check that needs to edit a location that might be matched multiple times
DaviChan
It is a common location for multiple matchers, that all nees to edit tte same node. The node only needs to be edited one though, it is just that it can be accessed theough multiple matchers
DaviChan
Struggle to resolve that :/
Anonymous
Last time I've checked it didn't work in trunk, but will check again, thanks. I'm mostly looking at the cppreference page to check compiler features support.
I checked on godbolt with -std=c++17 just to confirm and capture by value of structured bindings works fine on Clang trunk
Konstantin
Hi I have an old class, let's say MyClass, which I was allowed to refactor, it has a constructor with a const char* data I decided replace it with this for convenience std::string_view data Instances of MyClass are stored in a std::vector, later on there is a code which does regular push_back(some data of type const char*, e.g. "some data") and I'm not allowed to change this code Problem is that push_back does not work anymore because compiler does not see conversion from a const char* to MyClass(although MyClass has an only constructor from std::string_view, therefore it cannot implicitly(Idk why) convert) Solution would be easy if I could change push_back to emplace_back, but I'm not allowed to change that code Are there any ways to get push_back work?
Anonymous
Hi everyone, I've array then I want put it into a if statement, how can I do that? I want make tic tak game.
Anonymous
#include <iostream> using namespace std; int main() { //Main vars /*Main Array ->*/int playboard[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; int player; string playerSelected = "X"; string MachineSelected = "O"; //terrain cout << " | | \n"; cout << " " << playboard[0] << " | " << playboard[1] << " | " << playboard[2] << " \n"; cout << " | | \n"; cout << "-----|---------|------\n"; cout << " | | \n"; cout << " " << playboard[3] << " | " << playboard[4] << " | " << playboard[5] << " \n"; cout << " | | \n"; cout << "-----|---------|------\n"; cout << " | | \n"; cout << " " << playboard[6] << " | " << playboard[7] << " | " << playboard[8] << " \n"; cout << " | | \n"; //get player's number playboard cout << "Please type a number: "; cin >> player; // when player selected a number then program will replace array's number to PlayerSelected if (player = playboard[/*Error is Here*/]) { } } 👆👆👆 Here's my code
Anonymous
playboard is pointer (array) and player is int, therefore you cannot compare those values
So what do I do to replace a playboard[] to playerselected X?
Антон
can I use array int?
You can. I give you a permission
Morax
What does return; do in CPP?
DaviChan
What does return; do in CPP?
Do yo want the details or thr high level funktionality? Anyways, in short: it returns the execution to where the function got called from and also cleans up the local variables of the exiting function
Morax
I'm aware of that... But usually there's some expression after return... But how to interpret return when there's no expression after it..?
DaviChan
like i said 😅
DaviChan
Can only repeat myself. Only difference is that no value will be returned. (In detail: on x64 nothing gets loaded in RAX as return value, the rest is the same)
Morax
Okay. Got it 👍
Anonymous
Konstantin
https://onlinegdb.com/lCSbYaVh_ Good afternoon, I will be very grateful if someone can explain to me why my dobutok function is not working correctly. Really very urgently needed
Also, as far as I remember, onlinegdb provides you with a debugging option, so you can go instruction by instruction. If you don’t know what it is just google “how to debug C++”.
\Device\NUL
What does return; do in CPP?
End a void function
/
Help what is the best way to create a pointer to an array
/
new operator
But without new
Anonymous
/
malloc ig
Because then i have to use delete
/
malloc ig
I mean an array like int arr[12]
Anonymous
Because then i have to use delete
You'll always have to delete if it's dynamically allocated. With malloc, you'll have to free
\Device\NUL
I mean an array like int arr[12]
It's already pointer to stack allocated memory
Anonymous
I mean an array like int arr[12]
Yeah, with malloc : int *ptr = (int)malloc(sizeof(int)*12) Or, int arr[12] int *ptr = arr
/
Can you explain me when to use restrict
/
Yeah, with malloc : int *ptr = (int)malloc(sizeof(int)*12) Or, int arr[12] int *ptr = arr
I think it's because int arr[12] is like a pointer to the array
/
Show code
It's like your
/
Show code
But i mean that int arr[] is a pointer Int *ptr is another
\Device\NUL
I think it's because int arr[12] is like a pointer to the array
Yes, I already told you. Array is just syntatic sugar to pointer
\Device\NUL
https://t.me/programminginc/478344
Anonymous
It's like your
rextester.com/BHZWYH80040
Anonymous
What
I'm just showing you that it works
/
Yes, I already told you. Array is just syntatic sugar to pointer
But if i want to use restrict i need only one pointer i think
/
It's already pointer to stack allocated memory
How can I save the array pointer as int * without using new
/
I can't use restrict if it is an array variable
/
arr[x] is *(arr + x)
But how i use the restrict keyword on an array
\Device\NUL
Do you know
What exactly you want to do with restrict
/
What exactly you want to do with restrict
I want to make the compiler place the pointer in a register
/
What exactly you want to do with restrict
Because it does this thing mov eax, [ebp+ptr] add eax, 4 mov [ebp+ptr], eax mov eax, [ebp+ptr] mov eax, [eax] when it can do this add eax, 4 mov eax, [eax]
\Device\NUL
Yes i think
Try -O2 , if It's still not changed. Try -03
/
Try -O2 , if It's still not changed. Try -03
I mean because there are 2 pointers to the same memory
/
int Arr[] and int *ptr
/
Try -O2 , if It's still not changed. Try -03
I know that to use restrict should be ony one the pointer
\Device\NUL
And show the code
/
Which ABI is this ?
What do you mean
/
And show the code
I have not the code now i have in in the computer
/
Which ABI is this ?
And why you want to know the abi
\Device\NUL
/
What
\Device\NUL
And, eax register is not containing the address. Thus you will access region resulted from the operation instead
/
Now i go to eat