The POCO C++ Libraries Blog

Have you ever seen anything like STL?

Filed under: Uncategorized by alex at 21:42

I have to share what happened to me today.

But, first, a Meyers’ quote from “Effective STL”:

“… in the nearly 30 years I’ve been programming, I’ve never seen anything like STL. You probably haven’t either.”

Now my story:

I’m developing this app on top of an old DB which is, well, full of data we can’t afford to lose and not from the best design school, to put it mildly. So I end up wrestling this mammoth query, joining across five tables, doing unions, morphing and shaping where clauses, desperately trying to get the right result set and plug all the holes in SQL statement like Scrat water holes in Ice Age 2 (see attached picture for description 😉 ). When I finally think I’m done with the query, test points out a flaw. Due to limitation of MS Access (I know, it should be migrated to something decent, but it can’t be at this time. Period.) SQL dialect, there’s no remedy in SQL. So, I have to resort to some sort of “massaging” the data after it is fetched from the database. So I write a filter – iterator loop on the result set vector (it was meant to be a read-only query), run the thing and it runs – forever. I mean, a little shorter than that, but far from acceptable – on the order of one to two minutes. Scratch, scratch – clearly all clues point to std::vector, which shines in push_back-ing, but erasing from the middle of vector of few thousand 16-type Tuples … you get the picture. And then the light bulb comes on – std::list is the answer to my troubles. But, oh my – there’s no Extraction for std::list in PocoData. So, I fire the PocoData project, not really believing I’ll get away just like that, you know – there must be a catch, Murphy and all, but anyway, I’ve tried crazier things before … so I:

1) copy/paste std::vector Extraction template specialization

2) replace std::vector with std::list in both Extraction.h and my code

3) Recompile everything (with my eyes shut and ears covered 😉 )

4) Fire up the app and – boom! – the correct result set displays right in front of me in a fraction of second

Well, there is no comment needed to the above. I’m still rubbing my eyes and thinking, there must be a catch somewhere, but the stopwatch proves me wrong. No catch. It really was that simple.

If someone has seen anything like STL, please let me know. Because I haven’t.


Does your development look like this? Consider POCO!

  1. I must have got complacent about C++/STL – I would *expect* that to work 🙂

    I do still get excited over how pattern matching in template specialisations (partial or full) works so well. It’s only matched by how easy Haskell makes it to write complex code.

    Comment by Stuart Dootson on April 19, 2007, 23:30

  2. Oh, I agree, now looking back, sure – it is expected to work. And it’s not a rocket science, either. However, my amazement was actually over more than STL. Namely, there’s more entities involved here of which only one is STL. There is PocoData library where Extraction template specializations for STL containers and TypeHandlers for Tuples live. Then there is the ODBC DataConnector, which is a PocoData back-end and has actually nothing to do with this issue, but that’s not obvious immediately. I was simply expecting something to bomb on me – either at compile or runtime. But nothing did and that amazed me and inspired my post.

    Comment by alex on April 20, 2007, 03:22

  3. Hello

    Great book. I just want to say what a fantastic thing you are doing! Good luck!


    Comment by tovorinok on July 5, 2007, 16:23

RSS RSS feed for comments on this post. TrackBack URI

Leave a comment