typeHelper.cpp
Go to the documentation of this file.
1 /* *****************************************************************************
2 
3  trimAl v2.0: a tool for automated alignment trimming in large-scale
4  phylogenetics analyses.
5 
6  readAl v2.0: a tool for automated alignment conversion among different
7  formats.
8 
9  2009-2019
10  Fernandez-Rodriguez V. (victor.fernandez@bsc.es)
11  Capella-Gutierrez S. (salvador.capella@bsc.es)
12  Gabaldon, T. (tgabaldon@crg.es)
13 
14  This file is part of trimAl/readAl.
15 
16  trimAl/readAl are free software: you can redistribute it and/or modify
17  it under the terms of the GNU General Public License as published by
18  the Free Software Foundation, the last available version.
19 
20  trimAl/readAl are distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  GNU General Public License for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with trimAl/readAl. If not, see <http://www.gnu.org/licenses/>.
27 
28 ***************************************************************************** */
29 
30 #include <iostream>
31 #include <limits>
32 #include <cxxabi.h>
33 #include <iomanip>
34 #include <typeinfo>
35 
36 template<typename T>
37 std::string type_name()
38 {
39  int status;
40  std::string tname = typeid(T).name();
41  char *demangled_name = abi::__cxa_demangle(tname.c_str(), NULL, NULL, &status);
42  if(status == 0) {
43  tname = demangled_name;
44  std::free(demangled_name);
45  }
46  return tname;
47 }
48 
49 template <typename T>
51 {
52  std::cout << std::setw(15) << std::right << type_name<T>()
53  << std::setw(5) << std::right << sizeof(T)
54  << std::setw(25) << std::right << static_cast<unsigned long>(std::numeric_limits<T>::max())
55  << std::setw(30) << std::right << static_cast<long>(std::numeric_limits<T>::min())
56 
57  << "\n";
58 }
59 
60 typedef int internalType;
61 
62 int main()
63 {
68 
69  printSizeOfTypes<unsigned char>();
70  printSizeOfTypes<unsigned short>();
71  printSizeOfTypes<unsigned int>();
72  printSizeOfTypes<unsigned long>();
73 
74 }
int internalType
Definition: typeHelper.cpp:60
int main()
Definition: typeHelper.cpp:62
void printSizeOfTypes()
Definition: typeHelper.cpp:50
std::string type_name()
Definition: typeHelper.cpp:37