Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
asherikov committed Jun 22, 2024
1 parent 8a7b1ba commit 1a86812
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
8 changes: 4 additions & 4 deletions extra_adapters/eigen/eigen.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace ariles2
ARILES2_TRACE_FUNCTION;
const std::size_t size = visitor.startVector();

if (Eigen::Dynamic == t_rows)
if constexpr (Eigen::Dynamic == t_rows)
{
entry.resize(size);
}
Expand Down Expand Up @@ -252,9 +252,9 @@ namespace ariles2
const typename t_Visitor::Parameters &param)
{
ARILES2_TRACE_FUNCTION;
if (Eigen::Dynamic == t_rows)
if constexpr (Eigen::Dynamic == t_rows)
{
if (Eigen::Dynamic == t_cols)
if constexpr (Eigen::Dynamic == t_cols)
{
entry.resize(0, 0);
}
Expand All @@ -265,7 +265,7 @@ namespace ariles2
}
else
{
if (Eigen::Dynamic == t_cols)
if constexpr (Eigen::Dynamic == t_cols)
{
entry.resize(t_rows, 0);
}
Expand Down
3 changes: 1 addition & 2 deletions include/ariles2/adapters/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ namespace ariles2
apply_write(t_Visitor &writer, const t_Enumeration entry, const typename t_Visitor::Parameters &param)
{
ARILES2_TRACE_FUNCTION;
const int tmp_value = entry;
writer.writeElement(tmp_value, param);
writer.writeElement(static_cast<int>(entry), param);
}


Expand Down
40 changes: 16 additions & 24 deletions include/ariles2/visitors/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ namespace ariles2
template <typename t_Scalar>
inline t_Scalar getDefault() const
{
if constexpr (std::is_same_v<double, t_Scalar>)
{
return default_double_value_;
}
if constexpr (std::is_same_v<float, t_Scalar>)
{
return default_float_value_;
}
if constexpr (std::is_same_v<bool, t_Scalar>)
{
return false;
}
if constexpr (std::is_same_v<std::string, t_Scalar>)
{
return "";
}
return 0;
}
};
Expand Down Expand Up @@ -86,30 +102,6 @@ namespace ariles2
}
};

template <>
inline double Visitor::Parameters::getDefault<double>() const
{
return default_double_value_;
}

template <>
inline float Visitor::Parameters::getDefault<float>() const
{
return default_float_value_;
}

template <>
inline bool Visitor::Parameters::getDefault<bool>() const
{
return false;
}

template <>
inline std::string Visitor::Parameters::getDefault<std::string>() const
{
return "";
}


class ARILES2_VISIBILITY_ATTRIBUTE Base : public entry::Base<const defaults::Visitor>
{
Expand Down

0 comments on commit 1a86812

Please sign in to comment.