WPILibC++ 2024.3.2
Demangle.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#ifndef WPIUTIL_WPI_DEMANGLE_H_
6#define WPIUTIL_WPI_DEMANGLE_H_
7
8#include <string>
9#include <string_view>
10#include <typeinfo>
11
12namespace wpi {
13
14/**
15 * Demangle a C++ symbol.
16 *
17 * @param mangledSymbol the mangled symbol.
18 * @return The demangled symbol, or mangledSymbol if demangling fails.
19 */
20std::string Demangle(std::string_view mangledSymbol);
21
22/**
23 * Returns the type name of an object
24 * @param type The object
25 */
26template <typename T>
27std::string GetTypeName(const T& type) {
28 return Demangle(typeid(type).name());
29}
30
31} // namespace wpi
32
33#endif // WPIUTIL_WPI_DEMANGLE_H_
basic_string_view< char > string_view
Definition: core.h:501
type
Definition: core.h:556
Definition: ntcore_cpp.h:26
std::string Demangle(std::string_view mangledSymbol)
Demangle a C++ symbol.
std::string GetTypeName(const T &type)
Returns the type name of an object.
Definition: Demangle.h:27