C++ Learning Community Forum
August 01, 2010, 03:24:55 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Boost Lambda  (Read 571 times)
biggoron
C++ Freak
***
Posts: 351


View Profile
« on: March 29, 2009, 05:17:17 PM »

I can't get it to work in this case.

Code:
void TreeView::clear()
{
    using boost::lambda::_1;

    // TreeNodeChildren is an STL-like container of Gtk::TreeRow
    // const Gtk::TreeRow& is interchangable with const Gtk::TreeIter&
    // refStore->erase takes a const Gtk::TreeIter&

    Gtk::TreeNodeChildren children = scriptsRow.children();
    std::for_each(children.begin(), children.end(), refStore->erase(_1));
}

Errors:

Quote
In member function ‘void TreeView::clear()’:
error: no matching function for call to ‘Gtk::TreeStore::erase(const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >&)’
note: candidates are: Gtk::TreeIter Gtk::TreeStore::erase(const Gtk::TreeIter&)
=== Build finished: 1 errors, 0 warnings ===

Thanks.
Logged

dr voodoo
Global Moderator
rand()%title;
*****
Posts: 214


View Profile
« Reply #1 on: April 04, 2009, 12:01:46 PM »

You need to use boost::bind or boost::lambda::bind there.

Code
GeSHi (cpp):
void TreeView::clear()
{
   Gtk::TreeNodeChildren children = scriptsRow.children();
   std::for_each(children.begin(), children.end(), boost::bind(&TreeView::erase,refStore, _1);
}
Created by GeSHI 1.0.7.18
Logged
biggoron
C++ Freak
***
Posts: 351


View Profile
« Reply #2 on: April 09, 2009, 03:26:26 AM »

Thanks, that got it.
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!