Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-matrix-vector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
agnumpde
dune-matrix-vector
Commits
02ffbc31
Commit
02ffbc31
authored
7 years ago
by
Max Kahnt
Browse files
Options
Downloads
Patches
Plain Diff
Add trait utilities.
parent
407ab86d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/matrix-vector/traitutilities.hh
+79
-0
79 additions, 0 deletions
dune/matrix-vector/traitutilities.hh
with
79 additions
and
0 deletions
dune/matrix-vector/traitutilities.hh
0 → 100644
+
79
−
0
View file @
02ffbc31
#ifndef DUNE_MATRIX_VECTOR_TRAITUTILITIES_HH
#define DUNE_MATRIX_VECTOR_TRAITUTILITIES_HH
#include
<type_traits>
#include
<dune/common/std/type_traits.hh>
#include
<dune/common/typetraits.hh>
#include
<dune/matrix-vector/concepts.hh>
#include
<dune/matrix-vector/scalartraits.hh>
#include
<dune/matrix-vector/matrixtraits.hh>
#include
<dune/matrix-vector/vectortraits.hh>
namespace
Dune
{
namespace
MatrixVector
{
// convenience compile-time functions to classify types
template
<
class
T
>
constexpr
auto
isNumber
()
{
return
Std
::
bool_constant
<
IsNumber
<
T
>::
value
>
();
}
template
<
class
T
>
constexpr
auto
isScalar
()
{
return
Std
::
bool_constant
<
ScalarTraits
<
T
>::
isScalar
>
();
}
template
<
class
T
>
constexpr
auto
isVector
()
{
return
Std
::
bool_constant
<
VectorTraits
<
T
>::
isVector
>
();
}
template
<
class
T
>
constexpr
auto
isMatrix
()
{
return
Std
::
bool_constant
<
MatrixTraits
<
T
>::
isMatrix
>
();
}
template
<
class
T
>
constexpr
auto
isTupleOrDerived
()
{
return
Std
::
bool_constant
<
IsTupleOrDerived
<
std
::
decay_t
<
T
>>::
value
>
();
}
// enable_if typedefs for traits ...
template
<
class
T
>
using
EnableNumber
=
std
::
enable_if_t
<
isNumber
<
T
>
()
>
;
template
<
class
T
>
using
EnableScalar
=
std
::
enable_if_t
<
isScalar
<
T
>
()
>
;
template
<
class
T
>
using
EnableVector
=
std
::
enable_if_t
<
isVector
<
T
>
()
>
;
template
<
class
T
>
using
EnableMatrix
=
std
::
enable_if_t
<
isMatrix
<
T
>
()
>
;
// ... and their negations
template
<
class
T
>
using
DisableNumber
=
std
::
enable_if_t
<
not
isNumber
<
T
>
()
>
;
template
<
class
T
>
using
DisableScalar
=
std
::
enable_if_t
<
not
isScalar
<
T
>
()
>
;
template
<
class
T
>
using
DisableVector
=
std
::
enable_if_t
<
not
isVector
<
T
>
()
>
;
template
<
class
T
>
using
DisableMatrix
=
std
::
enable_if_t
<
not
isMatrix
<
T
>
()
>
;
// compile-time property checks
template
<
class
T
>
constexpr
auto
isSparseRangeIterable
()
{
return
Std
::
bool_constant
<
isTupleOrDerived
<
T
>
()
or
models
<
Concept
::
HasBegin
,
T
>
()
>
();
}
}
// end namespace MatrixVector
}
// end namespace Dune
#endif // DUNE_MATRIX_VECTOR_TRAITUTILITIES_HH
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