Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
amdis
amdis-core
Commits
56ddc859
Commit
56ddc859
authored
5 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
add fake container-like datastructure with all no-op
parent
e01dcaf2
Branches
Branches containing commit
No related tags found
1 merge request
!52
add fake container-like datastructure with all no-op
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/amdis/common/CMakeLists.txt
+1
-0
1 addition, 0 deletions
src/amdis/common/CMakeLists.txt
src/amdis/common/FakeContainer.hpp
+72
-0
72 additions, 0 deletions
src/amdis/common/FakeContainer.hpp
with
73 additions
and
0 deletions
src/amdis/common/CMakeLists.txt
+
1
−
0
View file @
56ddc859
...
...
@@ -10,6 +10,7 @@ install(FILES
Concepts.hpp
ConceptsBase.hpp
ConcurrentCache.hpp
FakeContainer.hpp
FieldMatVec.hpp
FieldMatVec.inc.hpp
Filesystem.hpp
...
...
This diff is collapsed.
Click to expand it.
src/amdis/common/FakeContainer.hpp
0 → 100644
+
72
−
0
View file @
56ddc859
#pragma once
#include
<cstddef>
namespace
AMDiS
{
struct
FakeAssigner
{
template
<
class
T
>
FakeAssigner
&
operator
=
(
T
&&
)
{
return
*
this
;
}
template
<
class
T
>
FakeAssigner
&
operator
+=
(
T
&&
)
{
return
*
this
;
}
template
<
class
T
>
FakeAssigner
&
operator
-=
(
T
&&
)
{
return
*
this
;
}
template
<
class
T
>
FakeAssigner
&
operator
*=
(
T
&&
)
{
return
*
this
;
}
template
<
class
T
>
FakeAssigner
&
operator
/=
(
T
&&
)
{
return
*
this
;
}
};
/// A container-like data-structure not storing anything and with empty
/// implementations in many container-interface functions.
/**
* This container that *does nothing* can be used as a dummy argument to
* functions expecting a container, in order to ommit specializations of
* these functions for not providing a container.
**/
class
FakeContainer
:
public
FakeAssigner
{
public:
using
size_type
=
std
::
size_t
;
template
<
class
...
Args
>
FakeContainer
(
Args
&&
...)
{}
template
<
class
Arg
>
void
push_back
(
Arg
&&
)
{}
template
<
class
...
Args
>
void
emplace_back
(
Args
&&
...)
{}
void
reserve
(
size_type
)
{}
void
resize
(
size_type
)
{}
/// This container is always empty
bool
empty
()
const
{
return
true
;
}
size_type
size
()
const
{
return
0u
;
}
/// Mutable *element* access does return the container itself
/// This allows to emulate nested containers
FakeContainer
&
operator
[](
size_type
)
{
return
*
this
;
}
/// Assignment operators from a fake assigner
using
FakeAssigner
::
operator
=
;
using
FakeAssigner
::
operator
+=
;
using
FakeAssigner
::
operator
-=
;
using
FakeAssigner
::
operator
*=
;
using
FakeAssigner
::
operator
/=
;
FakeAssigner
front
()
{
return
{};
}
FakeAssigner
back
()
{
return
{};
}
friend
inline
FakeAssigner
front
(
FakeContainer
&
)
{
return
{};
}
friend
inline
FakeAssigner
back
(
FakeContainer
&
)
{
return
{};
}
};
}
// end namespace AMDiS
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