GNOME Bugzilla – Bug 149483
sigc::var() not documented
Last modified: 2005-02-01 19:31:27 UTC
Documentation should explain that is possible to create a 0-ary functor returning the value of a referenced variable. This can be done by constructing the functor with sigc::var. Here follows a small example. #include <sigc++/adaptors/lambda/lambda.h> int main(int argc, char* argv[]) { int data; sigc::signal<int> readValue; readValue.connect(sigc::var(data)); data = 3; cout << readValue() << endl; data = 5; cout << readValue() << endl; } The expected output is: 3 5
Nota also that lambda group doesn't appear to be documented in the doxygen generated reference. Last time i checked it yield a 404 Not Found in the website. http://libsigc.sourceforge.net/libsigc2/docs/reference/html/group__lamdba.html
Thanks very much. I have added this as doxygen documenation to sigc::var: /** Converts a reference into a lambda object. * sigc::var creates a 0-ary functor, returning the value of a referenced variable. * For instance, * * @code * int main(int argc, char* argv[]) * { * int data; * sigc::signal<int> readValue; * * readValue.connect(sigc::var(data)); * * data = 3; * std::cout << readValue() << std::endl; //Prints 3. * * data = 5; * std::cout << readValue() << std::endl; //Prints 5. * } * @endcode * */ Please try to create an actual patch in future.