gul-cpp / gul14

General Utility Library for C++14
https://gul14.info/
GNU Lesser General Public License v2.1
2 stars 1 forks source link

Remove string_view::to_string() #29

Closed alt-graph closed 1 year ago

alt-graph commented 1 year ago

This PR removes gul14::string_view::to_string(). C++17's std::string_view does not have that member function, so we should not encourage our users to depend on it.

See: cppreference on std::string_view

Finii commented 1 year ago

Was the reason to have to_string() not the absence of a std::string constructor from string_view (which of course the 'real' string_view has)? Or conversion operator, or something?

Finii commented 1 year ago

I have the hunch that we discussed this or other custom-additions to the std:: implementation when we added string_view. Can not find that in Gitlab, maybe it has been in Stash, but that repo is deleted (instead of read-only-ed).

Like these: image

In principle I believe removing would be fine, but we should not shoot ourselves in the foot ;)

alt-graph commented 1 year ago

I have the hunch that we discussed this or other custom-additions to the std:: implementation when we added string_view. Can not find that in Gitlab, maybe it has been in Stash, but that repo is deleted (instead of read-only-ed).

I think we discussed the operators. But in any case to_string() is obsolete as a member function because string_view has an explicit conversion to std::string: image

alt-graph commented 1 year ago

Hope not too many uses already in dependents.

I agree. I just saw Olaf use it in code review and got curious, hence the PR...