Sign in to follow this  
chadsxe

Accessing functionality inside boost::ptr_list

Recommended Posts

chadsxe    146
Hi, I am getting a little mixed up at the moment. I am trying to access the functions of a class object that is inside boost::ptr_list. That boost::ptr_list is held inside a different class object which is held inside a std::vector. So in short
// When the button is hovered
if( m_listboxes[i]->GetID() == m_currentHoveredControl )
{
	// Tell it is hovered
	for ( unsigned int n = 0; n != m_listboxes[i]->GetListItems().size(); n++ )
	{
		// I am try to access the certain listItem held inside a boost:ptr_list
		// Obviously this does not work but I am trying to figure out what I need to do. 
		//m_listboxes[i]->GetListItems()[n].SetHovered( true );
	}
}



m_listboxes is a std::vector which holds a class object which holda a boost::ptr of "listItems". Regards Chad [Edited by - chadsxe on February 11, 2010 11:14:44 AM]

Share this post


Link to post
Share on other sites
Zipster    2365
A boost:ptr_list doesn't have random access, so you'll need to use iterators. Plus it might not be a bad idea to use some aliases here and there [smile] And typedef's, too, which I omitted:

ListBoxType* listBox = m_listboxes[i];
// ..
if(listBox->GetID() == m_currentHoveredControl)
{
boost::ptr_list<ItemType>& listItems = listBox->GetListItems();

for(boost::ptr_list<ItemType>::iterator it = listItems.begin(); it != listItems.end(); ++it)
{
it->SetHovered(true);
}
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this