Lists and back() Question.

From: Larry Lindstrom (larryl_at_nospam.com)
Date: 12/16/03


Date: Tue, 16 Dec 2003 10:54:55 -0800

Hi Experts:

    I'm not familiar with STL. I'm trying to use
a list as follows:

class TEST_RECORD
{
      int a;
      char b;
};

typedef list<TEST_RECORD *> TEST_LIST;

void test_function()
{
      TEST_LIST test_list;
      TEST_LIST::const_iterator test_iterator;
      TEST_RECORD *test_record_ptr;

      test_record_ptr = new TEST_RECORD;
      test_list.push_back(test_record_ptr);
      test_iterator = test_list.back(); <-- error
      test_iterator = test_list.begin();
}

    I want to start examining the back of the list
and move toward the front. Setting the iterator
at test_list.back yields the following from MSVC6:

      error C2679: binary '=' : no operator defined
      which takes a right-hand operand of type
      'class TEST_RECORD *' (or there is no acceptable
      conversion)

    Assigning the to test_list.begin raises no
complaints.

    I know the details of STL containers are
opaque, but they to behave as double linked
lists. Isn't there a method to move to the
tail of a list without traversing it from
the front?

                                      Thanks
                                      Larry