Build fix: specialization of template in different namespace
[lttng-tools.git] / src / common / format.hpp
CommitLineData
05aa7e19
JG
1/*
2 * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7#ifndef LTTNG_FORMAT_H
8#define LTTNG_FORMAT_H
9
10#include <common/macros.hpp>
11
5bb4ff54
JG
12#include <string>
13#include <cxxabi.h>
14
05aa7e19
JG
15DIAGNOSTIC_PUSH
16DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT
17DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES
18#define FMT_HEADER_ONLY
19#include <vendor/fmt/core.h>
20DIAGNOSTIC_POP
21
e2c2bec2 22namespace fmt {
5bb4ff54 23template <>
e2c2bec2 24struct formatter<std::type_info> : formatter<std::string> {
5bb4ff54
JG
25 template <typename FormatCtx>
26 typename FormatCtx::iterator format(const std::type_info& type_info, FormatCtx& ctx)
27 {
28 int status;
29 auto demangled_name = abi::__cxa_demangle(type_info.name(), nullptr, 0, &status);
e2c2bec2
JR
30 auto it = status == 0 ? formatter<std::string>::format(demangled_name, ctx) :
31 formatter<std::string>::format(type_info.name(), ctx);
5bb4ff54
JG
32
33 free(demangled_name);
34 return it;
35 }
36};
e2c2bec2 37} /* namespace fmt */
5bb4ff54 38
05aa7e19 39#endif /* LTTNG_FORMAT_H */
This page took 0.023683 seconds and 4 git commands to generate.