NiHu  2.0
type_info.hpp
Go to the documentation of this file.
1 // This file is a part of NiHu, a C++ BEM template library.
2 //
3 // Copyright (C) 2012-2014 Peter Fiala <fiala@hit.bme.hu>
4 // Copyright (C) 2012-2014 Peter Rucz <rucz@hit.bme.hu>
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
25 #ifndef TYPE_INFO_HPP_INCLUDED
26 #define TYPE_INFO_HPP_INCLUDED
27 
28 #include <iostream>
29 #include <type_traits>
30 
31 namespace NiHu
32 {
33 
40 template <class T>
41 std::ostream & print_type_info(std::ostream &os = std::cout)
42 {
43  os << (std::is_const<typename std::remove_reference<T>::type >::value ? "const " : "");
44  os << (std::is_same<typename std::decay<T>::type, int>::value ? "int " : "");
45  os << (std::is_same<typename std::decay<T>::type, char>::value ? "char " : "");
46  os << (std::is_lvalue_reference<T>::value ? "&" : "");
47  os << (std::is_rvalue_reference<T>::value ? "&&" : "");
48  return os;
49 }
50 
51 } // end of namespace NiHu
52 
53 #endif /* TYPE_INFO_HPP_INCLUDED */
NiHu::print_type_info
std::ostream & print_type_info(std::ostream &os=std::cout)
Print type information.
Definition: type_info.hpp:41