1. 5
  1. 4

    Fully agree, the Qt containers are great and sufficiently efficient. Implicit sharing enabled a programing style which is now associated with modern C++ move semantics long before there was C++11. There are a couple of other extremely useful classes in the Qt base package too, e.g. the unicode strings and conversions, or all the async network and threading features. It’s a long time ago since I last had to use plain standard libraries or Boost. With LeanQt I can now use this fundamental features without being forced to have a full Qt installation.

    1. 2

      I have a complex relationship with the C++ standard library. The lack of contains, as mentioned in the article, is one example of where it’s clearly not a clean abstraction. But then there’s a complaint that std::vector doesn’t have one and there’s a big danger there. In C++, the specific container to use is often provided as a template argument for various things and so you may not notice that the thing that you’re providing a std::vector to uses .contains on the template argument and end up with something that requires a linear-complexity operation on a common operation, whereas the same on std::unordered_set is constant time.

      The biggest problem with trying to avoid the standard library is that you can’t avoid it completely. Other C++ libraries that you use will use standard-library types and you will increase cognitive load by making people switch between the two. Sometimes this is unavoidable. The standard library lacks a representation-agnostic string encoding, and desktop software really wants one of those, so you’re going to be stuck with string copies in some places (and in places where you need to convert to C strings).

      Off-topic grumble: The STL was a library created by SGI. Please can people stop calling the C++ standard library the STL?

      1. 1

        I think it’s very useful to have a simple contains() method also on vector and vector like containers, not only for a unified API, but there is often a case where a simple vector is much cheaper than a hash or sorted container; so you can just use e.g. a QList instead of a QHash or QMap.

        I completely avoid the C++ standard library since 20 years in nearly all of my projects. There are a couple of libraries I use which depend on the standard library; this is no issue at least for me, since I grew up with STL and Qt also has iterators which look like STL and the C++ standard library. Using std::string in a public API is a bad idea from my humble point of view, regardless whether the client is Qt or something else.