1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

template static members

Discussion in 'C++' started by dshawul, Sep 3, 2010.

  1. dshawul

    dshawul New Member

    Joined:
    Sep 3, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I am trying to re-use memory in a class by using a static list of previously
    used memory. It seems to work but I get a crash at exit for MSVC compile.
    Gcc's compiles exit cleanly. I can't figure out why but I supect something to do
    with template and static stl list ?? If I don't make the class a template it exits cleanly..
    Very simplified code follows :

    Code:
    template 
    class Y {
            static std::list dlist;
    public:
            ~Y() {
                    dlist.pop_front();
            }
    };
    
    template
    std::list Y::dlist;
    
    Y x;
    
    int main() {
            return 0;
    }
     

Share This Page