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 #ifndef HELPER_FUNCTIONS__TYPE_NAME_HPP_
16 #define HELPER_FUNCTIONS__TYPE_NAME_HPP_
17 
18 #include <common/visibility_control.hpp>
19 
20 #include <string>
21 #include <typeinfo>
22 
23 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
24 #include <cxxabi.h>
25 #endif
26 
27 namespace autoware
28 {
29 namespace helper_functions
30 {
31 
33 template<typename T>
34 COMMON_PUBLIC std::string get_type_name()
35 {
36  #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
37  return abi::__cxa_demangle(typeid(T).name(), NULL, NULL, 0);
38  #else
39  // For unsupported compilers return a mangled name.
40  return typeid(T).name();
41  #endif
42 }
43 
45 template<typename T>
46 COMMON_PUBLIC std::string get_type_name(const T &)
47 {
48  return get_type_name<T>();
49 }
50 
51 } // namespace helper_functions
52 } // namespace autoware
53 
54 #endif // HELPER_FUNCTIONS__TYPE_NAME_HPP_
catr_diff.T
T
Definition: catr_diff.py:22
autoware::helper_functions::get_type_name
COMMON_PUBLIC std::string get_type_name()
Get a demangled name of a type.
Definition: type_name.hpp:34
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24