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
f211151d
Commit
f211151d
authored
14 years ago
by
Jorrit Fahlke
Browse files
Options
Downloads
Patches
Plain Diff
[PointerPairDeletor] Make it work with native tuples (C++0x).
[[Imported from SVN: r6073]]
parent
7cd3daef
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
dune/common/utility.hh
+20
-49
20 additions, 49 deletions
dune/common/utility.hh
with
20 additions
and
49 deletions
dune/common/utility.hh
+
20
−
49
View file @
f211151d
...
...
@@ -167,55 +167,6 @@ namespace Dune {
};
#endif // !defined(DOXYGEN)
/**
* @brief Deletes all objects pointed to in a tuple of pointers.
*
* \warning Pointers cannot be set to NULL, so calling the Deletor twice
* or accessing elements of a deleted tuple leads to unforeseeable results!
*/
template
<
class
Tuple
>
struct
PointerPairDeletor
{};
namespace
{
template
<
class
T
,
int
s
>
struct
PointerDeletor
{};
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
,
typename
T6
,
typename
T7
,
typename
T8
,
typename
T9
,
int
s
>
struct
PointerDeletor
<
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>
,
s
>
{
static
void
apply
(
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>&
t
)
{
PointerDeletor
<
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>
,
s
-
1
>::
apply
(
t
);
delete
get
<
s
-
1
>
(
t
);
}
};
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
,
typename
T6
,
typename
T7
,
typename
T8
,
typename
T9
>
struct
PointerDeletor
<
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>
,
0
>
{
static
void
apply
(
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>&
t
)
{}
};
}
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
,
typename
T6
,
typename
T7
,
typename
T8
,
typename
T9
>
struct
PointerPairDeletor
<
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>
>
{
static
void
apply
(
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>&
t
)
{
PointerDeletor
<
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>
,
tuple_size
<
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>
>::
value
>
::
apply
(
t
);
}
};
/**
* @brief Helper template to calculate length of a tuple.
*/
...
...
@@ -509,6 +460,26 @@ namespace Dune {
}
};
/**
* @brief Deletes all objects pointed to in a tuple of pointers.
*
* \warning Pointers cannot be set to NULL, so calling the Deletor twice
* or accessing elements of a deleted tuple leads to unforeseeable results!
*/
template
<
class
Tuple
>
class
PointerPairDeletor
{
struct
Deletor
{
template
<
typename
P
>
void
visit
(
const
P
&
p
)
{
delete
p
;
}
};
public
:
static
void
apply
(
Tuple
&
t
)
{
static
Deletor
deletor
;
ForEachValue
<
Tuple
>
(
t
).
apply
(
deletor
);
}
};
}
#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