Timeline for C++ string operators
Current License: CC BY-SA 3.0
18 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 6, 2017 at 7:23 | history | edited | Toby Speight | CC BY-SA 3.0 |
I had failed to update copy constructor to use length - thanks @malat for spotting
|
Jun 19, 2017 at 8:14 | history | edited | Toby Speight | CC BY-SA 3.0 |
Use make_unique rather than naked new[]
|
Jun 16, 2017 at 11:28 | comment | added | Rakete1111 |
@Pysis A simple variable data or count is enough to make the compiler complain.
|
|
Jun 16, 2017 at 11:25 | history | edited | Toby Speight | CC BY-SA 3.0 |
I missed a strcpy
|
Jun 15, 2017 at 20:07 | comment | added | Toby Speight |
It's not just about avoiding collisions with std names now; do you know your names won't collide with any future std ? You certainly shouldn't using namespace in a header, and I'm reviewing this code as a candidate header (and the main() as an illustration).
|
|
Jun 15, 2017 at 19:16 | comment | added | Pysis |
I just still find this point convincing when it is apparently too fashionable to criticize using namespace std . stackoverflow.com/questions/1452721/… Why overload standard library function names from a third-party library?
|
|
Jun 15, 2017 at 16:29 | vote | accept | Dries Reyskens | ||
Jun 15, 2017 at 14:40 | history | edited | Toby Speight | CC BY-SA 3.0 |
Show a smart-pointer version
|
Jun 15, 2017 at 14:35 | history | edited | Toby Speight | CC BY-SA 3.0 |
Show a smart-pointer version
|
Jun 15, 2017 at 14:20 | history | edited | Toby Speight | CC BY-SA 3.0 |
Improve efficiency as suggested; add noexcept
|
Jun 15, 2017 at 14:11 | comment | added | Deduplicator | That's certainly true enough. But those further optimizations all somewhat depend on the string being counted... | |
Jun 15, 2017 at 14:00 | comment | added | Toby Speight |
@Deduplicator, I didn't mean to imply that the headers mustn't declare anything outside namespace std . I do find it makes my code clearer if I can be explicit about where functions come from. I think I probably also assume that it reduces risk of accidentally using a reserved identifier, but that's probably illusory! As to the efficiency, you're certainly right there, but I wanted to focus on correctness before optimising further (and real-world implementations go much further, e.g. SSO).
|
|
Jun 15, 2017 at 13:56 | history | edited | Toby Speight | CC BY-SA 3.0 |
We don't need to provide two assignment operators - just pass by value as we need a copy anyway.
|
Jun 15, 2017 at 13:50 | comment | added | Deduplicator |
Let me criticize your review: 1. The c*-headers don't guarantee to confine their symbols to namespace std. They only guarantee to also put them there. 2. Implementing operator+ in terms of operator+= is unconscionably inefficient for this class.
|
|
Jun 15, 2017 at 12:58 | history | edited | Toby Speight | CC BY-SA 3.0 |
Use std::swap as suggested in comments
|
Jun 15, 2017 at 12:24 | history | edited | Toby Speight | CC BY-SA 3.0 |
added 3817 characters in body; added 16 characters in body; added 9 characters in body
|
Jun 15, 2017 at 12:07 | history | edited | Toby Speight | CC BY-SA 3.0 |
added 1572 characters in body
|
Jun 15, 2017 at 11:49 | history | answered | Toby Speight | CC BY-SA 3.0 |