开发者

std::string::back()

开发者 https://www.devze.com 2023-03-19 08:35 出处:网络
Why isn\'t there a std::basic_string<...>::back() member function? The functionality is obviously there, I mean, one can write

Why isn't there a std::basic_string<...>::back() member function?

The functionality is obviously there, I mean, one can write

Am I assuming some wrong equivalence between the potential back() and the two methods above? You can say that my second version is concise enough, but then, why not provide a function which is trivial to implement which brings string one step closer to a container? Is there a caveat I am missing?

Thanks.


There is no particular reason that std::string shouldn't have had these functions and this assertion is supported by the fact that they have been added in the upcoming C++ standard.


If the C++0x standard (or at least the working draft) is to be believed, then front() and back() do indeed now exist.

See section 21.4.5.


MSDN says that there is one. And an accompanying front(). Maybe you just have an ancient, doddery compiler.

0

精彩评论

暂无评论...
验证码 换一张
取 消