https://github.com/Renjian-buchai/string-sort
Ideas to make it more advanced (while still being completely useless) are welcome.
1 messages · Page 1 of 1 (latest)
https://github.com/Renjian-buchai/string-sort
Ideas to make it more advanced (while still being completely useless) are welcome.
@limber ice this was the thing I told you about
A few issues imo:
Why are you casting literally every statement to (void)? It provides no benefit whatsoever (from what I know) but adds unnecessary noise to the code.
And I don't know any style guide that would recommend this and it's usually a good idea to follow a popular style guide as that makes it easier for others to read your code without getting used to your style.
Your lexicalAnalyser function takes a reference to a flags int, why not just return one? Output parameters are rarely a good idea if you can avoid them.
You use bit flags for knowing which flags haven been passed which is reasonable but please define constants instead of using magic numbers. A macro or function that does the bit manipulation would probably be helpful as well.
If that's so, i'll limit void casting to ternary statements, i guess.
The rest i'll probably do it later
very interestring
Whe even for ternaries?
Ternaries are expected to have a return value, so if I use it to print to stderr, I want to make sure that I explicitly know that it is not meant to print to stderr and return to a variable
Er, by ternary, i mean things like
Condition?std::cerr<<"error message",1:0;
Honestly if your ternaries have side effects like that then don't use a ternary.
Use an if-else instead
What is a good way to check if a string fails to allocate memory?
Which way do you allocate it?
Just statically
I should swap to dynamically, especially since it's allocated only once, but that's besides the point
There's a hard limit on std::string length, so if I ever hit it, do I just throw an error message and exit?
Now it's dynamically allocated and will probably crash
It's now back to statically allocated because there really isn't a reason to dynamically allocate a local var anyways
Yeah but do you mean a std::string a c string, are you using new or malloc or the std::string constructor?
If you do malloc you should check if it returns a null pointer. If you use new or stdd::string it throws a bad_alloc exception
std::string, and the constructor
But I wasn't asking about memory allocation, sorry for the confusion, but memory reallocation
There's a hard maximum on the size of an std::string, so how do I know if it hits that limit?
I think it throws an std::length_error, based on reading the stl source code, but I'm not completely clear
I was going to say this is literally sort
but no
it's so much less useful lmfao
I love it