Scroom  0.14
boost-bind.cc File Reference
#include <iostream>
#include <boost/bind/bind.hpp>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/test/unit_test.hpp>
Include dependency graph for boost-bind.cc:

Classes

class  A
 

Functions

 BOOST_AUTO_TEST_CASE (keeps_object_alive_while_setting)
 
 BOOST_AUTO_TEST_CASE (keeps_object_alive_while_getting)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( keeps_object_alive_while_getting  )
58 {
59  int value = 25;
60  const int expected = value;
61  A::Ptr a = A::create(value);
62  boost::function<int()> const f = boost::bind(&A::get, a);
63 
64  a.reset();
65  BOOST_CHECK_EQUAL(expected, f());
66 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( keeps_object_alive_while_setting  )
46 {
47  int value = 25;
48  const int expected = 1;
49  A::Ptr a = A::create(value);
50  boost::function<void()> const f = boost::bind(&A::set, a, expected);
51 
52  a.reset();
53  f();
54  BOOST_CHECK_EQUAL(expected, value);
55 }
Here is the call graph for this function:
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(sample.expectedColors, originalColormap->colors.size())
A::set
void set(int v)
Definition: boost-bind.cc:34
A::Ptr
boost::shared_ptr< A > Ptr
Definition: boost-bind.cc:27
A::get
int get() const
Definition: boost-bind.cc:36
A::create
static Ptr create(int &i)
Definition: boost-bind.cc:38