Timeline for answer to String class for general purpose library by Loki Astari
Current License: CC BY-SA 3.0
Post Revisions
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 23, 2017 at 12:41 | history | edited | CommunityBot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
| Sep 22, 2016 at 19:29 | comment | added | Loki Astari |
@DutChen18: search and replace this-> with nothing. Then compile with -Wshadow -Werror that will find all the places that you have conflicts. Then re-run your unit test to verify everything works.
|
|
| Sep 22, 2016 at 15:08 | comment | added | DutChen18 | oh boy, i will now have to spend a lot of time refactoring my code. | |
| Sep 22, 2016 at 14:29 | comment | added | Loki Astari | @DutChen18 I got the apart about explicit template instantiation wrong. I have deleted it. | |
| Sep 22, 2016 at 14:29 | comment | added | Loki Astari |
@DutChen18: Apart from doing it the standard way catches more errors at compile time (rather than run time). If not using this-> confuses you this is a sure sign that you have badly named variables. If you work with other C++ developers they will also complain as this is the standard way is not to add this prefix because it catches more errors.
|
|
| Sep 22, 2016 at 14:28 | history | edited | Loki Astari | CC BY-SA 3.0 |
added 32 characters in body
|
| Sep 22, 2016 at 11:55 | comment | added | DutChen18 |
Is there any other reason for not using this-> for every member? IMO it's so much easier to read and i often get confused when i don't use this-> for a member. You say "This will not prevent other types from being valid in From." but when i try to call String::From(true, 2) it says unresolved external symbol, so it does prevent other types from being valid.
|
|
| Sep 21, 2016 at 11:53 | comment | added | Loki Astari | @DutChen18 Note: You did do pretty well. C++ is a large complex language. You just have to learn a few more idioms and things I suggest will become natural. | |
| Sep 21, 2016 at 11:51 | comment | added | Loki Astari |
I would also note. That there is no way you will make your private string as efficient as std::string. The best you will be able to do is equal std::string and the chances of that are very slim as it took them over a decade to get to this point. You have no ability to reserve space so you're always going to be inefficient when it comes to adding more to the string and you are missing out on all their optimizations. You should be re-using std::string not re-writting. So as @utnapistim suggests wrap the std::string in your class and just provide a thin wrapper.
|
|
| Sep 21, 2016 at 8:08 | comment | added | DutChen18 | wow, thanks. I thought that what i had so far wat pretty descent but it seems like i missed out on a lot of things. Currently don't have time to fix those issues, but i'll do so later. | |
| Sep 21, 2016 at 8:07 | vote | accept | DutChen18 | ||
| Sep 21, 2016 at 2:38 | history | edited | Loki Astari | CC BY-SA 3.0 |
added 624 characters in body
|
| Sep 21, 2016 at 1:44 | history | answered | Loki Astari | CC BY-SA 3.0 |