algorithms
2.2.0
Framework-independent algorithms for the EIC
Toggle main menu visibility
Loading...
Searching...
No Matches
demangle.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-3.0-or-later
2
// Copyright (C) 2022 Wouter Deconinck, Sylvester Joosten
3
//
4
// Get a demangled type name string
5
#pragma once
6
7
#include <cstdlib>
8
#include <cxxabi.h>
9
#include <fmt/format.h>
10
#include <memory>
11
#include <string>
12
13
#include <
algorithms/error.h
>
14
15
namespace
algorithms::detail
{
16
17
template
<
class
T> std::string
demangledName
() {
18
const
char
* mangled =
typeid
(T).name();
19
int
status = 1;
// ABI spec sets status to 0 on success, so we need a different
20
// starting value
21
std::unique_ptr<char, void (*)(
void
*)> res{abi::__cxa_demangle(mangled, NULL, NULL, &status),
22
std::free};
23
if
(status != 0) {
24
throw
algorithms::Error
(fmt::format(
"Failed to demangle type name: {}"
, mangled),
25
"algorithms::detail::demangledName()"
);
26
}
27
28
return
res.get();
29
}
30
31
}
// namespace algorithms::detail
algorithms::Error
Definition
error.h:13
error.h
algorithms::detail
Definition
algorithm.h:183
algorithms::detail::demangledName
std::string demangledName()
Definition
demangle.h:17
core
include
algorithms
detail
demangle.h
Generated by
1.17.0