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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Core Modules
dune-common
Commits
f2cd5e39
Commit
f2cd5e39
authored
15 years ago
by
Martin Nolte
Browse files
Options
Downloads
Patches
Plain Diff
added test showing what polyallocator shall be able to do
[[Imported from SVN: r5956]]
parent
cd5833b9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dune/common/test/.gitignore
+1
-0
1 addition, 0 deletions
dune/common/test/.gitignore
dune/common/test/Makefile.am
+3
-0
3 additions, 0 deletions
dune/common/test/Makefile.am
dune/common/test/polyallocator.cc
+68
-0
68 additions, 0 deletions
dune/common/test/polyallocator.cc
with
72 additions
and
0 deletions
dune/common/test/.gitignore
+
1
−
0
View file @
f2cd5e39
...
...
@@ -16,6 +16,7 @@ sllisttest
tuplestest
settest
fmatrixtest
polyallocator
poolallocatortest
*.gcda
*.gcno
...
...
This diff is collapsed.
Click to expand it.
dune/common/test/Makefile.am
+
3
−
0
View file @
f2cd5e39
...
...
@@ -22,6 +22,7 @@ TESTPROGS = \
mpicollcomm
\
mpiguard
\
nullptr-test
\
polyallocator
\
poolallocatortest
\
settest
\
shared_ptrtest
\
...
...
@@ -101,6 +102,8 @@ fvectortest_SOURCES = fvectortest.cc
fmatrixtest_SOURCES
=
fmatrixtest.cc
polyallocator_SOURCES
=
polyallocator.cc
poolallocatortest_SOURCES
=
poolallocatortest.cc
settest_SOURCES
=
settest.cc
...
...
This diff is collapsed.
Click to expand it.
dune/common/test/polyallocator.cc
0 → 100644
+
68
−
0
View file @
f2cd5e39
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include
<config.h>
#include
<iostream>
#include
<dune/common/polyallocator.hh>
struct
A
{
virtual
~
A
()
{}
virtual
void
test
(
int
i
)
=
0
;
};
struct
B
:
public
A
{
B
(
int
i
)
:
k
(
i
)
{}
void
test
(
int
i
)
{
std
::
cout
<<
"B( "
<<
k
<<
" ).test( "
<<
i
<<
" )"
<<
std
::
endl
;
}
int
k
;
};
struct
C
:
public
A
{
void
test
(
int
i
)
{
std
::
cout
<<
"C.test( "
<<
i
<<
" )"
<<
std
::
endl
;
}
};
A
*
create
(
int
argc
,
char
**
argv
,
Dune
::
PolyAllocator
&
allocator
)
{
if
(
argc
>
1
)
{
B
*
b
=
allocator
.
allocate
<
B
>
();
allocator
.
construct
(
b
,
B
(
atoi
(
argv
[
1
]
)
)
);
return
b
;
}
else
{
C
*
c
=
allocator
.
allocate
<
C
>
();
allocator
.
construct
(
c
,
C
()
);
return
c
;
}
}
int
main
(
int
argc
,
char
**
argv
)
{
Dune
::
PolyAllocator
allocator
;
A
*
a
=
create
(
argc
,
argv
,
allocator
);
a
->
test
(
2
);
allocator
.
destroy
(
a
);
allocator
.
deallocate
(
a
);
return
0
;
}
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