Default.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SpaceVecAlg/SpaceVecAlg>
4 
5 #include <string>
6 #include <type_traits>
7 #include <variant>
8 
9 namespace mc_rtc
10 {
11 
18 template<typename T, typename Enable = void>
19 struct Default
20 {
21  static_assert(!std::is_same_v<T, T>, "Must be specialized");
22 };
23 
24 template<typename T>
25 struct Default<T, std::enable_if_t<std::is_arithmetic_v<T>>>
26 {
27  inline static constexpr T value = 0;
28 };
29 
30 template<typename Scalar, int N, int Options, int MaxRows, int MaxCols>
31 struct Default<Eigen::Matrix<Scalar, N, 1, Options, MaxRows, MaxCols>, std::enable_if_t<(N > 0)>>
32 {
33  inline static const Eigen::Matrix<Scalar, N, 1, Options, MaxRows, MaxCols> value =
34  Eigen::Matrix<Scalar, N, 1, Options, MaxRows, MaxCols>::Zero();
35 };
36 
37 template<typename Scalar, int N, int Options, int MaxRows, int MaxCols>
38 struct Default<Eigen::Matrix<Scalar, N, N, Options, MaxRows, MaxCols>, std::enable_if_t<(N > 1)>>
39 {
40  inline static const Eigen::Matrix<Scalar, N, N, Options, MaxRows, MaxCols> value =
41  Eigen::Matrix<Scalar, N, N, Options, MaxRows, MaxCols>::Identity();
42 };
43 
44 template<>
45 struct Default<sva::PTransformd>
46 {
47  inline static const sva::PTransformd value = sva::PTransformd::Identity();
48 };
49 
50 template<>
51 struct Default<sva::MotionVecd>
52 {
53  inline static const sva::MotionVecd value = sva::MotionVecd::Zero();
54 };
55 
56 template<>
57 struct Default<sva::ForceVecd>
58 {
59  inline static const sva::ForceVecd value = sva::ForceVecd::Zero();
60 };
61 
62 template<>
63 struct Default<sva::ImpedanceVecd>
64 {
65  inline static const sva::ImpedanceVecd value = sva::ImpedanceVecd::Zero();
66 };
67 
68 template<>
69 struct Default<sva::AdmittanceVecd>
70 {
71  inline static const sva::AdmittanceVecd value = sva::AdmittanceVecd::Zero();
72 };
73 
74 template<>
75 struct Default<std::string>
76 {
77  inline static const std::string value;
78 };
79 
80 template<typename T, typename... Others>
81 struct Default<std::variant<T, Others...>> : public Default<T>
82 {
83 };
84 
85 } // namespace mc_rtc
mc_rtc::Default
Definition: Default.h:19
mc_rtc::Default< std::string >::value
static const std::string value
Definition: Default.h:77
std
Definition: Contact.h:66
mc_rtc
Definition: Contact.h:87