klimi
where to find
In the source code
Anonymous
Ya but I got this https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3
Anonymous
where in there?
klimi
where in there?
Find the file where it is
klimi
What more to say
Anonymous
wanted a string class implementation code
Anonymous
I don't know how to do that
Anonymous
kindly help
Anonymous
In which folder will that be?
Mihail
Who need it i don't 😁 being a low level guy over here.
and "low level guys" like not having their code being generic and prefer to have the overhaed of doing all checks that could be done at compile time at runtime?
Mihail
weird but ok
Mihail
In which folder will that be?
src/string.cpp, but it won't be as simple as copying the file
Anonymous
Rust, Haskell, golang, haxe, Swift, C#
I wouldn't say C# is a good example. It wasn't available for linux over years
Mihail
No string.cpp here
well that's for libcxx. if you're looking at libstdc++ then idk
Anonymous
I just wanted string class implementation code
Pavel
I wouldn't say C# is a good example. It wasn't available for linux over years
If they wrote the kernel on it, it would be available from the box. The reason the kernel is not rewritten in C++ not because C++ is worser than C. You usually do not rewrite projects just because there's a new language. Otherwise we would constantly rewrite our code.
Anonymous
and nothing else. Where ca I get it?
klimi
Anonymous
Aah !! But I guess I made someone upset
Anonymous
sorry
Anonymous
guys
klimi
guys
Its okay, you will get there eventually
Anonymous
I got it.
Anonymous
But the reason I was asking is
Anonymous
that
Anonymous
which data-member of the string class holds the text when we write
Anonymous
string s = "abcd";
Anonymous
that's it
Anonymous
because naturally "abcd" is of type const char*
Anonymous
correct me on this if im wrong
Mihail
that's implementation-defined, but you can use std::string::data to get a pointer to it.
Mihail
but editing the memory referenced by that pointer is undefined behavior
Anonymous
but I guess the standard implementation must have used some pointer to "abcd".
Anonymous
Is that so?
Anonymous
https://github.com/llvm-mirror/libcxx/blob/master/src/string.cpp Searching "data" shows nothing.
Anonymous
Searching "data" shows nothing.
Anonymous
here
Mihail
but I guess the standard implementation must have used some pointer to "abcd".
yes and you can get that pointer by calling std::string::data
Mihail
Searching "data" shows nothing.
i told you that it won't be as simle as copying the file
Mihail
it doesn't contain the whole definition or implementation of the class
Mihail
what are you trying to do?
Anonymous
Is any text enclosed in "" double quotes const char*?
Anonymous
just wait a bit getting back to u in a sec
Anonymous
https://www.youtube.com/watch?v=Rr1NX1lH3oE
Anonymous
because in this video 3:24
Anonymous
he says "Cherno" is not a std::string but it is const char array
Anonymous
So any text enclosed in double quotes is const char array
Anonymous
and not std::string
Mihail
yes that's true
Anonymous
My bad I was speaking const char*
Anonymous
So that's what I
Anonymous
m asking
Anonymous
what data-member of string class is the "abcd" getting assigned
klimi
"Abcd" is just chars in memory
klimi
So its const char*
Anonymous
I'm not understanding ur meaning of implementation defined
Mihail
you can get a pointer to that with std::string::data
Mihail
I'm not understanding ur meaning of implementation defined
it's up to the library implementors to decide
Anonymous
I hope that the cpp developers use a standard library
Mihail
the standard doesn't define it and you can't be sure
I_Interface
you can get a pointer to that with std::string::data
Could i use auto for this ? Or it needs to be used with cast ?
I_Interface
yeah why not?
with static_cast ?
Anonymous
So its const char*
I guess he said it is const char array and not const char*
Mihail
with static_cast ?
just use auto. don't see why it wouldn't work
I_Interface
just use auto. don't see why it wouldn't work
idk, it's just a guess of mine) didn't use auto for this)
Anonymous
Although I have learnt that array do decay to pointers but they r not the same
I_Interface
better to use smart pointers
Anonymous
the standard doesn't define it and you can't be sure
Didn't understand what u mean by "the stand. doesn't define it..." and why can't I be sure?
Anonymous
Now this is getting completely over my head
Mihail
Didn't understand what u mean by "the stand. doesn't define it..." and why can't I be sure?
well because the library implementors can choose how to store the string and you can't be sure because there are many standard libraries and they have all choose diffrent ways of storing the data