Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. STL thoughts

STL thoughts

Scheduled Pinned Locked Moved The Lounge
c++discussiondockerquestion
32 Posts 16 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CodeGuy
    wrote on last edited by
    #1

    I've been looking at some discussions recently on the forums regarding the C++ STL. Seems like most everyone prefers using classes because the data and methods are bound together. When the data/container is separate from most of the algorithms (as is the case with libraries like STL), then most users don't have a good idea of the capabilities of the library or forget about the algorithms. What do you think of the STL concept?

    R T C V M 7 Replies Last reply
    0
    • C CodeGuy

      I've been looking at some discussions recently on the forums regarding the C++ STL. Seems like most everyone prefers using classes because the data and methods are bound together. When the data/container is separate from most of the algorithms (as is the case with libraries like STL), then most users don't have a good idea of the capabilities of the library or forget about the algorithms. What do you think of the STL concept?

      R Offline
      R Offline
      realJSOP
      wrote on last edited by
      #2

      They sure haven't made things any easier.

      1 Reply Last reply
      0
      • C CodeGuy

        I've been looking at some discussions recently on the forums regarding the C++ STL. Seems like most everyone prefers using classes because the data and methods are bound together. When the data/container is separate from most of the algorithms (as is the case with libraries like STL), then most users don't have a good idea of the capabilities of the library or forget about the algorithms. What do you think of the STL concept?

        T Offline
        T Offline
        Tim Smith
        wrote on last edited by
        #3

        I wonder how many people are like me and just end up using vector, set, map, and a few other assorted classes. I hardly if ever use the algorithms directly. Tim Smith Descartes Systems Sciences, Inc.

        H J J 3 Replies Last reply
        0
        • C CodeGuy

          I've been looking at some discussions recently on the forums regarding the C++ STL. Seems like most everyone prefers using classes because the data and methods are bound together. When the data/container is separate from most of the algorithms (as is the case with libraries like STL), then most users don't have a good idea of the capabilities of the library or forget about the algorithms. What do you think of the STL concept?

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          i love the STL. :rolleyes: as soon as i got the hang of it, i abandoned MFC's collections totally. i use the std algorithms a lot: sort, reverse, unique, etc. i use string and wstring in many apps (especially where MFC isn't an option). i've used functors in a couple of places to do some strange stuff that would've been a hideous mess otherwise. and, i've lately found myself using small things like std::swap or std::min. i used to think STL was worthless - MFC can do a lot of the basic stuff (CStringArray, for example). but, once i really got into STL, i realized how powerful it really is. yummy. i imagine i'd get the same feeling if i ever got into the functional programming languages; but i don't have the time to learn a new language these days. -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

          C C J 3 Replies Last reply
          0
          • C CodeGuy

            I've been looking at some discussions recently on the forums regarding the C++ STL. Seems like most everyone prefers using classes because the data and methods are bound together. When the data/container is separate from most of the algorithms (as is the case with libraries like STL), then most users don't have a good idea of the capabilities of the library or forget about the algorithms. What do you think of the STL concept?

            V Offline
            V Offline
            Vagif Abilov
            wrote on last edited by
            #5

            Well, it depends on algorithm complexity. In case of strings and vectors algorithms are not prioritized - we really think of objects, not methods. But take, for example, quick sort algorithm. Then it's not important what we sort - rather how we sort (I'm oversimplified it a little, but you got the idea). What many developers forget when they start using STL - is that source code reuse has nothing to do with binary code reuse. If you declare and use vector, vector, vector, then you end up with 3 copies of API sets that implement vector functionality. (Once by reducing the number of MFC CList<> collections I managed to reduce the size of the executable by about 100K). In case classes are just slightly different, it is much more efficient to declare a vector of base class elements. If however classes have different storage size, storing by value base class objects does not work. So you end up with an vector of pointers. So like everything else, STL has its pro's and co's. Vagif Abilov COM+/ATL/MFC Developer Oslo, Norway

            1 Reply Last reply
            0
            • C Chris Losinger

              i love the STL. :rolleyes: as soon as i got the hang of it, i abandoned MFC's collections totally. i use the std algorithms a lot: sort, reverse, unique, etc. i use string and wstring in many apps (especially where MFC isn't an option). i've used functors in a couple of places to do some strange stuff that would've been a hideous mess otherwise. and, i've lately found myself using small things like std::swap or std::min. i used to think STL was worthless - MFC can do a lot of the basic stuff (CStringArray, for example). but, once i really got into STL, i realized how powerful it really is. yummy. i imagine i'd get the same feeling if i ever got into the functional programming languages; but i don't have the time to learn a new language these days. -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

              C Offline
              C Offline
              CodeGuy
              wrote on last edited by
              #6

              I love STL as well, but I understand why it scares people too. I typedef the hell out of a lot of my declarations to reduce all the template goo in my code. My own powerful STL faves: 1) Tokenizing strings into a vector from a file in one step, using ifstream, the copy algorithm and back_inserter. 2) Using for_each to call a member function on each item in a vector of object pointers. This is great for simulation programs that I work on.

              1 Reply Last reply
              0
              • C Chris Losinger

                i love the STL. :rolleyes: as soon as i got the hang of it, i abandoned MFC's collections totally. i use the std algorithms a lot: sort, reverse, unique, etc. i use string and wstring in many apps (especially where MFC isn't an option). i've used functors in a couple of places to do some strange stuff that would've been a hideous mess otherwise. and, i've lately found myself using small things like std::swap or std::min. i used to think STL was worthless - MFC can do a lot of the basic stuff (CStringArray, for example). but, once i really got into STL, i realized how powerful it really is. yummy. i imagine i'd get the same feeling if i ever got into the functional programming languages; but i don't have the time to learn a new language these days. -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                I couldn't agree more - where I work I am known as the STL zealot, because I absolutely refuse to use the MFC containers now that I know some STL. It's just so flexible and powerful, I feel like I am barely scratching the surface. I have recently read that the MFC containers were only put in as a stopgap as the STL was not part of the standard at the time. I dunno if this is true or not, but I do know that compared to the STL they seem to me like tinkertoys. Christian Secrets of a happy marriage #27: Never go to bed if you are mad at each other. It's more fun to stay up and fight.

                R E 2 Replies Last reply
                0
                • C CodeGuy

                  I've been looking at some discussions recently on the forums regarding the C++ STL. Seems like most everyone prefers using classes because the data and methods are bound together. When the data/container is separate from most of the algorithms (as is the case with libraries like STL), then most users don't have a good idea of the capabilities of the library or forget about the algorithms. What do you think of the STL concept?

                  M Offline
                  M Offline
                  Mike Burston
                  wrote on last edited by
                  #8

                  For anyone using the STL, you should get a copy the July 2001 "C/C++ Users Journal" - it has a great article by Leor Zolman on how to install a Perl filter that totally reworks the warning and error messages from STL classes. This makes a HUGE difference to working with STL under VC6 - no more of those endless messages that are impossible to decode. Or it you're too cheap to pay for a copy of the Users Journal, go straight to the source : http://www.bdsoft.com/tools/stlfilt.html

                  N 1 Reply Last reply
                  0
                  • M Mike Burston

                    For anyone using the STL, you should get a copy the July 2001 "C/C++ Users Journal" - it has a great article by Leor Zolman on how to install a Perl filter that totally reworks the warning and error messages from STL classes. This makes a HUGE difference to working with STL under VC6 - no more of those endless messages that are impossible to decode. Or it you're too cheap to pay for a copy of the Users Journal, go straight to the source : http://www.bdsoft.com/tools/stlfilt.html

                    N Offline
                    N Offline
                    Nick Blumhardt
                    wrote on last edited by
                    #9

                    Great! Mike, you just hit on my biggest woe with using STL (which I love). Thanks. On the topic, does anyone know of a good *online* STL reference? I've seen a few wonderful paper versions, but it would be handy to keep something searchable on my machine- and I don't trust any of the documentation in MSDN.... Often, I come across something wonderful in STL (like the string tokenising noted above) and feel like singing and dancing... :) everyone here is a bit sus on the STL and I have to keep quiet :( The solution... an STL forum!!! I know we have a VC++ forum, but it's kind of in a different vein to what I mean... Chris? cheers NB

                    T B C 3 Replies Last reply
                    0
                    • C Christian Graus

                      I couldn't agree more - where I work I am known as the STL zealot, because I absolutely refuse to use the MFC containers now that I know some STL. It's just so flexible and powerful, I feel like I am barely scratching the surface. I have recently read that the MFC containers were only put in as a stopgap as the STL was not part of the standard at the time. I dunno if this is true or not, but I do know that compared to the STL they seem to me like tinkertoys. Christian Secrets of a happy marriage #27: Never go to bed if you are mad at each other. It's more fun to stay up and fight.

                      R Offline
                      R Offline
                      Reno Tiko
                      wrote on last edited by
                      #10

                      STL containers are great. The only problem I have with STL is mixing it with MFC GUI code. Many of the functions require a CString as inputs/outputs (e.g. GetWindowText() is a common function that comes up), and I have to pass in a temp CString to GetWindowText() and then convert that into a std::string. Sometimes that scratches me the wrong way, and annoys me like fingernails scratching on a blackboard.

                      J 1 Reply Last reply
                      0
                      • N Nick Blumhardt

                        Great! Mike, you just hit on my biggest woe with using STL (which I love). Thanks. On the topic, does anyone know of a good *online* STL reference? I've seen a few wonderful paper versions, but it would be handy to keep something searchable on my machine- and I don't trust any of the documentation in MSDN.... Often, I come across something wonderful in STL (like the string tokenising noted above) and feel like singing and dancing... :) everyone here is a bit sus on the STL and I have to keep quiet :( The solution... an STL forum!!! I know we have a VC++ forum, but it's kind of in a different vein to what I mean... Chris? cheers NB

                        T Offline
                        T Offline
                        Tim Smith
                        wrote on last edited by
                        #11

                        Here is the SGI one http://www.sgi.com/tech/stl/stl\_index\_cat.html Tim Smith Descartes Systems Sciences, Inc.

                        1 Reply Last reply
                        0
                        • T Tim Smith

                          I wonder how many people are like me and just end up using vector, set, map, and a few other assorted classes. I hardly if ever use the algorithms directly. Tim Smith Descartes Systems Sciences, Inc.

                          H Offline
                          H Offline
                          Henry Jacobs
                          wrote on last edited by
                          #12

                          I was the same way until I started reading "Effective STL" by Scott Meyers. It's a great book. I definitely recommend it.

                          1 Reply Last reply
                          0
                          • N Nick Blumhardt

                            Great! Mike, you just hit on my biggest woe with using STL (which I love). Thanks. On the topic, does anyone know of a good *online* STL reference? I've seen a few wonderful paper versions, but it would be handy to keep something searchable on my machine- and I don't trust any of the documentation in MSDN.... Often, I come across something wonderful in STL (like the string tokenising noted above) and feel like singing and dancing... :) everyone here is a bit sus on the STL and I have to keep quiet :( The solution... an STL forum!!! I know we have a VC++ forum, but it's kind of in a different vein to what I mean... Chris? cheers NB

                            B Offline
                            B Offline
                            Ben Burnett
                            wrote on last edited by
                            #13

                            >>> [snip]...does anyone know of a good *online* STL reference? <<< I've found the following ones to be very good; Dinkum C++ Library (http://www.dinkumware.com/htm\_cpl/index.html) SGI's STL (http://www.sgi.com/tech/stl/) Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)

                            1 Reply Last reply
                            0
                            • R Reno Tiko

                              STL containers are great. The only problem I have with STL is mixing it with MFC GUI code. Many of the functions require a CString as inputs/outputs (e.g. GetWindowText() is a common function that comes up), and I have to pass in a temp CString to GetWindowText() and then convert that into a std::string. Sometimes that scratches me the wrong way, and annoys me like fingernails scratching on a blackboard.

                              J Offline
                              J Offline
                              James R Twine
                              wrote on last edited by
                              #14

                              > The only problem I have with STL is mixing it with MFC GUI code. > Many of the functions require a CString as inputs/outputs (e.g. > GetWindowText() is a common function that comes up), and I have > to pass in a temp CString to GetWindowText() and then convert > that into a std::string    GetWindowText(...) also allows you to take a TCHAR buffer, so you do not have to do an extra wasteful dynamic memory allocation (and free) for the CString.    Yes, std::basic_string does not directly expose the internal buffer, but IIRC, that is one of the "features" of proper encapsulation.    The STL containers can also manage your own string type, or even MFC's CString, if you so desire (always store pointers to objects).    Peace! -=- James.

                              1 Reply Last reply
                              0
                              • C Chris Losinger

                                i love the STL. :rolleyes: as soon as i got the hang of it, i abandoned MFC's collections totally. i use the std algorithms a lot: sort, reverse, unique, etc. i use string and wstring in many apps (especially where MFC isn't an option). i've used functors in a couple of places to do some strange stuff that would've been a hideous mess otherwise. and, i've lately found myself using small things like std::swap or std::min. i used to think STL was worthless - MFC can do a lot of the basic stuff (CStringArray, for example). but, once i really got into STL, i realized how powerful it really is. yummy. i imagine i'd get the same feeling if i ever got into the functional programming languages; but i don't have the time to learn a new language these days. -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

                                J Offline
                                J Offline
                                James R Twine
                                wrote on last edited by
                                #15

                                > [...]i've used functors in a couple of places to do some strange stuff > that would've been a hideous mess otherwise.    Man, once I first learned about (and figured out) functors, I thought that they were the coolest idea! :)    "algorithm" contains lots of cool stuff, I, too, use STL, even the allocators stuff (for preventing heap contention with multithreaded apps), quite often.    Peace! -=- James.

                                1 Reply Last reply
                                0
                                • N Nick Blumhardt

                                  Great! Mike, you just hit on my biggest woe with using STL (which I love). Thanks. On the topic, does anyone know of a good *online* STL reference? I've seen a few wonderful paper versions, but it would be handy to keep something searchable on my machine- and I don't trust any of the documentation in MSDN.... Often, I come across something wonderful in STL (like the string tokenising noted above) and feel like singing and dancing... :) everyone here is a bit sus on the STL and I have to keep quiet :( The solution... an STL forum!!! I know we have a VC++ forum, but it's kind of in a different vein to what I mean... Chris? cheers NB

                                  C Offline
                                  C Offline
                                  Christian Graus
                                  wrote on last edited by
                                  #16

                                  We don't need an STL forum, just the courage to speak freely about STL in the face of public persecution. ;) Christian Secrets of a happy marriage #27: Never go to bed if you are mad at each other. It's more fun to stay up and fight.

                                  C R 2 Replies Last reply
                                  0
                                  • T Tim Smith

                                    I wonder how many people are like me and just end up using vector, set, map, and a few other assorted classes. I hardly if ever use the algorithms directly. Tim Smith Descartes Systems Sciences, Inc.

                                    J Offline
                                    J Offline
                                    James Pullicino
                                    wrote on last edited by
                                    #17

                                    Yes, I am like that. But I hope to improve as I learn the STL more and more. The way I see it, it is better if STL is hard to learn. I will learn it for sure, but others won't, which will make me better than the rest ;) :cool: (2b || !2b)

                                    1 Reply Last reply
                                    0
                                    • C Christian Graus

                                      We don't need an STL forum, just the courage to speak freely about STL in the face of public persecution. ;) Christian Secrets of a happy marriage #27: Never go to bed if you are mad at each other. It's more fun to stay up and fight.

                                      C Offline
                                      C Offline
                                      CodeGuy
                                      wrote on last edited by
                                      #18

                                      LOL, sounds like a religion.

                                      1 Reply Last reply
                                      0
                                      • C Christian Graus

                                        We don't need an STL forum, just the courage to speak freely about STL in the face of public persecution. ;) Christian Secrets of a happy marriage #27: Never go to bed if you are mad at each other. It's more fun to stay up and fight.

                                        R Offline
                                        R Offline
                                        realJSOP
                                        wrote on last edited by
                                        #19

                                        Infidel! I KEEL YOU!!! I KEEL YOU ALL!!!

                                        1 Reply Last reply
                                        0
                                        • T Tim Smith

                                          I wonder how many people are like me and just end up using vector, set, map, and a few other assorted classes. I hardly if ever use the algorithms directly. Tim Smith Descartes Systems Sciences, Inc.

                                          J Offline
                                          J Offline
                                          Jonathan Gilligan
                                          wrote on last edited by
                                          #20

                                          I use a number of the algorithms directly. The problem is that the way Microsoft/Dinkumware implemented STL for VC++, you can't use predicate versions of many of the algorithms (e.g., sorting can only be done using operator >() for a comparison operator), which makes them less than useful. Fortunately, the C++ compiler itself (if you're using SP3 or above) is capable of generating predicates, so you can rewrite the STL to comply more closely with what's documented in Saini and Musser. The real beauty will come when Microsoft finally implements partial-template-specialization, at which point the algorithms will really come into their own. He was allying himself to science, for what was science but the absence of prejudice backed by the presence of money? --- Henry James, The Golden Bowl

                                          J 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups