I do not see a reason why the methods resize and reserve of standard containers have the return type void. In my opinion it would be much better if they would return a reference to themselves. Such a change will not influence on the existed code base.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/01f927fa-9176-44fa-b0a3-e17482f9996b%40isocpp.org.
There is a school of thought that mutators should return void, because there is no way to confuse them with things that return a changed copy without changing the original.
On Fri, Jun 1, 2018 at 3:18 PM, 'Vlad from Moscow' via ISO C++ Standard - Future Proposals <std-pr...@isocpp.org> wrote:
I do not see a reason why the methods resize and reserve of standard containers have the return type void. In my opinion it would be much better if they would return a reference to themselves. Such a change will not influence on the existed code base.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/01f927fa-9176-44fa-b0a3-e17482f9996b%40isocpp.org.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWUGAOfvhiae4FrBm15%2BbjQr9Yw_jdfDTMVdjEnmO0-9g%40mail.gmail.com.
When I first read the suggestion I was sceptical.On Fri, 1 Jun 2018 at 16:51, Gašper Ažman <gasper...@gmail.com> wrote:There is a school of thought that mutators should return void, because there is no way to confuse them with things that return a changed copy without changing the original.If they didn't return void, what would be best for calling mutators on rvalues? Presumably this?auto resize(size_t n) & -> vector&;auto resize(size_t n) && -> vector&&;
This would allow code such as:auto v = std::vector<int>().reserve(20);Which is actually quite expressive, and starts to persuade me.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ffea28da-3c21-4966-bd18-0cbdf813d842%40isocpp.org.
I do not see a reason why the methods resize and reserve of standard containers have the return type void. In my opinion it would be much better if they would return a reference to themselves. Such a change will not influence on the existed code base.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/01f927fa-9176-44fa-b0a3-e17482f9996b%40isocpp.org.
When I first read the suggestion I was sceptical.On Fri, 1 Jun 2018 at 16:51, Gašper Ažman <gasper...@gmail.com> wrote:There is a school of thought that mutators should return void, because there is no way to confuse them with things that return a changed copy without changing the original.If they didn't return void, what would be best for calling mutators on rvalues? Presumably this?auto resize(size_t n) & -> vector&;auto resize(size_t n) && -> vector&&;
This would allow code such as:auto v = std::vector<int>().reserve(20);Which is actually quite expressive, and starts to persuade me.
On Friday, June 1, 2018 at 9:18:45 AM UTC-7, Richard Hodges wrote:When I first read the suggestion I was sceptical.On Fri, 1 Jun 2018 at 16:51, Gašper Ažman <gasper...@gmail.com> wrote:There is a school of thought that mutators should return void, because there is no way to confuse them with things that return a changed copy without changing the original.If they didn't return void, what would be best for calling mutators on rvalues? Presumably this?auto resize(size_t n) & -> vector&;auto resize(size_t n) && -> vector&&;
This would allow code such as:auto v = std::vector<int>().reserve(20);Which is actually quite expressive, and starts to persuade me.I think you meanauto resize(size_t n) && -> vector;because otherwise you've just disabled copy elision.
I do not see a reason why the methods resize and reserve of standard containers have the return type void. In my opinion it would be much better if they would return a reference to themselves.