// Suite question 4

template <class T>
inline void CStackList <T>::swap (void) throw (CException)
{
    if (!m_Sommet || !m_Sommet->GetSuivant ()) throw CException (CstNoSwap, "Swap impossible");

    CElemGen <T> Sommet  = Pop();
    CElemGen <T> Dessous = Pop();
    Push (Sommet);
    Push (Dessous);

    /** / ou, plus difficile à écrire mais plus performant :

    CElemGen <T> OldSommet  = m_Sommet;
    m_Sommet = m_Sommet->GetSuivant ();
    OldSommet->SetSuivant (m_Sommet->GetSuivant ());
    m_Sommet->SetSuivant (OldSommet);

    /**/

} // swap()

// Suite question 5

template <class T>
inline CStackList <T>::~CStackList (void) throw (CException)
{
    if (!m_Sommet) return;

    // ou : if (0 == m_Sommet) return;

    for ( ; m_Sommet; ) Pop ();

    /** / ou, plus lourd :

    for ( ; m_Sommet; m_Sommet = Ptr)
    {
        CElemGen <T> * Ptr = m_Sommet->GetSuivant ();
        delete m_Sommet;
    }

    /**/

    throw CException (CstPileNonVide, "Pile non vide");

} // ~CStackList()