Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Koch
dune-common
Commits
33952cac
Commit
33952cac
authored
20 years ago
by
Robert Klöfkorn
Browse files
Options
Downloads
Patches
Plain Diff
comment / wrong.
[[Imported from SVN: r1384]]
parent
25bbaadf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
grid/bsgrid/myautoptr.hh
+38
-39
38 additions, 39 deletions
grid/bsgrid/myautoptr.hh
with
38 additions
and
39 deletions
grid/bsgrid/myautoptr.hh
+
38
−
39
View file @
33952cac
...
...
@@ -3,20 +3,20 @@
#ifndef __DUNE_BSGRID_MYAUTOPTR_HH__
#define __DUNE_BSGRID_MYAUTOPTR_HH__
/**
\
brief
An
auto
pointer
class
*
\
template
<
class
Pointer
>
class
AutoPointer
{
//! Pointer to Object
Pointer
*
ptr_
;
/** \brief An auto pointer class *
/
template
<
class
Pointer
>
class
AutoPointer
{
//! Pointer to Object
Pointer
*
ptr_
;
//! number of copies that exist from this Object
mutable
int
*
refCount_
;
//! number of copies that exist from this Object
mutable
int
*
refCount_
;
public:
//! if a copy is made, the refcount is increased
inline
AutoPointer
(
const
AutoPointer
<
Pointer
>
&
copy
)
{
public:
//! if a copy is made, the refcount is increased
inline
AutoPointer
(
const
AutoPointer
<
Pointer
>
&
copy
)
{
ptr_
=
0
;
refCount_
=
0
;
if
(
copy
.
ptr_
)
...
...
@@ -25,14 +25,14 @@
refCount_
=
copy
.
refCount_
;
(
*
refCount_
)
++
;
}
}
}
//! initialize the member variables
AutoPointer
()
:
ptr_
(
0
)
,
refCount_
(
0
)
{}
//! initialize the member variables
AutoPointer
()
:
ptr_
(
0
)
,
refCount_
(
0
)
{}
// store object pointer and create refCount
void
store
(
Pointer
*
ptr
)
{
// store object pointer and create refCount
void
store
(
Pointer
*
ptr
)
{
assert
(
ptr_
==
0
);
ptr_
=
ptr
;
if
(
ptr_
)
...
...
@@ -41,11 +41,11 @@
refCount_
=
tmp
;
(
*
refCount_
)
=
1
;
}
}
}
//! set Stack free, if no more refences exist
~
AutoPointer
()
{
//! set Stack free, if no more refences exist
~
AutoPointer
()
{
if
(
refCount_
&&
ptr_
)
{
(
*
refCount_
)
--
;
...
...
@@ -55,32 +55,31 @@
if
(
refCount_
)
delete
refCount_
;
}
}
}
}
//! return object reference
Pointer
&
operator
*
()
const
{
//! return object reference
Pointer
&
operator
*
()
const
{
assert
(
ptr_
!=
0
);
return
*
ptr_
;
}
}
//! return object pointer
Pointer
*
operator
->
()
const
{
//! return object pointer
Pointer
*
operator
->
()
const
{
assert
(
ptr_
!=
0
);
return
ptr_
;
}
}
private
:
//! if copy is made than one more Reference exists
AutoPointer
<
Pointer
>
&
operator
=
(
const
AutoPointer
<
Pointer
>
&
copy
)
{
private
:
//! if copy is made than one more Reference exists
AutoPointer
<
Pointer
>
&
operator
=
(
const
AutoPointer
<
Pointer
>
&
copy
)
{
assert
(
false
);
return
(
*
this
);
}
};
}
};
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment