6 #ifndef mmx_shared_object_hpp
7 #define mmx_shared_object_hpp
26 #define define_operator_rrr(parm0,parm1,parm2,opname,function) \
28 opname(const parm1& x, const parm2& y) { \
29 parm0 r; function(r.rep(),x.rep(),y.rep()); return r; \
32 #define define_operator_rr_(parm0,parm1,parm2,opname,function) \
34 parm0 opname(const parm1& x, const parm2& y) { \
35 parm0 r; function(r.rep(),x.rep(),y); return r; \
37 #define define_operator_r_r(parm0,parm1,parm2,opname,function) \
39 parm0 opname(const parm1& x, const parm2& y) { \
40 parm0 r; function(r.rep(),x,y.rep()); return r; \
43 #define define_operator__r_(parm0,parm1,parm2,opname,function) \
45 parm0 opname(const parm1& x, const parm2& y) { \
46 parm0 r; function(r,x.rep(),y); return r; \
50 #define define_function_from_inplace(parm0,parm1,parm2,function) \
52 void function(parm0& r, const parm1& x, const parm2& y) { \
57 #define assert(expr,msg) if (!(expr)) assert (msg);
78 rep(P0 a) : refc(1), obj(a) {};
80 template<
class P0,
class P1>
81 rep(P0 a, P1
b ) : refc(1), obj(a,b) {};
83 template<
class P0,
class P1,
class P2>
84 rep(P0 a, P1
b, P2
c ) : refc(1), obj(a,b,c) {};
86 template<
class P0,
class P1,
class P2,
class P3 >
87 rep(P0 a, P1
b, P2
c, P3 d) : refc(1), obj(a,b,c,d) {};
92 rep(
const rep& o) : refc(1), obj(o.obj) { }
94 void*
operator new(
size_t s)
95 {
return std::allocator<R>().allocate(s); }
96 void operator delete(
void* p)
97 {std::allocator<R>().deallocate((R*)p,
sizeof(
rep)); }
109 if (! --body->refc)
delete body;}
111 {
assert(body->refc>1); --body->refc; body=
new rep(*body);}
119 template<
class P0,
class P1>
121 template<
class P0,
class P1,
class P2>
123 template<
class P0,
class P1,
class P2,
class P3>
147 int ref()
const {
return body->refc;}
148 int ref() {
return body->refc;}
174 const R &
rep()
const {
return *
data;}
180 inline R &
rep(R & r) {
return r;}
184 inline const R &
rep(
const R & r) {
return r;}
226 #endif // mmx_shared_object_hpp
Definition: shared_object.hpp:71
shared_object(P0 a, P1 b)
Definition: shared_object.hpp:120
int refc
Definition: shared_object.hpp:74
T value_type
Definition: shared_object.hpp:219
const C & b
Definition: Interval_glue.hpp:25
shared_object(P0 a, P1 b, P2 c)
Definition: shared_object.hpp:122
R & rep()
Definition: shared_object.hpp:169
void divorce()
Definition: shared_object.hpp:110
rep(P0 a, P1 b, P2 c, P3 d)
Definition: shared_object.hpp:87
R & rep(R &r)
Definition: shared_object.hpp:180
rep(P0 a)
Definition: shared_object.hpp:78
R data
Definition: shared_object.hpp:168
int ref()
Definition: shared_object.hpp:148
shared_object(const shared_object &s)
Definition: shared_object.hpp:129
R object_type
Definition: shared_object.hpp:113
const R * const_iterator
Definition: shared_object.hpp:115
The structure for obtain the template parameter.
Definition: shared_object.hpp:202
rep(const rep &o)
Definition: shared_object.hpp:92
shared_object(rep *s)
Definition: shared_object.hpp:130
Definition: shared_object.hpp:64
shared_object & operator=(const shared_object &s)
Definition: shared_object.hpp:133
iterator operator->()
Definition: shared_object.hpp:141
R & operator*()
Definition: shared_object.hpp:142
rep(P0 a, P1 b)
Definition: shared_object.hpp:81
shared_object(const R &obj_arg)
Definition: shared_object.hpp:128
Definition: shared_object.hpp:61
int ref() const
Definition: shared_object.hpp:147
shared_object(P0 a)
Definition: shared_object.hpp:118
R * iterator
Definition: shared_object.hpp:114
rep(P0 a, P1 b, P2 c)
Definition: shared_object.hpp:84
shared_object()
Definition: shared_object.hpp:125
Definition: shared_object.hpp:164
R obj
Definition: shared_object.hpp:75
shared_object(P0 a, P1 b, P2 c, P3 d)
Definition: shared_object.hpp:124
const C & c
Definition: Interval_glue.hpp:45
T value_type
Definition: shared_object.hpp:205
~rep()
Definition: shared_object.hpp:93
const R & rep() const
Definition: shared_object.hpp:170
~shared_object()
Definition: shared_object.hpp:131
R element_type
Definition: shared_object.hpp:67
rep * body
Definition: shared_object.hpp:104
void leave()
Definition: shared_object.hpp:106
rep()
Definition: shared_object.hpp:89
#define assert(expr, msg)
Definition: shared_object.hpp:57