DUNE-ACFEM (unstable)

tostring.hh
1#ifndef __DUNE_ACFEM_MPL_TOSTRING_HH__
2#define __DUNE_ACFEM_MPL_TOSTRING_HH__
3
4#include <string>
5#include "generators.hh"
6
7namespace Dune {
8
9 namespace ACFem {
10
27 template<class T, T I0>
28 auto toString(Sequence<T, I0>)
29 {
30 return std::to_string(I0);
31 }
32
36 template<class T, T I0, T I1, T... Rest>
38 {
39 return std::to_string(I0) + "," + toString(Sequence<T, I1, Rest...>{});
40 }
41
43 template<class T>
44 auto toString(Sequence<T>)
45 {
46 return std::string();
47 }
48
49 namespace {
50 template<class T, std::size_t I0>
51 std::string toStringHelper(const T& t, IndexSequence<I0>)
52 {
53 return std::to_string(std::get<I0>(t));
54 }
55
56 template<class T, std::size_t I0, std::size_t I1, std::size_t... Rest>
57 auto toStringHelper(const T& t, IndexSequence<I0, I1, Rest...>)
58 {
59 return std::to_string(std::get<I0>(t)) + "," + toStringHelper(t, IndexSequence<I1, Rest...>{});
60 }
61 }
62
63 template<class T, std::enable_if_t<IsTupleLike<T>{}, int> = 0>
64 auto toString(const T& t)
65 {
66 return toStringHelper(t, MakeSequenceFor<T>{});
67 }
68
69 template<class T, T V, std::enable_if_t<!std::is_same<T, bool>{}, int> = 0>
70 auto toString(Constant<T, V>)
71 {
72 return std::to_string(V)+"_c";
73 }
74
75 template<bool V>
76 std::string toString(BoolConstant<V>)
77 {
78 return V ? "true" : "false";
79 }
80
82
84
85 } // ACFem::
86
87} // Dune::
88
89#endif // __DUNE_ACFEM_MPL_TOSTRING_HH__
std::integer_sequence< T, V... > Sequence
Sequence of any type of integer values.
Definition: types.hh:56
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Jun 19, 23:17, 2026)