Skip to content

Instantly share code, notes, and snippets.

@SteveBronder
Created May 13, 2022 18:29
Show Gist options
  • Save SteveBronder/803227cccc66035f7b1988d0156e562a to your computer and use it in GitHub Desktop.
Save SteveBronder/803227cccc66035f7b1988d0156e562a to your computer and use it in GitHub Desktop.
#include <Eigen/Dense>
#include <string_view>
#include <iostream>
template <typename T>
constexpr std::string_view
type_name()
{
std::string_view name, prefix, suffix;
#ifdef __clang__
name = __PRETTY_FUNCTION__;
prefix = "std::string_view type_name() [T = ";
suffix = "]";
#elif defined(__GNUC__)
name = __PRETTY_FUNCTION__;
prefix = "constexpr std::string_view type_name() [with T = ";
suffix = "; std::string_view = std::basic_string_view<char>]";
#elif defined(_MSC_VER)
name = __FUNCSIG__;
prefix = "class std::basic_string_view<char,struct std::char_traits<char> > __cdecl type_name<";
suffix = ">(void)";
#endif
name.remove_prefix(prefix.size());
name.remove_suffix(suffix.size());
return name;
}
int main() {
Eigen::MatrixXd A;
Eigen::MatrixXd B;
std::cout << "Eigen type: \n\t" << type_name<decltype(A * B)>() ;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment