Nils
I am unsure about is, it looks too weird to be a good idea xD
Nils
thx
Nameful
I am unsure about is, it looks too weird to be a good idea xD
It looks like you're getting the reference of a variable and then de-referencing that reference
Nameful
in other words, accomplishing nothing
Nils
Wow code::blocks is very buggy
Nils
You can
I am having trouble with doing so... https://hastebin.com/uyopicehet.cpp
Nils
I am having trouble with doing so... https://hastebin.com/uyopicehet.cpp
The error is: error: invalid conversion from ‘const char*’ to ‘std::map<char, std::__cxx11::basic_string<char> >::key_type’ {aka ‘char’} [-fpermissive]
Nils
and: error: ambiguous overload for ‘operator[]’ (operand types are ‘std::map<char, std::__cxx11::basic_string<char> >’ and ‘const char [6]’)
Nils
both in line 16 of the paste
Oladoja
Powershell
Nils
Having even more error chaos now… :-/
Nils
https://hastebin.com/supezobewi.m
SYED
hi @all can anyone tell me that i can create a varible in heap in c++
Alion🦁
Ajay
Does RVO happens in case of string? string fun(){ ... string s; s = "abc"; return s; } int main(){ string s = fun(); } Inside main(), does copy happens or transfer?
Dima
/warn Non approved admin post
Dima
Thanks
Ajay
in this case the move constructor of std::string() should run
ok so i shouldn't worry about slowness
Anonymous
ok so i shouldn't worry about slowness
https://en.cppreference.com/w/cpp/language/copy_elision your case is called NRVO. i'm not sure if the move constructor can be skipped as well because there is an extra assignment.
Anonymous
But please do not split declaration and assignment
Dima
yes
Dima
maybe C89 tutorials lol
Ajay
But please do not split declaration and assignment
actually I am returning an array element containing a string so i used it as an analogous.
Dont
cristal clear!!! thank you very much m8!!!
U welcome i am glad i could help
Ajay
string fun(){ ... string s; ... s = "abc"; return s; } int main(){ cout<<fun(); } Above code doesn't print anything/garbage. BTW, if I had to print it directly rather than storing the returned value in some string then how should I do that other than doing it using string_view or c-style string?
cadalt ⚡ 𓄂𓍊𓋼
Remove @MissRose_bot from there
Ajay
prints abc for me regardless of optimisation. same in both gcc and llvm
oh sorry, I pasted the wrong code. Here's the correct one string_view fun(){ ... string s; ... s = "abc"; return s; } int main(){ cout<<fun(); }
Anonymous
It's ub
Ajay
yeah
Ajay
what happens on return?
Anonymous
what happens on return?
string_view constructor call
Anonymous
registerations end soon
Anonymous
what happens on return?
trying to access contents of string that has been destroyed already
Dima
string is in a stack
Dima
stack gets cleared in the end of a scope
Dima
so all variables
Anonymous
What should I buy for programming? A rtx 2080 with latest ryzen processor PC or a 16 inch macbook?
Asdew
ThinkPad X220
klimi
What should I buy for programming? A rtx 2080 with latest ryzen processor PC or a 16 inch macbook?
You are quite crazy, like I code on lenovo g560, i3-380m with 4gb ram
klimi
ThinkPad X220
X220 gang I see
Asdew
X220 gang I see
I sadly don't have one, yet.
klimi
I sadly don't have one, yet.
Will you buy that old hardware
Ибраги́м
OK, let me destroy this u this time
Dima
#ot
Martin
💡💡💡Hi everyone. I'm completely new to programming and have never written a single line of code. Shall I start with C, C++, D or Rust? Do C/C++ or D programmers see Rust as a serious alternative? I'm especially drawn to the safety features/memory management during compilation. I've also heard that the hardest issue with writing C is memory management issues whereas Rust would solve this. Rust on the other hand may be more difficult just because one has to relearn if coming from C/C++. Would not having any prior coding experience in my case be an advantage to get straight into D or Rust instead? Is D comparable to Rust in terms of being a "safer" language?
klimi
people traditionally use whatever they know the most or i most comfortable
Jussi
Start with python
Anonymous
Jussi
/warn no
Wow, why did I get this?
klimi
Wow, why did I get this?
i think Danya just got mad... but i think you deserve it
Jussi
Very helpful, well thanks for the warning lol
klimi
Very helpful, well thanks for the warning lol
you don't get what this group is about do you
Jussi
Helping other people out? Or praising C-languages?
Jussi
Now Im not sure which one
Anonymous
💡💡💡Hi everyone. I'm completely new to programming and have never written a single line of code. Shall I start with C, C++, D or Rust? Do C/C++ or D programmers see Rust as a serious alternative? I'm especially drawn to the safety features/memory management during compilation. I've also heard that the hardest issue with writing C is memory management issues whereas Rust would solve this. Rust on the other hand may be more difficult just because one has to relearn if coming from C/C++. Would not having any prior coding experience in my case be an advantage to get straight into D or Rust instead? Is D comparable to Rust in terms of being a "safer" language?
0) I'm impressed of your knowing of programming languages when you have no experience 1) I'd suggest to start from C++, so-called Modern C++. D is a good language, but the community is not as large as C++ one C is not a good choice for starting, but for continuing — why not? It has its issues with some features that allow writing unsafe code Rust is good language though. I've never tried it. My personal opinion is not good language to start with because of advanced memory management 2) Rust is good replacement for C, not C++ 3) Rust is young language, D is not but still is not popular. You can start with D or C#, yeah. C# is a better choice because of community and support. D has less possiblities 4) D and Rust both are pretty safe
Jussi
I just mean, if a person comes in, has not written a single line of code ever, I think they should start with a simple programming language which abstracts out for example types, which is a common place where newbies get already lost. Especially in C++ with templates.
Jussi
Why do you warn me solely based on your personal opinion vs mine?
Jussi
@unterumarmung
Dima
always thinking he’s right:)
Jussi
Not stated in rules
Anonymous
Why do you warn me solely based on your personal opinion vs mine?
And yeah, the person hasn't written anything about Python, have you noticed?
Anonymous
Not stated in rules
It's stated lol
Anonymous
Admins, give link to rules please