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. General Programming
  3. C / C++ / MFC
  4. Query about STL list

Query about STL list

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasequestion
6 Posts 3 Posters 0 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.
  • N Offline
    N Offline
    Nirav Doshi
    wrote on last edited by
    #1

    Hi, I am trying some code similar to what I have posted below, but it is not being compiled on the VC++ 7.0 :(, and on VC++ 6.0 it gives a INTERNAL_COMPILER_ERROR X| :

    #include <list>
    ...
    template <class clDataType>
    class CMyData
    {
        clDataType    myObj;                   // Typically will be a string type only
        unsigned long myObjSize;
    
        public:
        ...
    };
    
    template <class clDataType>
    class CMyManager
    {
        unsigned int  nIndex;
        clDataType    myData;                   // This is ALSO required
        list<CMyData<clDataType>> myList;       // :sigh: This is making me :((
    
        public:
        ...
    };
    

    What I am trying is to have a STL list of CMyData<clDataType>! :confused: Is it possible or am I doing some mistake?! :doh: Thanks, Rgds, Nirav * Don't wish it was easier, wish you were better! *

    H 1 Reply Last reply
    0
    • N Nirav Doshi

      Hi, I am trying some code similar to what I have posted below, but it is not being compiled on the VC++ 7.0 :(, and on VC++ 6.0 it gives a INTERNAL_COMPILER_ERROR X| :

      #include <list>
      ...
      template <class clDataType>
      class CMyData
      {
          clDataType    myObj;                   // Typically will be a string type only
          unsigned long myObjSize;
      
          public:
          ...
      };
      
      template <class clDataType>
      class CMyManager
      {
          unsigned int  nIndex;
          clDataType    myData;                   // This is ALSO required
          list<CMyData<clDataType>> myList;       // :sigh: This is making me :((
      
          public:
          ...
      };
      

      What I am trying is to have a STL list of CMyData<clDataType>! :confused: Is it possible or am I doing some mistake?! :doh: Thanks, Rgds, Nirav * Don't wish it was easier, wish you were better! *

      H Offline
      H Offline
      Henrik Stuart
      wrote on last edited by
      #2

      Your problem is this line: list<CMyData<clDataType>> myList; due to the lexical analysis of C++ it has to be written as this: list<CMyData<clDataType> > myList; as such the space is crucial. The >> is parsed as right-shift, even though it makes little sense in that context (also is why it causes an error). Hope that helps. -- Henrik Stuart (http://www.unprompted.com/hstuart/)

      N 1 Reply Last reply
      0
      • H Henrik Stuart

        Your problem is this line: list<CMyData<clDataType>> myList; due to the lexical analysis of C++ it has to be written as this: list<CMyData<clDataType> > myList; as such the space is crucial. The >> is parsed as right-shift, even though it makes little sense in that context (also is why it causes an error). Hope that helps. -- Henrik Stuart (http://www.unprompted.com/hstuart/)

        N Offline
        N Offline
        Nirav Doshi
        wrote on last edited by
        #3

        Hello Henrik, It worked!... Thanks a ton! :-O... Well pointed out! So much about Micro$oft Compiler! Thanks, Rgds, Nirav * Don't wish it was easier, wish you were better! *

        H 1 Reply Last reply
        0
        • N Nirav Doshi

          Hello Henrik, It worked!... Thanks a ton! :-O... Well pointed out! So much about Micro$oft Compiler! Thanks, Rgds, Nirav * Don't wish it was easier, wish you were better! *

          H Offline
          H Offline
          Henrik Stuart
          wrote on last edited by
          #4

          Hey, You're welcome. It isn't, however, limited to Microsoft's compiler, it's mandated in ISO/IEC 14882:1998 and as such part of C++ as a language. You would get the same behaviour in any other C++ compiler. :) -- Henrik Stuart (http://www.unprompted.com/hstuart/)

          N 1 Reply Last reply
          0
          • H Henrik Stuart

            Hey, You're welcome. It isn't, however, limited to Microsoft's compiler, it's mandated in ISO/IEC 14882:1998 and as such part of C++ as a language. You would get the same behaviour in any other C++ compiler. :) -- Henrik Stuart (http://www.unprompted.com/hstuart/)

            N Offline
            N Offline
            Nirav Doshi
            wrote on last edited by
            #5

            Oh, is it?! My apologies to Bill Gate$ & Micro$oft! * Don't wish it was easier, wish you were better! *

            R 1 Reply Last reply
            0
            • N Nirav Doshi

              Oh, is it?! My apologies to Bill Gate$ & Micro$oft! * Don't wish it was easier, wish you were better! *

              R Offline
              R Offline
              Robert A T Kaldy
              wrote on last edited by
              #6

              Don't apologize. The VC should report this as a parse error, not internal compiler error! :) Robert-Antonio Love, truth and electric traction must gain victory over hate, lie and diesel traction.

              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