Skip navigation.
Home
l'art pour l'art

TOAD: First steps with GNU C++0x lambda functions and closures

See all entries for

John Freeman's C++ Lambda implementation for GCC is still under development
but this weekend I have checked out the development branch of the SVN
repository and wrote the following code:

int main() {
  // create two GUI elements 
  TSlider *slider = new TSlider();
  TWindow *window = new TWindow();
 
  // whenever 'slider' is modified, take its value, convert it from
  // radians to degree and rotate the picture in 'window'
  slider->sigChanged.add(
    [slider, window] () -> void {
      window->setRotation(slider->getValue()*360.0/(2.0*M_PI));
    }
  ); 
     
  slider->setValue(3.1415);
  return 0;
}

I will wait until the C++ lambda code is merged into an official GCC release

TOAD: C++0x lambda functions and closures for GCC are under active development

See all entries for

Supported by the Google Summer of Code™, John Freeman, who is also a co-author of the specification, is working on C++0x lambda functions and closures for the GNU C++ Compiler in the GCC subversion repository. (project description)

I am indeed very excited!

It's Roberts A. Heinleins 100th birthday!

Today is Robert A. Heinlein's 100th birthday!

TOAD: Lambda functions and closures are now part of C++0x

See all entries for

I just read that Lambda functions and closures are now part of C++0x. Once The GNU C++ Compiler supports these, I will redesign the current CPP+Signal'n Slots based closure syntax.

This means that

TCLOSURE2(
  slider,sigChanged,
  _this, this,
  _slider, slider,
  _this->setValue(_slider->getValue());
)

is going to look like

slider->sigChanged->connect([] { this->setValue(slider->getValue()); });

in the future.

TOAD: TModelLayout

See all entries for

Whew! After letting TOAD rest for about six months, there are finally some new commits. TModelLayout is now able to restore itself from a file and I've fixed some minor issues with TPen::setFont and vertical scrolling in TTextArea.