olli
i think you are totally wrong, cause such a silly example can be found in 1984, or you think you are the only smart person in the universe?
no he's completely right, read the standard. Also arguing people did it 30 years ago, so it must be right seem foolish. A lot of people think this is valid c++ Code, when it's not (don't do this) union FI { float F; int I; }; int main() { // BAD! BAD! FI V; V.F = 3.141; std::printf("%d\n", V.I); }
Anonymous
Can someone help me link python to c++
Anonymous
Can someone help me link python to c++
What are you looking for exactly?
Anonymous
I won't to link my python program to c++
Anonymous
No
Is it possible to do so
Anonymous
Okay thanks
Anonymous
Or to link c++ to python
Anonymous
Use Google before asking questions here
Anonymous
Okay but they don't give me any useful answers
Anonymous
What do you mean with "link", it is possible to use both languages in the same project as you can load dll files in python as far as i know at least
Anonymous
You will lose the cross platform aspect of python tho.
Anonymous
🤷
Okay thanks
Anonymous
Like to build a software that has both python code and c++
It's too hard for you I think Learn more about Computer Science first
Anonymous
Please send me pdf files of computer science
Vlad
You will lose the cross platform aspect of python tho.
You can compile it on install into the library.
Vlad
Okay thanks
Well it wasn't for you :P
Vlad
It was about non-crossplatform part
Anonymous
Okay
Anonymous
This code is not correct The returned string_view object will refer to local string object that will be destroyed after function call
Anonymous
It doesn't mean it's correct
Anonymous
If it works as you expect it's doesn't mean that it actually works
Anonymous
You can't return string_view that created from a local variable It's like returning a pointer to a local variable
Vlad
You can if you take your string by reference
Vlad
Wat
I mean std::string_view foo(std::string& s) { // return view of s }
Vlad
Although I have no idea what's he trying to achieve with his code.
olli
Notes It is the programmer's responsibility to ensure that std::string_view does not outlive the pointed-to character array:
Vlad
https://godbolt.org/z/8jsvh5
Vlad
This should do, although it's your responsibility now to ensure that the string will be alive along with string_view
Vlad
And I passed to it a temporary string lmao
olli
Vlad
https://godbolt.org/z/89xoE8
Vlad
"This should work now" (C)
Vlad
I also changed arg to be lvalue ref
Vlad
For such accidents not to happen :P
olli
const is better :)
Vlad
const is better :)
Yeah but you can call it with "asdf"
Vlad
Which is error prone
su
no he's completely right, read the standard. Also arguing people did it 30 years ago, so it must be right seem foolish. A lot of people think this is valid c++ Code, when it's not (don't do this) union FI { float F; int I; }; int main() { // BAD! BAD! FI V; V.F = 3.141; std::printf("%d\n", V.I); }
i did it 30 years ago, and i must say, all you fools that lead C++ to that stupid situation it is here, fuck it. just fuck that language, if it allows morons make a stupid decisions and make from a c++ development, being a lightly fast, to the same shit where java is now. ok, you are ruining c++ for 30 yrs, and where are you now? in the same shit as java programmers. sitting together, in the same can.
Vlad
As I did exactly that :P
olli
As I did exactly that :P
why not? std::string_view substr(std::string_view src, size_t from, size_t to) { return src.substr(from, to); }
olli
Cause the task was to create a fast substr from a string
you can call it with a std::string or with a string literal
Vlad
They should be, but I'm still gonna ask
olli
Are literals safe in that case?
yes, because a literal is not of type std::string
olli
the only way to "screw up" would be substr(std::string("asdf"), 0, 2)...
Vlad
I guess string and const char* overload will do better
Vlad
Cause string_view has it's substr anyway
olli
i did it 30 years ago, and i must say, all you fools that lead C++ to that stupid situation it is here, fuck it. just fuck that language, if it allows morons make a stupid decisions and make from a c++ development, being a lightly fast, to the same shit where java is now. ok, you are ruining c++ for 30 yrs, and where are you now? in the same shit as java programmers. sitting together, in the same can.
So what exactly is your issue? Your code had UB 30 years ago? Fix it! If you don't want or can't learn the language use another one, there are enough reasons to use C or C++ over other languages, there are a lot of environments where you simply cannot use Java or you don't want to rely on GC.
Vlad
I guess string and const char* overload will do better
Maybe string_view lvalue ref as well, so you cant assign temporal bs
Anonymous
associativity matters only when there are multiple operators of same precedence that share operands. example - a + b + c -> (a + b) + c precedence is enough to decide the groups in y = x++ * ++x
Dima
lol
Anonymous
lol
Hpo
Anonymous
Hpo
Hey
Anonymous
Hi
Anonymous
Hello😊
Anonymous
klimi
What the f
ZukiZest
any website to learn C?
klimi
any website to learn C?
https://lmgtfy.com/?q=Learn+c+website
Zel
Heh
klimi
You need to ask admins for permission before posting any self promo
kodes
Correct me if I'm wrong but is it that we can use heap memory only using stack?
Vlad
Correct me if I'm wrong but is it that we can use heap memory only using stack?
pointer to that memory will be on stack if it's what you mean
Roxifλsz 🇱🇹
Hello nazi chipmunk
Anonymous
ZukiZest
su
horizon in falling
su
white point balance virginity raped