Anonymous
Oh, also interesting by the way, should it be std::move(*this) in the first variant?
i couldn't find a source so i started testing. you were right, return *this causes a copy. but return std::move(*this); calls the move constructor. it seems there is no way to completely avoid a function call. https://godbolt.org/z/fs53Whvz5
Pavel
i couldn't find a source so i started testing. you were right, return *this causes a copy. but return std::move(*this); calls the move constructor. it seems there is no way to completely avoid a function call. https://godbolt.org/z/fs53Whvz5
not sure what you mean by avoiding function call, but I think it may have been pretty unsafe if *this could be moved away like this on any function call on rvalue ref object :)
Pavel
Well, after some thinking, maybe it wouldn't be unsafe If it's temporary, it doesn't matter If we do std::move, then we should be ready to that
Massi
can someone give me some c programmes to read
Vlad
Choose the C language and off you go
Anonymous
Anonymous
not sure what you mean by avoiding function call, but I think it may have been pretty unsafe if *this could be moved away like this on any function call on rvalue ref object :)
> not sure what you mean by avoiding function call https://en.cppreference.com/w/cpp/language/copy_elision (the situations mentioned here are language guarantees, not compiler optimisations)
Diego
struct A { int i; int j; A() : j(0), i(j) { } }; Could someone explain why this produces UB?
Niharika
👍
Massi
How to write a programme which inverses the numbers like 1234 inverse it to 4321
Massi
Division and modulo using the number 10?
JR
Yes
Massi
Okay thanks
JR
I'm glad to help.
Anonymous
## Rules #pinned * You are not entitled to an answer, getting angry about not answered questions will get you warned. * Not checking your problem in google (or any other search engine) first will get you a warn. * Asking to solve an assignment/test/whatever without trying it first yourself will get you a warn or will get you BANNED. We won’t write a code for you, but we can push you forward and suggest something. * Before posting a long code snippet think twice and read the Resources section below. * No “best book” or “best youtube channel” requests, use /get cbook and /get cppbookguide chat commands. * No “best ide” requests, use /get ide chat command to see the suggestions. * Asking for something that is in the pinned message right after joining WILL GET YOU BANNED. * C/C++ discussion preffered (assembly also allowed), asking about other languages (or groups for other languages) right after joining will get you BANNED. * Reverse enginnering, hacking and related topics are allowed, but asking to hack facebook, instagram, etc. is NOT allowed. Also if you ask "how to become a hacker" and obviously have zero knowledge on anything related to that you may get warned or banned. * Legitimate requests for help on code and programming questions are welcome. A request is considered legitimate if it describes your problem, what you've done so far and what went wrong. Requests such as "write my program" or "do my homework" are never considered legitimate. Asking not legitimate questions will result in a warn or ban. See https://stackoverflow.com/help/mcve on how to write good questions. * Asking for book recommendations is ok, but "pls give pdf book" is not allowed, find books by yourself. Posting illegally copied books (or links to those books) is also not allowed and will get you BANNED. * Only English language is allowed, if you speak shitty English or don't understand anything in English YOU WILL BE BANNED. * A little bit of programming related memes, jokes, shitposting are allowed. * NSFW content (porn, nudity, etc.) is not allowed. * Spamming/advertising (job posts are also ads, so ask an admin before posting) will grant you a warning or an immediate ban if you do it right after joining. * Religion, politics and ideological topics are forbidden. * Long code snippets must be posted via a snippet website(links below), posting pictures of code and posting long snippets in the group is not allowed. * If you encounter a problem, while using dev C++ or turbo C/C++, you will not be helped, use another more modern IDE. * Don't post compiled executables, that is obviously a security risk. * Personal messages without asking beforehand are not allowed. * If you want to post a link or some article in this chat you will need an admin approval first ## Resources C/C++ group India: http://t.me/c_cpp_india About asking good questions: * [English](http://www.catb.org/esr/faqs/smart-questions.html) * [Translations](http://www.catb.org/esr/faqs/smart-questions.html#translations) For posting long code snippets: * [GitHub Gist](https://gist.github.com) * [Ubuntu Paste](https://paste.ubuntu.com/) * [Pastebin](https://pastebin.com) ## Reports If you notice any forbidden content, please use the /report command while responding to the offending post to report it to the admins.
/get cppbookguide
Swostik
How to fix linker error in vs code 2020?
Damo
Can anyone help me to create bin and image file in petalinux compiler
Igor🇺🇦
How to fix linker error in vs code 2020?
The same way you fix it anywhere else.
Igor🇺🇦
Plzz do explain.
What's there to explain? You have linker error, it's given by compiler and not related to IDE you're using. No one knows what exact error you have.
Swostik
OK.... I will look into it
Sandro
How to write a programme which inverses the numbers like 1234 inverse it to 4321
int revnum(int num) { int rev = 0; while (num) { rev = rev * 10; rev = rev + num % 10; num = num / 10; } return rev; }
H
struct A { int i; int j; A() : j(0), i(j) { } }; Could someone explain why this produces UB?
in class and struct , member variables allocate from top to bottom.
H
first i, then j but you try to do unlike that.
Anonymous
/get cpp textbook
Meftahi
/get
.
When I install vs code I get error saying: "An error occurred while trying to rename a file in the destination directory: MoveFilefailed; code 2. The system cannot find the file specified." It is giving me option to skip and if I skip then while writting the code there are something that are not being done like while writing HTML code if I put "! " I not getting the boiler plate and some other issues are also there pls help. I have tried both 32 and 64 bit having same problem in both Please help
.
Windows?
I mean yes
EG
Have you tried installing with elevated privileges? As admin?
.
No
.
Okay sir thanks
MRT
hey how i can fix socket buffer size ? if client send big data to server , the server does not receive it and another data must be sent to the server so that I can get the previous data , I marked the data, and it's interesting to me that other small data that is sent after the big data is sent to the server sooner.
Ammar
hey how i can fix socket buffer size ? if client send big data to server , the server does not receive it and another data must be sent to the server so that I can get the previous data , I marked the data, and it's interesting to me that other small data that is sent after the big data is sent to the server sooner.
When a client send large data to server, the server may receive partial bytes of it, in this case, the server must call recv() again until the data is fully received. How does server know that the data is fully received? This is how it works... You have to add length identifier at the beginning of your packet, and always save the return value of recv(), the return value indicates how many bytes is read from the file descriptor, and then compare the value with the expected length. If it's below the expectation length, you have to call recv() again and accumulate the return value until everything is fulfilled.
Ammar
See my work for example: https://github.com/TeaInside/teavpn2/blob/d1a999952ca44210a904d4061529615334a3b032/src/teavpn2/server/linux/tcp.c#L1166-L1306
MRT
i marked data with special character and length, i can get length before data sended
in qt we dont have recv ! if data is not complate socket->readall() most be call again ?
Ammar
i marked data with special character and length, i can get length before data sended
You better of specify how many bytes your length identifier. See: https://github.com/TeaInside/teavpn2/blob/d1a999952ca44210a904d4061529615334a3b032/src/teavpn2/include/teavpn2/net/tcp_pkt_client.h#L39-L53 In the above case, I have to receive sizeof(tcli_pkt_type_t) + sizeof(uint8_t) + sizeof(uint16_t) as initial minimal packet length. After I received them, I can then decide whether the data is completely received or not based on that minimal packet length. Because minimal packet length contains how many bytes to be received.
Ammar
/report
.
What should I do please help
.
I use insiders version also but it is not solving
.
Please help🥺🥺
.
Please anyone about it
Ryno
I am a newbie/beginnee
Anonymous
Can you please help me
MRT
for simple chat server, how many connection needed ?
EG
Please don't ignore help me
Remove completely the folder where the vs code was installed and try again the release version
MRT
one for one client?
how many for one
HaiNahi
Contribute to this project
HaiNahi
https://github.com/SwastikMajumder/cpurenderer
HaiNahi
https://youtu.be/-gmR-pKFskE a output example
Mr.
Hi
Mr.
Anyone know c#
Anonymous
Anyone know c#
/warn offtop
Mr.
Ok
Gulshan
https://del.dog/nopollyreb.txt
Gulshan
What should be done here ?....
Ludovic 'Archivist'
https://del.dog/nopollyreb.txt
you don't want vector<int> array(n); but vector<int> array; array.reserve(n);
Ludovic 'Archivist'
https://del.dog/nopollyreb.txt
https://en.cppreference.com/w/cpp/container/vector/vector Look at the overload (4) that you were using Look here for reserve: https://en.cppreference.com/w/cpp/container/vector/reserve
Gulshan
Thanks buddy 😊
كتابة بحوث 💻
Write a C ++ program that adds three double numbers into a subfunction that receives pointers? Please Help 🥲
Ammar
Write a C ++ program that adds three double numbers into a subfunction that receives pointers? Please Help 🥲
It's not code-writing service group. You can't ask this in this group.
Pavel
struct A { int i; int j; A() : j(0), i(j) { } }; Could someone explain why this produces UB?
Order of initialization of class members is the order in which member appear in the class declaration. In your case i is being initialized first and is being initialized with value of j which isn't initialized yet. I'm not sure if it's UB, but it definitely is not correct code.
Diego
Thanks