File: type.h

package info (click to toggle)
libloki 0.1.7-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,608 kB
  • sloc: cpp: 30,475; ansic: 1,974; makefile: 365; php: 316; perl: 108
file content (166 lines) | stat: -rw-r--r-- 4,267 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
////////////////////////////////////////////////////////////////////////////////
// The Loki Library
// Copyright (c) 2006 Peter Kmmel
// Permission to use, copy, modify, distribute and sell this software for any 
//     purpose is hereby granted without fee, provided that the above copyright 
//     notice appear in all copies and that both that copyright notice and this 
//     permission notice appear in supporting documentation.
// The author makes no representations about the 
//     suitability of this software for any purpose. It is provided "as is" 
//     without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////

// $Id: type.h 760 2006-10-17 20:36:13Z syntheticpp $


#include <loki/Pimpl.h>


//#define TEST_WITH_BOOST
#ifdef TEST_WITH_BOOST
#include <boost/shared_ptr.hpp>
#endif

#include <loki/SmartPtr.h>
#include <loki/SmallObj.h>

using namespace Loki;

/////////////////////////////////////////
// class A declaration
/////////////////////////////////////////

class A
{
public:
    A();
    void foo();

private:
    PimplOf<A>::Type d;
};


/////////////////////////////////////////
// class B declaration
/////////////////////////////////////////

class B : private PimplOf<B>::Owner
{
public:
    B();
    void foo();
};


/////////////////////////////////////////
// class C declaration
/////////////////////////////////////////

class C
{
public:
    C();
    void foo();

private:
    PimplOf<C>::Type p;
    RimplOf<C>::Type d; 
};


/////////////////////////////////////////
// class D declaration
/////////////////////////////////////////

class D : private RimplOf<D>::Owner
{
public:
    D();
    void foo();
};




////////////////////
// more test code
////////////////////

struct E;

typedef SmartPtr<ImplOf<E> >      LokiPtr;
typedef ConstPropPtr<ImplOf<E> >  CPropPtr;
typedef std::auto_ptr<ImplOf<E> > StdAutoPtr;

#ifdef TEST_WITH_BOOST
    typedef boost::shared_ptr<ImplOf<E> > BoostPtr;
#else
    typedef LokiPtr BoostPtr;
#endif



// Pimpl

typedef Pimpl<ImplOf<E> >             Pimpl1;
typedef Pimpl<ImplOf<E>, CPropPtr>    Pimpl2;
typedef Pimpl<ImplOf<E>, LokiPtr>     Pimpl3;
typedef Pimpl<ImplOf<E>, BoostPtr>    Pimpl4;
typedef Pimpl<ImplOf<E>, StdAutoPtr>  Pimpl5;

struct P1 {Pimpl1 d;        P1();void f();void f()const;};
struct P2 {Pimpl2 d;        P2();void f();void f()const;};
struct P3 {Pimpl3 d;        P3();void f();void f()const;};
struct P4 {Pimpl4 d;        P4();void f();void f()const;};
struct P5 {Pimpl5 d;        P5();void f();void f()const;};


// PimplOwner

typedef PimplOwner<ImplOf<E> >            PimplOwner1;
typedef PimplOwner<ImplOf<E>, CPropPtr>   PimplOwner2;
typedef PimplOwner<ImplOf<E>, LokiPtr>    PimplOwner3;
typedef PimplOwner<ImplOf<E>, BoostPtr>   PimplOwner4;
typedef PimplOwner<ImplOf<E>, StdAutoPtr> PimplOwner5;

struct PO1 : private PimplOwner1 {PO1();void f();void f()const;};
struct PO2 : private PimplOwner2 {PO2();void f();void f()const;};
struct PO3 : private PimplOwner3 {PO3();void f();void f()const;};
struct PO4 : private PimplOwner4 {PO4();void f();void f()const;};
struct PO5 : private PimplOwner5 {PO5();void f();void f()const;};



// Rimpl

typedef RimplOf<E,Pimpl1> Rimpl1;
typedef RimplOf<E,Pimpl2> Rimpl2;
typedef RimplOf<E,Pimpl3> Rimpl3;
typedef RimplOf<E,Pimpl4> Rimpl4;
typedef RimplOf<E,Pimpl5> Rimpl5;

struct R1 {Pimpl1 p; Rimpl1::Type d; R1();void f();void f()const;};
struct R2 {Pimpl2 p; Rimpl2::Type d; R2();void f();void f()const;};
struct R3 {Pimpl3 p; Rimpl3::Type d; R3();void f();void f()const;};
struct R4 {Pimpl4 p; Rimpl4::Type d; R4();void f();void f()const;};
struct R5 {Pimpl5 p; Rimpl5::Type d; R5();void f();void f()const;};


// RimplOwner

typedef RimplOf<E,Pimpl1>::Owner RimplO1;
typedef RimplOf<E,Pimpl2>::Owner RimplO2;
typedef RimplOf<E,Pimpl3>::Owner RimplO3;
typedef RimplOf<E,Pimpl4>::Owner RimplO4;
typedef RimplOf<E,Pimpl5>::Owner RimplO5;

struct RO1 : private RimplO1 {RO1();void f();void f()const;};
struct RO2 : private RimplO2 {RO2();void f();void f()const;};
struct RO3 : private RimplO3 {RO3();void f();void f()const;};
struct RO4 : private RimplO4 {RO4();void f();void f()const;};
struct RO5 : private RimplO5 {RO5();void f();void f()const;};