Hacker News new | past | comments | ask | show | jobs | submit login

There's some small effort to land quality-of-life improvements to the C++ standard library but it feels like too-little too-late.

As an example, for years C++ didn't have std::string::contains() because you could write find(x) != npos -- and so the argument is why carry around this unnecessary function? Well, because that's what programmers often actually wanted. C++ 23 will finally get std::string::contains()




> As an example, for years C++ didn't have std::string::contains() because you could write find(x) != npos

Yes, because you would have a utility header where you implemented it like so:

    bool contains(const std::string& s, char c) noexcept 
    { return s.find(c) == std::string::npos; }
> and so the argument is why carry around this unnecessary function? Well, because that's what programmers often actually wanted.

No, we didn't want the method, we wanted the function. Actually, string has way too many methods, most being useless, in the sense that they are trivial to implement as freestanding functions.

But really, what programmers (should) actually want is uniform function call syntax: https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax - which would let us blur the distinction between freestanding functions and methods.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: