Ticket #6943: intrusive.cpp

File intrusive.cpp, 1.0 KB (added by safety0ff.bugz@…, 10 years ago)

Reduced example of the issue

Line 
1//****** Header 1 **********
2
3#include <boost/intrusive_ptr.hpp>
4#include <boost/detail/atomic_count.hpp>
5
6using boost::intrusive_ptr;
7
8class Foo;
9namespace boost
10{
11 void intrusive_ptr_add_ref(Foo* psFoo);
12 void intrusive_ptr_release(Foo* psFoo);
13};
14
15class SomeClass
16{
17 boost::detail::atomic_count reference_count;
18 friend void ::boost::intrusive_ptr_add_ref(Foo* psFoo);
19 friend void ::boost::intrusive_ptr_release(Foo* psFoo);
20};
21
22namespace boost
23{
24 void intrusive_ptr_add_ref(Foo* psFoo)
25 {
26 ++(psFoo->reference_count);
27 }
28
29 void intrusive_ptr_release(Foo* psFoo)
30 {
31 --(psFoo->reference_count);
32 }
33};
34
35//****** Header 2 **********
36
37// include Header 1
38#include <boost/intrusive_ptr.hpp>
39using boost::intrusive_ptr;
40
41// Gcc 4.7.0 and clang 3.1 need the following two lines to compile this example
42//using boost::intrusive_ptr_add_ref;
43//using boost::intrusive_ptr_release;
44
45class Bar
46{
47 intrusive_ptr<Foo> psFoo;
48public:
49 Bar(intrusive_ptr<Foo> foo): psFoo(foo) { }
50};
51
52//****** Source 2 **********
53// include Header 2
54
55int main(int, const char**)
56{
57 return 0;
58}