Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
typeinfo.hpp
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
26#include <typeinfo>
27
29
30#include "typeindex.h"
31
32namespace ext {
33
44template < class T >
45std::string to_string ( ) {
46 if constexpr ( std::is_class < T >::value ) {
47 std::string res = ext::to_string ( ext::type_index ( typeid ( T * ) ) ); // handle even incomplete class types
48 res.pop_back ( ); // to erase extra pointer
49 return res;
50 } else {
51 return ext::to_string ( ext::type_index ( typeid ( T ) ) );
52 }
53}
54
62bool is_same_type ( const std::string & first, const std::string & second );
63bool are_same_types ( const std::vector < std::string > & first, const std::vector < std::string > & second );
64
65template < typename T >
66bool is_same_type ( const std::string & name ) {
67 std::string ret = to_string < T > ( );
68 return is_same_type ( ret, name );
69}
70
71std::string erase_template_info ( std::string str );
72ext::vector < std::string > get_template_info ( const std::string & str );
73
74} /* namespace ext */
75
Definition: typeindex.h:37
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
p second
Definition: ToRegExpAlgebraic.h:126
ext::set< ext::pair< StateType, StateType > > ret(const ext::set< ext::pair< StateType, StateType > > &S, const DeterministicPushdownStoreSymbolType &pdaSymbol, const InputSymbolType &input, const N &nondeterministic)
Definition: RHDPDACommon.h:57
return res
Definition: MinimizeByPartitioning.h:145
Definition: sigHandler.cpp:20
ext::vector< std::string > get_template_info(const std::string &str)
Definition: typeinfo.cpp:25
std::string erase_template_info(std::string str)
Definition: typeinfo.cpp:12
std::string to_string(const T &value)
To string method designated for objects that can be casted to string.
Definition: string.hpp:131
bool are_same_types(const std::vector< std::string > &first, const std::vector< std::string > &second)
Definition: typeinfo.cpp:61
bool is_same_type(const std::string &first, const std::string &second)
Compares two types specified by their string names not looking at template params and unspecified seg...
Definition: typeinfo.cpp:41