Program Listing for File human_readable.hpp
↰ Return to documentation for file (src/navtk/utils/human_readable.hpp)
#pragma once
#include <string>
#include <type_traits>
#include <typeinfo>
#include <navtk/tensors.hpp>
// To support GCC's oddball name mangling
#ifdef __GNUG__
# include <cxxabi.h>
# include <cstdlib>
#endif
namespace navtk {
namespace utils {
std::string repr(const Matrix& matrix, const std::string& decl);
std::string repr(const Matrix& matrix);
template <class E>
std::string repr(const xt::xexpression<E>& expr) {
return repr(expr, "(expr)");
}
std::string diff(const std::string& before_name,
const std::string& after_name,
const Matrix& before,
const Matrix& after,
double rtol = 1e-05,
double atol = 1e-08);
std::string diff(const Matrix& before,
const Matrix& after,
double rtol = 1e-05,
double atol = 1e-08);
template <typename T>
std::string identify_type() {
#ifdef __GNUG__
int err;
typedef std::unique_ptr<char[], decltype(&std::free)> CStrPtr;
CStrPtr buffer{__cxxabiv1::__cxa_demangle(typeid(T).name(), nullptr, 0, &err), &std::free};
std::string out{err ? "<UNKNOWN TYPE>" : buffer.get()};
#else
std::string out{typeid(T).name()};
#endif
if (std::is_rvalue_reference<T>::value)
return out + "&&";
else if (std::is_reference<T>::value)
return out + "&";
return out;
}
} // namespace utils
} // namespace navtk