codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <stdio.h> #include <boost/function.hpp> #include <boost/bind.hpp> class Foo { public: Foo() { printf("Foo::Foo\n"); } ~Foo() { printf("Foo::~Foo\n"); } Foo(const Foo&) { printf("Foo::Foo(const Foo&)\n"); } Foo& operator=(const Foo&) { printf("Foo::operator=(const Foo &)\n"); return *this; } }; void Function(const Foo&) { printf("Function invoked\n"); } int main(void) { { boost::function<void(void)> func; { Foo f; printf("\nConstructing function\n"); func = boost::bind(&Function, f); printf("Construction complete\n\n"); } printf("\nCalling function\n"); func(); printf("Calling complete\n\n"); } printf("Function has been destroyed\n"); }
Private
[
?
]
Run code
Submit