Click here to Skip to main content
15,887,417 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: ATL / COM what's the use for ? Pin
Schehaider_Aymen2-Jun-10 21:58
Schehaider_Aymen2-Jun-10 21:58 
QuestionWindows Vista not allowed to write file on C:\Users folder Pin
am 20091-Jun-10 3:50
am 20091-Jun-10 3:50 
AnswerRe: Windows Vista not allowed to write file on C:\Users folder Pin
Randor 1-Jun-10 8:38
professional Randor 1-Jun-10 8:38 
GeneralRe: Windows Vista not allowed to write file on C:\Users folder Pin
am 20092-Jun-10 4:27
am 20092-Jun-10 4:27 
QuestionRe: Windows Vista not allowed to write file on C:\Users folder Pin
Randor 2-Jun-10 7:46
professional Randor 2-Jun-10 7:46 
AnswerRe: Windows Vista not allowed to write file on C:\Users folder Pin
am 20093-Jun-10 4:21
am 20093-Jun-10 4:21 
QuestionProblem with Activex control property pages Pin
Sreenivas00328-May-10 2:17
Sreenivas00328-May-10 2:17 
QuestionAbout the remove() behavior of container list on MAC [modified] Pin
szh12113-May-10 15:47
szh12113-May-10 15:47 
// My code is bellowing:
	  class MyClass{
	  public:
		  MyClass(int key):fKey(key) {}
		  const int GetKey() const { return fKey; }
		  // some other members 
	  private:		  
		  int fKey;
	  };

	  bool operator==(const MyClass& lh, const MyClass& rh)
	  {
		  cout<<lh.GetKey()<<"  "<<rh.GetKey()<<endl;
          return (lh.GetKey() == rh.GetKey());
	  }

	  list<MyClass> myList;
	  // insert some items into myList. The items are with key 1, 2, 3, 4 and 5
	  MyClass val(3);
	  cout<<"Before remove"<<endl;
	  myList.remove(val);
	  cout<<"After remove"<<endl;

//------------------- The source code of list::remove() in MAC sdk 10.4 
    template<typename _Tp, typename _Alloc>
    void
    list<_Tp, _Alloc>::
    remove(const value_type& __value)
    {
      iterator __first = begin();
      iterator __last = end();
      while (__first != __last)
	{
	  iterator __next = __first;
	  ++__next;
	  if (*__first == __value)
	    _M_erase(__first);
	  __first = __next;
	}
    }

	// Erases element at position given.
      void
      _M_erase(iterator __position)
      {
        __position._M_node->unhook();
        _Node* __n = static_cast<_Node*>(__position._M_node);
        this->get_allocator().destroy(&__n->_M_data);
        _M_put_node(__n);
      }


//====================================

My questing is whether it is possible that the value of "__value" might be changed in list::remove()?
I got a strange problem, it might remove 2 items from myList in only one statement "myList.remove(val);".
The log looks like:
    Before remove
1  3
2  3
3  3
4  4
5  4
After remove



The issue is at the line "4 4", does anybody have any idea what happend?

My guess is the statement in list::remove() "_M_erase(__first);" might release or delete the object that __first is pointing to,
and which just is __value. I mean the object __value is not really existed any more after the statement. Is that possible?

Did i miss something? Or there is any rule i need to follow while using container list on MAC?

PS:
The code i posted is just a sample. In my real project, a customized type is used but not "int".

modified on Thursday, May 13, 2010 10:19 PM

AnswerRe: About the remove() behavior of container list on MAC Pin
szh12113-May-10 22:55
szh12113-May-10 22:55 
QuestionChild windows of non-modal dialog not receiving WM_DESTROY (at least not when expected) Pin
mjxy9-May-10 4:49
mjxy9-May-10 4:49 
QuestionHowto put a TrackBar in a Menu ? Pin
yarp27-Apr-10 1:07
yarp27-Apr-10 1:07 
QuestionCreating a borderless MDI child window Pin
Member 381982124-Apr-10 0:00
Member 381982124-Apr-10 0:00 
AnswerRe: Creating a borderless MDI child window Pin
Jonathan Davies24-Apr-10 1:06
Jonathan Davies24-Apr-10 1:06 
QuestionProblems while adding custom header with IWebBrowser2 [modified] Pin
arbittorr21-Apr-10 12:14
arbittorr21-Apr-10 12:14 
AnswerRe: Problems while adding custom header with IWebBrowser2 Pin
Stephen Hewitt22-Apr-10 14:09
Stephen Hewitt22-Apr-10 14:09 
GeneralRe: Problems while adding custom header with IWebBrowser2 Pin
arbittorr23-Apr-10 0:18
arbittorr23-Apr-10 0:18 
GeneralRe: Problems while adding custom header with IWebBrowser2 Pin
Jonathan Davies23-Apr-10 1:57
Jonathan Davies23-Apr-10 1:57 
GeneralRe: Problems while adding custom header with IWebBrowser2 Pin
arbittorr23-Apr-10 22:01
arbittorr23-Apr-10 22:01 
GeneralRe: Problems while adding custom header with IWebBrowser2 Pin
Jonathan Davies24-Apr-10 1:26
Jonathan Davies24-Apr-10 1:26 
QuestionIs it possible to make an activex by WTL Pin
Shuang. Wu15-Apr-10 20:31
Shuang. Wu15-Apr-10 20:31 
AnswerRe: Is it possible to make an activex by WTL Pin
Jonathan Davies15-Apr-10 23:47
Jonathan Davies15-Apr-10 23:47 
GeneralRe: Is it possible to make an activex by WTL Pin
Shuang. Wu16-Apr-10 0:20
Shuang. Wu16-Apr-10 0:20 
GeneralRe: Is it possible to make an activex by WTL Pin
Jonathan Davies16-Apr-10 0:40
Jonathan Davies16-Apr-10 0:40 
AnswerRe: Is it possible to make an activex by WTL Pin
«_Superman_»16-Apr-10 8:02
professional«_Superman_»16-Apr-10 8:02 
GeneralRe: Is it possible to make an activex by WTL Pin
Shuang. Wu18-Apr-10 6:00
Shuang. Wu18-Apr-10 6:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.