Autoware.Auto
type_name.hpp
Go to the documentation of this file.
1 // Copyright 2021 Apex.AI, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // Co-developed by Tier IV, Inc. and Apex.AI, Inc.
16 
17 #ifndef HELPER_FUNCTIONS__TYPE_NAME_HPP_
18 #define HELPER_FUNCTIONS__TYPE_NAME_HPP_
19 
20 #include <common/visibility_control.hpp>
21 
22 #include <string>
23 #include <typeinfo>
24 
25 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
26 #include <cxxabi.h>
27 #endif
28 
29 namespace autoware
30 {
31 namespace helper_functions
32 {
33 
35 template<typename T>
36 COMMON_PUBLIC std::string get_type_name()
37 {
38  #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
39  return abi::__cxa_demangle(typeid(T).name(), NULL, NULL, 0);
40  #else
41  // For unsupported compilers return a mangled name.
42  return typeid(T).name();
43  #endif
44 }
45 
47 template<typename T>
48 COMMON_PUBLIC std::string get_type_name(const T &)
49 {
50  return get_type_name<T>();
51 }
52 
53 } // namespace helper_functions
54 } // namespace autoware
55 
56 #endif // HELPER_FUNCTIONS__TYPE_NAME_HPP_
autoware::helper_functions::get_type_name
COMMON_PUBLIC std::string get_type_name()
Get a demangled name of a type.
Definition: type_name.hpp:36
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
setup.name
name
Definition: setup.py:6