Dima
yeah I am jk
Alignant
string's aren't hard to implement but you can customize them very well
The hard part is to implement the bunch of functions that work with strings
BinaryByter
i implemented a std::vector in a day
BinaryByter
a string is probably easier
Dima
if it’s based of vector<char> so yeah its super easy
Alignant
String is easier. But you would need to implement split, join, strlen, reverse...
Alignant
Tons of stuff
BinaryByter
and even if
BinaryByter
3 days of work AT MOST
BinaryByter
for increased productivity
Alignant
3 days of work AT MOST
True, but Imagine that some guy just told his program manager that he'll spend some time implementing strings :D
Alignant
Most of them would hire java coders :D
Alignant
They don't bother with perfomance~
olli
Namespaces weren't a thing in 98 iirc
They were, C++03 was primarily a bug fix release
BinaryByter
wait
BinaryByter
a bug fix release?
BinaryByter
we are talking about a specification
Alignant
Yeah... an actual standard... a paper
Alignant
maxi, make a card library... that fits for any card game :D
olli
92 core and 125 library defects were addressed Edit http://open-std.org/JTC1/SC22/WG21/docs/lwg-status.html#TC1 http://open-std.org/JTC1/SC22/WG21/docs/cwg_status.html#TC1
olli
Additionally it added greater consistency and portability. Iirc c++98 did not require to represent a std::vector as continuous block of memory
Alignant
lol
Or even better. A library that indexes a video file and allows you to do a search. There is a neural network that produces a text description for a picture, but nobody used it to search a specific frame in a video https://cs.stanford.edu/people/karpathy/deepimagesent/
Alignant
And guess in what language this library is written c:
Alignant
Python y o t h h t o y nohtyP
Mat
Python y o t h h t o y nohtyP
Python y o t h h t o y nohtyP
Alignant
Python y o t h h t o y nohtyP
Actually, that's what I hate about C++
Alignant
It's impossible to google a name like that
Alignant
Or to spell it in this way
Mat
And guess in what language this library is written c:
The second version uses lua https://github.com/karpathy/neuraltalk2
Alignant
C++ + + ++C
Alignant
Not a bad language, actually
Alignant
Would a link to a SICP book be a violation? It's on mitpress.mit.edu and free
Mat
Would a link to a SICP book be a violation? It's on mitpress.mit.edu and free
If it's legitimate to share, you can do it. But give at least a little sum or something like that
Mat
Welcome :)
Alignant
So, guys. Can you answer my riddle? c:
Alignant
struct A { int data[2]; A(int x, int y) : data{x, y} {} virtual void f() {} }; int main(int argc, char **argv) { A a(22, 33); int *arr = (int *) &a; std::cout << arr[2] << std::endl; return 0; } What will be the output? :D
BinaryByter
But then again, i'm sleepy
BinaryByter
So no guarantee given
Alignant
Nope, it certainly does :D
Alignant
I guarantee it compiles and gives an output
olli
struct A { int data[2]; A(int x, int y) : data{x, y} {} virtual void f() {} }; int main(int argc, char **argv) { A a(22, 33); int *arr = (int *) &a; std::cout << arr[2] << std::endl; return 0; } What will be the output? :D
Probably the output will be like 33 on 32bit systems and 22 on 64bit Systems. However the output is completely implementation defined/undefined, the standard defines no layout if virtual functions are present. Neither does it define how virtual functions will be implemented and dispatched
Alignant
Almost correct :D It's 22 on a 64bit machine, and 33 on a 32bit machine. And I checked it on GCC and Clang :D
olli
Almost correct :D It's 22 on a 64bit machine, and 33 on a 32bit machine. And I checked it on GCC and Clang :D
But please note it is actually not defined and would expect that to be the answer to your question.
Alignant
#include <iostream> struct A { int arr[10]; int lol; }; int main() { A a; for (int i = 0; i < 10; i++) a.arr[i] = i; a.lol = 1488; for (int i = 0; i <= 10; i++) std::cout << a.arr[i]; return 0; } So, it is possible that it'll not print 01234567891488?
⠠⠍⠥⠓⠁⠍⠍⠁⠙⠽⠥⠎⠥⠋
Language: cpp Source: #include <iostream> struct A { int arr[10]; int lol; }; int main() { A a; for (int i = 0; i < 10; i++) a.arr[i] = i; a.lol = 1488; for (int i = 0; i <= 10; i++) std::cout << a.arr[i]; return 0; } Warnings: source_file.cpp: In function ‘int main()’: source_file.cpp:18:29: warning: iteration 10u invokes undefined behavior [-Waggressive-loop-optimizations] std::cout << a.arr[i]; ^ source_file.cpp:17:23: note: containing loop for (int i = 0; i <= 10; i++) ^ Result: 01234567890 Note: cplusplus_gcc assumed, other valid options are cplusplus_clang, visual_cplusplus, you can be more specific next time.
⠠⠍⠥⠓⠁⠍⠍⠁⠙⠽⠥⠎⠥⠋
You have one warning
Alignant
Yes it is. Although this struct is standard layout type there is no guarantee that no padding bytes will be added.
This bot is great. I was checking it out :D Well, that's true. But the main idea was that it a struct with a virtual method inherits a vptr, which is either 8 or 4 bytes
olli
This bot is great. I was checking it out :D Well, that's true. But the main idea was that it a struct with a virtual method inherits a vptr, which is either 8 or 4 bytes
Although most implementers decided to do it that way it is not defined. There is no vptr in the standard. So you cannot rely on it.
olli
Furthermore, even if a vptr is used, the compiler may add padding bytes after it. But I saw what the questions wants to make you think about :)
BinaryByter
I hope
olli
unless you use the align flag
How should alignment help?
BinaryByter
How should alignment help?
that removes padding bytes, right?
Alignant
cplusplus_gcc
That was a rhetorical question :D I just wander why the result is different on the same compiller
olli
that removes padding bytes, right?
No, you may use alignment specifiers to tell the compiler to align a type on a certain boundary e.g. to make use of more efficient instructions.
Alignant
The bot uses -O2 flag, I tried without it
Muhammad Hafif Al Busyro
.
Sid_Cr7
Can normal developer, developed app using C language ?
Sid_Cr7
?
Sid_Cr7
?
Can you developed app using C language?
Anonymous
if it some terminal based app... in theory you could, but there's no point in doing that. C++ has OOP + tons of libs
Anonymous
Can you developed app using C language?
C is better for some calculation algorithms, in my opinion