dune-vtk 2.12
Loading...
Searching...
No Matches
rangetype.hh
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <type_traits>
5
6
7namespace Dune {
8
9// forward declarations
10template <class T, int N>
11class FieldVector;
12
13template <class T, int N, int M>
14class FieldMatrix;
15
16} // end namespace Dune
17
18namespace Dune::Vtk {
19
21template <class F, class D>
23
24namespace Impl {
25
26 template <class T, int N>
27 constexpr auto dimRangeImpl (Dune::FieldVector<T,N>)
28 -> std::integral_constant<int, N> { return {}; }
29
30 template <class T, int N, int M>
31 constexpr auto dimRangeImpl (Dune::FieldMatrix<T,N,M>)
32 -> std::integral_constant<int, N*M> { return {}; }
33
34 constexpr auto dimRangeImpl (...)
35 -> std::integral_constant<int, 1> { return {}; }
36
37} // end namespace Impl
38
40template <class T>
41static constexpr int dimRange ()
42{
43 return decltype(Impl::dimRangeImpl(std::declval<T>()))::value;
44}
45
46namespace Impl {
47
48 template <class T, int N, int M>
49 constexpr std::array<int,2> rangeShapeImpl (Dune::FieldMatrix<T,N,M> const*) { return {N,M}; }
50
51 constexpr std::array<int,2> rangeShapeImpl (...) { return {0,0}; }
52
53} // end namespace Impl
54
56template <class T>
58{
59 return Impl::rangeShapeImpl(static_cast<T const*>(nullptr));
60}
61
62} // end namespace Dune::Vtk
Definition writer.hh:16
constexpr std::array< int, 2 > rangeShape()
Static shape {rows,cols} of a matrix-valued range type, or {0,0} if unknown or not a matrix.
Definition rangetype.hh:57
static constexpr int dimRange()
Number of components the range contains.
Definition rangetype.hh:41
static constexpr size_type M()
static constexpr size_type N()