Ticket #1067: boostfunction.cpp

File boostfunction.cpp, 651 bytes (added by Tarjei Knapstad <tarjei.knapstad@…>, 15 years ago)

Ready-to-run example code

Line 
1#include <iostream>
2#include <boost/function.hpp>
3
4struct Functor {
5
6 Functor(void)
7
8 { std::cout << "Functor constructor (" << this << ')' << std::endl; }
9
10 Functor(const Functor&)
11
12 { std::cout << "Functor copy constructor (" << this << ')' << std::endl; }
13
14 ~Functor(void)
15
16 { std::cout << "Functor destructor (" << this << ')' << std::endl; }
17
18 void operator()(void) const
19
20 { std::cout << "Hello world!" << std::endl; }
21
22 std::string memfunc(void) const
23
24 { return std::string("hello world!!!!!!"); }
25
26};
27
28int main(void)
29{
30 Functor func;
31 boost::function0<void> f(func);
32
33 return 0;
34}