\doxysection{name\+\_\+demangling.\+hpp}
\hypertarget{name__demangling_8hpp_source}{}\label{name__demangling_8hpp_source}\index{ginkgo/core/base/name\_demangling.hpp@{ginkgo/core/base/name\_demangling.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{//\ SPDX-\/FileCopyrightText:\ 2017\ -\/\ 2024\ The\ Ginkgo\ authors}}
\DoxyCodeLine{00002\ \textcolor{comment}{//}}
\DoxyCodeLine{00003\ \textcolor{comment}{//\ SPDX-\/License-\/Identifier:\ BSD-\/3-\/Clause}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#ifndef\ GKO\_PUBLIC\_CORE\_BASE\_NAME\_DEMANGLING\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_BASE\_NAME\_DEMANGLING\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <ginkgo/config.hpp>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#ifdef\ GKO\_HAVE\_CXXABI\_H}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#include\ <cxxabi.h>}}
\DoxyCodeLine{00014\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_HAVE\_CXXABI\_H}}
\DoxyCodeLine{00015\ }
\DoxyCodeLine{00016\ }
\DoxyCodeLine{00017\ \textcolor{preprocessor}{\#include\ <memory>}}
\DoxyCodeLine{00018\ \textcolor{preprocessor}{\#include\ <string>}}
\DoxyCodeLine{00019\ }
\DoxyCodeLine{00020\ }
\DoxyCodeLine{00021\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00022\ }
\DoxyCodeLine{00028\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko_1_1name__demangling}{name\_demangling}}\ \{}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00031\ \textcolor{keyword}{inline}\ std::string\ get\_type\_name(\textcolor{keyword}{const}\ std::type\_info\&\ tinfo)}
\DoxyCodeLine{00032\ \{}
\DoxyCodeLine{00033\ \textcolor{preprocessor}{\#ifdef\ GKO\_HAVE\_CXXABI\_H}}
\DoxyCodeLine{00034\ \ \ \ \ \textcolor{keywordtype}{int}\ status\{\};}
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keyword}{const}\ std::string\ name(}
\DoxyCodeLine{00036\ \ \ \ \ \ \ \ \ std::unique\_ptr<\textcolor{keywordtype}{char}[],\ \textcolor{keywordtype}{void}\ (*)(\textcolor{keywordtype}{void}*)>(}
\DoxyCodeLine{00037\ \ \ \ \ \ \ \ \ \ \ \ \ abi::\_\_cxa\_demangle(tinfo.name(),\ \textcolor{keyword}{nullptr},\ \textcolor{keyword}{nullptr},\ \&status),}
\DoxyCodeLine{00038\ \ \ \ \ \ \ \ \ \ \ \ \ std::free)}
\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ \ \ \ \ .get());}
\DoxyCodeLine{00040\ \ \ \ \ \textcolor{keywordflow}{if}\ (!status)}
\DoxyCodeLine{00041\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ name;}
\DoxyCodeLine{00042\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00043\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_HAVE\_CXXABI\_H}}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ std::string(tinfo.name());}
\DoxyCodeLine{00045\ \}}
\DoxyCodeLine{00046\ }
\DoxyCodeLine{00047\ }
\DoxyCodeLine{00056\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00057\ std::string\ \doxymbox{\hyperlink{namespacegko_1_1name__demangling_a305c6bc422a3babdd1179db5b2859ae3}{get\_static\_type}}(\textcolor{keyword}{const}\ T\&)}
\DoxyCodeLine{00058\ \{}
\DoxyCodeLine{00059\ \ \ \ \ \textcolor{keywordflow}{return}\ get\_type\_name(\textcolor{keyword}{typeid}(T));}
\DoxyCodeLine{00060\ \}}
\DoxyCodeLine{00061\ }
\DoxyCodeLine{00062\ }
\DoxyCodeLine{00071\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00072\ std::string\ \doxymbox{\hyperlink{namespacegko_1_1name__demangling_a7469320f9401df05fcad48027569cef0}{get\_dynamic\_type}}(\textcolor{keyword}{const}\ T\&\ t)}
\DoxyCodeLine{00073\ \{}
\DoxyCodeLine{00074\ \ \ \ \ \textcolor{keywordflow}{return}\ get\_type\_name(\textcolor{keyword}{typeid}(t));}
\DoxyCodeLine{00075\ \}}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00077\ }
\DoxyCodeLine{00078\ \textcolor{keyword}{namespace\ }detail\ \{}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ }
\DoxyCodeLine{00081\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00082\ std::string\ get\_enclosing\_scope(\textcolor{keyword}{const}\ T\&)}
\DoxyCodeLine{00083\ \{}
\DoxyCodeLine{00084\ \ \ \ \ \textcolor{keyword}{auto}\ name\ =\ get\_type\_name(\textcolor{keyword}{typeid}(T));}
\DoxyCodeLine{00085\ \ \ \ \ \textcolor{keyword}{auto}\ found\ =\ name.rfind(\textcolor{charliteral}{':'});}
\DoxyCodeLine{00086\ \ \ \ \ \textcolor{keywordflow}{if}\ (found\ ==\ std::string::npos)\ \{}
\DoxyCodeLine{00087\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ name;}
\DoxyCodeLine{00088\ \ \ \ \ \}}
\DoxyCodeLine{00089\ \ \ \ \ \textcolor{keywordflow}{return}\ name.substr(0,\ found\ -\/\ 1);}
\DoxyCodeLine{00090\ \}}
\DoxyCodeLine{00091\ }
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \}\ \ \textcolor{comment}{//\ namespace\ detail}}
\DoxyCodeLine{00094\ }
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00109\ \textcolor{preprocessor}{\#define\ GKO\_FUNCTION\_NAME\ gko::name\_demangling::get\_enclosing\_scope([]\ \{\})}}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00111\ }
\DoxyCodeLine{00112\ \}\ \ \textcolor{comment}{//\ namespace\ name\_demangling}}
\DoxyCodeLine{00113\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{00114\ }
\DoxyCodeLine{00115\ }
\DoxyCodeLine{00116\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_BASE\_NAME\_DEMANGLING\_HPP\_}}

\end{DoxyCode}
