4 ms·
The STL is a huge leap over C, but it could be so much better. On one hand, it's not particularly good for really low level coding, as other people have explai
by jlarocco 15y ago
The STL is a huge leap over C, but it could be so much better.
On one hand, it's not particularly good for really low level coding, as other people have explained.
But on the other hand, it's not really convenient for higher level coding, either.
To see what I mean, compare the interfaces of std::string [1] and Qt's QString [2]. Common, simple things like converting numeric data to/from string, splitting into substrings, and find/replace are a PITA in the STL. The containers are nice, but even they could use some work.
I know it'd never happen, but I think the non-GUI parts of Qt would make a really nice standard library.
[1] http://www.cplusplus.com/reference/string/string/ http://www.cplusplus.com/reference/string/string/
[2] http://developer.qt.nokia.com/doc/qt-4.8/qstring.html http://developer.qt.nokia.com/doc/qt-4.8/qstring.html
- tspiteri 15y agoI think that std::string does not support conversions as part of the class because those operations do not need direct access to the internal data of the string class. They could be written as helper functions (as opposed to member functions) easily without loss in efficiency. Member functions are used when they need direct access to the private fields. For example, C++11 has a new group of functions, std::to_string(...), and their counterparts std::sto*(...), which are not member functions [1]. [1] http://en.cppreference.com/w/cpp/string/basic_string http://en.cppreference.com/w/cpp/string/basic_string