SeqAn3
3.3.0
The Modern C++ library for sequence analysis.
Toggle main menu visibility
Welcome
Setup
Quick Setup (using CMake)
Tutorial
First steps with SeqAn
Parsing command line arguments with Sharg
C++ Concepts
Alphabets in SeqAn
Ranges
Minimisers
Sequence File Input and Output
Pairwise Alignment
Indexing and searching with SeqAn
SAM Input and Output in SeqAn
Implementing your own read mapper with SeqAn
How-To
Porting from SeqAn2
How to write an argument parser with subcommands
How to serialise SeqAn data structures
How to write a view
How to write your own alphabet
Cookbook
About
Stability and long-term promises
Citing
Customisation
Changelog
Copyright
Code of Conduct
Contributing
API Reference
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
type_name_as_string.hpp
Go to the documentation of this file.
1
// -----------------------------------------------------------------------------------------------------
2
// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
3
// Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
4
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6
// -----------------------------------------------------------------------------------------------------
7
13
#pragma once
14
15
#if defined(__GNUC__) || defined(__clang__)
16
# include <cxxabi.h>
17
#endif
// defined(__GNUC__) || defined(__clang__)
18
19
#include <
functional
>
20
#include <
memory
>
21
#include <
string
>
22
#include <
typeinfo
>
23
24
#include <
seqan3/core/platform.hpp
>
25
26
namespace
seqan3::detail
27
{
28
43
template
<
typename
type>
44
inline
std::string
const
type_name_as_string = []()
45
{
46
std::string
demangled_name{};
47
#if defined(__GNUC__) || defined(__clang__)
// clang and gcc only return a mangled name.
48
using
safe_ptr_t =
std::unique_ptr
<char,
std::function
<void(
char
*)>>;
49
50
// https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.3/a01696.html
51
int
status
{};
52
safe_ptr_t demangled_name_ptr{abi::__cxa_demangle(
typeid
(type).name(), 0, 0, &status),
53
[](
char
* name_ptr)
54
{
55
free
(name_ptr);
56
}};
57
58
// We exclude status != 0, because this code can't be reached normally, only if there is a defect in the compiler
59
// itself, since the type is directly given by the compiler. See https://github.com/seqan/seqan3/pull/2311.
60
// LCOV_EXCL_START
61
if
(status != 0)
62
return
std::string
{
typeid
(type).name()} +
" (abi::__cxa_demangle error status ("
+
std::to_string
(status)
63
+
"): "
64
+ (
status
== -1 ?
"A memory allocation failure occurred."
65
: (
status
== -2 ?
"mangled_name is not a valid name under the C++ ABI mangling rules."
66
: (
status
== -3 ?
"One of the arguments is invalid."
:
"Unknown Error"
)))
67
+
")"
;
68
// LCOV_EXCL_STOP
69
70
demangled_name =
std::string
{
std::addressof
(*demangled_name_ptr)};
71
#else
// e.g. MSVC
72
demangled_name =
typeid
(type).name();
73
#endif
// defined(__GNUC__) || defined(__clang__)
74
75
if
constexpr
(std::is_const_v<std::remove_reference_t<type>>)
76
demangled_name +=
" const"
;
77
if
constexpr
(std::is_lvalue_reference_v<type>)
78
demangled_name +=
" &"
;
79
if
constexpr
(std::is_rvalue_reference_v<type>)
80
demangled_name +=
" &&"
;
81
82
return
demangled_name;
83
}();
84
85
}
// namespace seqan3::detail
std::addressof
T addressof(T... args)
std::string
std::free
T free(T... args)
std::function
functional
memory
platform.hpp
Provides platform and dependency checks.
std::experimental::filesystem::status
T status(T... args)
string
std::to_string
T to_string(T... args)
typeinfo
std::unique_ptr
Version:
main_user
main_dev
3.4.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.2
3.0.1
3.0.0
seqan3
utility
detail
type_name_as_string.hpp
Generated on Thu Aug 17 2023 14:29:11 for SeqAn3 by
1.9.6