From 33b684a160826e9dcf20483bc3d1169f071d95e8 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Wed, 26 Aug 2015 10:42:34 +0200 Subject: [PATCH] remove another template --- alib2data/src/alphabet/BarSymbol.h | 4 +++- alib2data/src/alphabet/BlankSymbol.h | 4 +++- alib2data/src/alphabet/BottomOfTheStackSymbol.h | 4 +++- alib2data/src/alphabet/EndSymbol.h | 4 +++- alib2data/src/alphabet/LabeledSymbol.h | 4 +++- alib2data/src/alphabet/RankedSymbol.h | 4 +++- alib2data/src/alphabet/StartSymbol.h | 4 +++- alib2data/src/alphabet/SubtreeWildcardSymbol.h | 4 +++- alib2data/src/alphabet/SymbolPairSymbol.h | 4 +++- alib2data/src/alphabet/SymbolSetSymbol.h | 4 +++- alib2data/src/alphabet/UniqueSymbol.h | 4 +++- alib2data/src/alphabet/VariablesBarSymbol.h | 4 +++- alib2data/src/automaton/FSM/CompactNFA.h | 4 +++- alib2data/src/automaton/FSM/DFA.h | 4 +++- alib2data/src/automaton/FSM/EpsilonNFA.h | 4 +++- alib2data/src/automaton/FSM/ExtendedNFA.h | 4 +++- .../src/automaton/FSM/MultiInitialStateNFA.h | 4 +++- alib2data/src/automaton/FSM/NFA.h | 4 +++- alib2data/src/automaton/PDA/DPDA.h | 4 +++- alib2data/src/automaton/PDA/InputDrivenDPDA.h | 4 +++- alib2data/src/automaton/PDA/InputDrivenNPDA.h | 4 +++- alib2data/src/automaton/PDA/NPDA.h | 4 +++- .../PDA/RealTimeHeightDeterministicDPDA.h | 4 +++- .../PDA/RealTimeHeightDeterministicNPDA.h | 4 +++- alib2data/src/automaton/PDA/SinglePopDPDA.h | 4 +++- alib2data/src/automaton/PDA/SinglePopNPDA.h | 4 +++- alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h | 4 +++- alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h | 4 +++- alib2data/src/automaton/TA/DFTA.h | 4 +++- alib2data/src/automaton/TA/NFTA.h | 4 +++- alib2data/src/automaton/TM/OneTapeDTM.h | 4 +++- alib2data/src/common/base.hpp | 11 ----------- alib2data/src/container/ObjectsMap.h | 4 +++- alib2data/src/container/ObjectsPair.h | 4 +++- alib2data/src/container/ObjectsSet.h | 4 +++- alib2data/src/container/ObjectsVector.h | 4 +++- alib2data/src/exception/AlibException.h | 4 +++- alib2data/src/grammar/ContextFree/CFG.h | 4 +++- alib2data/src/grammar/ContextFree/CNF.h | 4 +++- .../src/grammar/ContextFree/EpsilonFreeCFG.h | 4 +++- alib2data/src/grammar/ContextFree/GNF.h | 4 +++- alib2data/src/grammar/ContextFree/LG.h | 4 +++- alib2data/src/grammar/ContextSensitive/CSG.h | 4 +++- .../ContextSensitive/NonContractingGrammar.h | 4 +++- alib2data/src/grammar/Regular/LeftLG.h | 4 +++- alib2data/src/grammar/Regular/LeftRG.h | 4 +++- alib2data/src/grammar/Regular/RightLG.h | 4 +++- alib2data/src/grammar/Regular/RightRG.h | 4 +++- .../ContextPreservingUnrestrictedGrammar.h | 4 +++- .../grammar/Unrestricted/UnrestrictedGrammar.h | 4 +++- alib2data/src/graph/directed/DirectedGraph.h | 4 +++- alib2data/src/graph/undirected/UndirectedGraph.h | 4 +++- alib2data/src/label/HexavigesimalLabel.h | 4 +++- alib2data/src/label/LabelPairLabel.h | 4 +++- alib2data/src/label/LabelSetLabel.h | 4 +++- alib2data/src/label/ObjectLabel.h | 4 +++- alib2data/src/label/PrimitiveLabel.h | 4 +++- alib2data/src/label/UniqueLabel.h | 4 +++- alib2data/src/object/Void.h | 4 +++- alib2data/src/primitive/Bool.h | 4 +++- alib2data/src/primitive/Character.h | 4 +++- alib2data/src/primitive/Integer.h | 4 +++- alib2data/src/primitive/String.h | 4 +++- alib2data/src/primitive/Unsigned.h | 4 +++- alib2data/src/regexp/formal/FormalRegExp.h | 4 +++- .../src/regexp/formal/FormalRegExpAlternation.h | 4 +++- .../src/regexp/formal/FormalRegExpConcatenation.h | 4 +++- alib2data/src/regexp/formal/FormalRegExpEmpty.h | 4 +++- alib2data/src/regexp/formal/FormalRegExpEpsilon.h | 4 +++- .../src/regexp/formal/FormalRegExpIteration.h | 4 +++- alib2data/src/regexp/formal/FormalRegExpSymbol.h | 4 +++- alib2data/src/regexp/unbounded/UnboundedRegExp.h | 4 +++- .../regexp/unbounded/UnboundedRegExpAlternation.h | 4 +++- .../unbounded/UnboundedRegExpConcatenation.h | 4 +++- .../src/regexp/unbounded/UnboundedRegExpEmpty.h | 4 +++- .../src/regexp/unbounded/UnboundedRegExpEpsilon.h | 4 +++- .../regexp/unbounded/UnboundedRegExpIteration.h | 4 +++- .../src/regexp/unbounded/UnboundedRegExpSymbol.h | 4 +++- alib2data/src/string/CyclicString.h | 4 +++- alib2data/src/string/Epsilon.h | 4 +++- alib2data/src/string/LinearString.h | 4 +++- .../src/tree/ranked/PrefixRankedBarPattern.h | 4 +++- alib2data/src/tree/ranked/PrefixRankedBarTree.h | 4 +++- alib2data/src/tree/ranked/PrefixRankedPattern.h | 4 +++- alib2data/src/tree/ranked/PrefixRankedTree.h | 4 +++- alib2data/src/tree/ranked/RankedPattern.h | 4 +++- alib2data/src/tree/ranked/RankedTree.h | 4 +++- alib2data/src/tree/unranked/UnrankedPattern.h | 4 +++- alib2data/src/tree/unranked/UnrankedTree.h | 4 +++- alib2std/src/extensions/typeindex.h | 15 +++++++++++++++ alib2std/src/typeindex | 7 +++++++ 91 files changed, 286 insertions(+), 99 deletions(-) create mode 100644 alib2std/src/extensions/typeindex.h create mode 100644 alib2std/src/typeindex diff --git a/alib2data/src/alphabet/BarSymbol.h b/alib2data/src/alphabet/BarSymbol.h index f453079ae5..34058baaf1 100644 --- a/alib2data/src/alphabet/BarSymbol.h +++ b/alib2data/src/alphabet/BarSymbol.h @@ -27,7 +27,9 @@ public: virtual SymbolBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const BarSymbol & other ) const; diff --git a/alib2data/src/alphabet/BlankSymbol.h b/alib2data/src/alphabet/BlankSymbol.h index 6ae2ec63d4..0cae214431 100644 --- a/alib2data/src/alphabet/BlankSymbol.h +++ b/alib2data/src/alphabet/BlankSymbol.h @@ -27,7 +27,9 @@ public: virtual SymbolBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const BlankSymbol & other ) const; diff --git a/alib2data/src/alphabet/BottomOfTheStackSymbol.h b/alib2data/src/alphabet/BottomOfTheStackSymbol.h index 5378b44622..ab362107bc 100644 --- a/alib2data/src/alphabet/BottomOfTheStackSymbol.h +++ b/alib2data/src/alphabet/BottomOfTheStackSymbol.h @@ -27,7 +27,9 @@ public: virtual SymbolBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const BottomOfTheStackSymbol & other ) const; diff --git a/alib2data/src/alphabet/EndSymbol.h b/alib2data/src/alphabet/EndSymbol.h index a92192f2f5..d0180fb29e 100644 --- a/alib2data/src/alphabet/EndSymbol.h +++ b/alib2data/src/alphabet/EndSymbol.h @@ -27,7 +27,9 @@ public: virtual SymbolBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const EndSymbol & other ) const; diff --git a/alib2data/src/alphabet/LabeledSymbol.h b/alib2data/src/alphabet/LabeledSymbol.h index 076db05004..12dff66690 100644 --- a/alib2data/src/alphabet/LabeledSymbol.h +++ b/alib2data/src/alphabet/LabeledSymbol.h @@ -42,7 +42,9 @@ public: label::Label & getLabel ( ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const LabeledSymbol & other ) const; diff --git a/alib2data/src/alphabet/RankedSymbol.h b/alib2data/src/alphabet/RankedSymbol.h index 93f63b3558..a41996c5b0 100644 --- a/alib2data/src/alphabet/RankedSymbol.h +++ b/alib2data/src/alphabet/RankedSymbol.h @@ -48,7 +48,9 @@ public: const primitive::Unsigned & getRank ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const RankedSymbol & other ) const; diff --git a/alib2data/src/alphabet/StartSymbol.h b/alib2data/src/alphabet/StartSymbol.h index d441dcd0da..064815848c 100644 --- a/alib2data/src/alphabet/StartSymbol.h +++ b/alib2data/src/alphabet/StartSymbol.h @@ -27,7 +27,9 @@ public: virtual SymbolBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const StartSymbol & other ) const; diff --git a/alib2data/src/alphabet/SubtreeWildcardSymbol.h b/alib2data/src/alphabet/SubtreeWildcardSymbol.h index 8e8822e37f..bfe27f7f09 100644 --- a/alib2data/src/alphabet/SubtreeWildcardSymbol.h +++ b/alib2data/src/alphabet/SubtreeWildcardSymbol.h @@ -27,7 +27,9 @@ public: virtual SymbolBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const SubtreeWildcardSymbol & other ) const; diff --git a/alib2data/src/alphabet/SymbolPairSymbol.h b/alib2data/src/alphabet/SymbolPairSymbol.h index f034cdc599..dbd1e4dfd9 100644 --- a/alib2data/src/alphabet/SymbolPairSymbol.h +++ b/alib2data/src/alphabet/SymbolPairSymbol.h @@ -37,7 +37,9 @@ public: const std::pair < Symbol, Symbol > & getData ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const SymbolPairSymbol & other ) const; diff --git a/alib2data/src/alphabet/SymbolSetSymbol.h b/alib2data/src/alphabet/SymbolSetSymbol.h index 075e84fe44..e8900f76fa 100644 --- a/alib2data/src/alphabet/SymbolSetSymbol.h +++ b/alib2data/src/alphabet/SymbolSetSymbol.h @@ -37,7 +37,9 @@ public: const std::set < Symbol > & getData ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const SymbolSetSymbol & other ) const; diff --git a/alib2data/src/alphabet/UniqueSymbol.h b/alib2data/src/alphabet/UniqueSymbol.h index 5a9f364357..0a304b56b4 100644 --- a/alib2data/src/alphabet/UniqueSymbol.h +++ b/alib2data/src/alphabet/UniqueSymbol.h @@ -42,7 +42,9 @@ public: primitive::Integer & getId ( ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UniqueSymbol & other ) const; diff --git a/alib2data/src/alphabet/VariablesBarSymbol.h b/alib2data/src/alphabet/VariablesBarSymbol.h index 0d311be80b..b006095763 100644 --- a/alib2data/src/alphabet/VariablesBarSymbol.h +++ b/alib2data/src/alphabet/VariablesBarSymbol.h @@ -27,7 +27,9 @@ public: virtual SymbolBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const VariablesBarSymbol & other ) const; diff --git a/alib2data/src/automaton/FSM/CompactNFA.h b/alib2data/src/automaton/FSM/CompactNFA.h index 88934dcf89..a714c6d531 100644 --- a/alib2data/src/automaton/FSM/CompactNFA.h +++ b/alib2data/src/automaton/FSM/CompactNFA.h @@ -81,7 +81,9 @@ public: std::map < std::pair < State, string::LinearString >, std::set < State > > getTransitionsToState ( const State & from ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const CompactNFA & other ) const; diff --git a/alib2data/src/automaton/FSM/DFA.h b/alib2data/src/automaton/FSM/DFA.h index e36bc3a9b4..6a302755fe 100644 --- a/alib2data/src/automaton/FSM/DFA.h +++ b/alib2data/src/automaton/FSM/DFA.h @@ -82,7 +82,9 @@ public: bool isTotal ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const DFA & other ) const; diff --git a/alib2data/src/automaton/FSM/EpsilonNFA.h b/alib2data/src/automaton/FSM/EpsilonNFA.h index c69ab4f1ef..56fa4bb17f 100644 --- a/alib2data/src/automaton/FSM/EpsilonNFA.h +++ b/alib2data/src/automaton/FSM/EpsilonNFA.h @@ -159,7 +159,9 @@ public: bool isTotal ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const EpsilonNFA & other ) const; diff --git a/alib2data/src/automaton/FSM/ExtendedNFA.h b/alib2data/src/automaton/FSM/ExtendedNFA.h index 63c3169463..37faaf58cc 100644 --- a/alib2data/src/automaton/FSM/ExtendedNFA.h +++ b/alib2data/src/automaton/FSM/ExtendedNFA.h @@ -83,7 +83,9 @@ public: std::map < std::pair < State, regexp::RegExp >, std::set < State > > getTransitionsToState ( const State & from ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const ExtendedNFA & other ) const; diff --git a/alib2data/src/automaton/FSM/MultiInitialStateNFA.h b/alib2data/src/automaton/FSM/MultiInitialStateNFA.h index 747cb0fbdd..ffe0ae2c1c 100644 --- a/alib2data/src/automaton/FSM/MultiInitialStateNFA.h +++ b/alib2data/src/automaton/FSM/MultiInitialStateNFA.h @@ -98,7 +98,9 @@ public: unsigned transitionsSize ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const MultiInitialStateNFA & other ) const; diff --git a/alib2data/src/automaton/FSM/NFA.h b/alib2data/src/automaton/FSM/NFA.h index 057873fd62..c9d568394a 100644 --- a/alib2data/src/automaton/FSM/NFA.h +++ b/alib2data/src/automaton/FSM/NFA.h @@ -96,7 +96,9 @@ public: unsigned transitionsSize ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const NFA & other ) const; diff --git a/alib2data/src/automaton/PDA/DPDA.h b/alib2data/src/automaton/PDA/DPDA.h index 199afdf8b7..0ec6314c96 100644 --- a/alib2data/src/automaton/PDA/DPDA.h +++ b/alib2data/src/automaton/PDA/DPDA.h @@ -93,7 +93,9 @@ public: std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < State, std::vector < alphabet::Symbol > > > getTransitionsToState ( const State & from ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const DPDA & other ) const; diff --git a/alib2data/src/automaton/PDA/InputDrivenDPDA.h b/alib2data/src/automaton/PDA/InputDrivenDPDA.h index a4e0576941..c5d67d50de 100644 --- a/alib2data/src/automaton/PDA/InputDrivenDPDA.h +++ b/alib2data/src/automaton/PDA/InputDrivenDPDA.h @@ -95,7 +95,9 @@ public: bool isDeterministic ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const InputDrivenDPDA & other ) const; diff --git a/alib2data/src/automaton/PDA/InputDrivenNPDA.h b/alib2data/src/automaton/PDA/InputDrivenNPDA.h index b0f157937f..3504bb4a45 100644 --- a/alib2data/src/automaton/PDA/InputDrivenNPDA.h +++ b/alib2data/src/automaton/PDA/InputDrivenNPDA.h @@ -95,7 +95,9 @@ public: bool isDeterministic ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const InputDrivenNPDA & other ) const; diff --git a/alib2data/src/automaton/PDA/NPDA.h b/alib2data/src/automaton/PDA/NPDA.h index dbc9eba711..fb25cd6a45 100644 --- a/alib2data/src/automaton/PDA/NPDA.h +++ b/alib2data/src/automaton/PDA/NPDA.h @@ -79,7 +79,9 @@ public: const std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::pair < State, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const NPDA & other ) const; diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h index 3df41d3b2e..21d25c59a0 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h @@ -119,7 +119,9 @@ public: const std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, State > & getLocalTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const RealTimeHeightDeterministicDPDA & other ) const; diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h index 35e5443fb0..046ca4f7f1 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h @@ -119,7 +119,9 @@ public: const std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < State > > & getLocalTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const RealTimeHeightDeterministicNPDA & other ) const; diff --git a/alib2data/src/automaton/PDA/SinglePopDPDA.h b/alib2data/src/automaton/PDA/SinglePopDPDA.h index 4f5a80440f..4e450d8415 100644 --- a/alib2data/src/automaton/PDA/SinglePopDPDA.h +++ b/alib2data/src/automaton/PDA/SinglePopDPDA.h @@ -83,7 +83,9 @@ public: const std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::pair < State, std::vector < alphabet::Symbol > > > & getTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const SinglePopDPDA & other ) const; diff --git a/alib2data/src/automaton/PDA/SinglePopNPDA.h b/alib2data/src/automaton/PDA/SinglePopNPDA.h index 1782b58298..901ec11d14 100644 --- a/alib2data/src/automaton/PDA/SinglePopNPDA.h +++ b/alib2data/src/automaton/PDA/SinglePopNPDA.h @@ -79,7 +79,9 @@ public: const std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::set < std::pair < State, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const SinglePopNPDA & other ) const; diff --git a/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h b/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h index df9285dfe9..07bff3d05a 100644 --- a/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h +++ b/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h @@ -105,7 +105,9 @@ public: const std::map < std::pair < State, alphabet::Symbol >, State > & getLocalTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const VisiblyPushdownDPDA & other ) const; diff --git a/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h b/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h index bba11c1613..3f736cddf6 100644 --- a/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h +++ b/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h @@ -105,7 +105,9 @@ public: const std::map < std::pair < State, alphabet::Symbol >, std::set < State > > & getLocalTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const VisiblyPushdownNPDA & other ) const; diff --git a/alib2data/src/automaton/TA/DFTA.h b/alib2data/src/automaton/TA/DFTA.h index 62263e1f18..4dc69b135e 100644 --- a/alib2data/src/automaton/TA/DFTA.h +++ b/alib2data/src/automaton/TA/DFTA.h @@ -75,7 +75,9 @@ public: void addInputSymbol ( const alphabet::RankedSymbol & symbol ) { inputAlphabet.insert ( symbol ); } virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const DFTA & other ) const; diff --git a/alib2data/src/automaton/TA/NFTA.h b/alib2data/src/automaton/TA/NFTA.h index 92b26daee4..8300b3106a 100644 --- a/alib2data/src/automaton/TA/NFTA.h +++ b/alib2data/src/automaton/TA/NFTA.h @@ -87,7 +87,9 @@ public: void addInputSymbol ( const alphabet::RankedSymbol & symbol ) { inputAlphabet.insert ( symbol ); } virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const NFTA & other ) const; diff --git a/alib2data/src/automaton/TM/OneTapeDTM.h b/alib2data/src/automaton/TM/OneTapeDTM.h index d8a05e8719..33b1072c3a 100644 --- a/alib2data/src/automaton/TM/OneTapeDTM.h +++ b/alib2data/src/automaton/TM/OneTapeDTM.h @@ -74,7 +74,9 @@ public: const std::map < std::pair < State, alphabet::Symbol >, std::tuple < State, alphabet::Symbol, Shift > > & getTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const OneTapeDTM & other ) const; diff --git a/alib2data/src/common/base.hpp b/alib2data/src/common/base.hpp index 8ab1304e04..2208457c70 100644 --- a/alib2data/src/common/base.hpp +++ b/alib2data/src/common/base.hpp @@ -50,17 +50,6 @@ public: virtual int compare ( const T & other ) const = 0; - // TODO what if someone want to control the ordering? - template < typename R > - static int compare ( const R & first, const T & second ) { - if ( std::type_index ( typeid ( first ) ) < std::type_index ( typeid ( second ) ) ) - return -1; - else if ( std::type_index ( typeid ( first ) ) > std::type_index ( typeid ( second ) ) ) - return 1; - else - return first.compare ( ( const R & ) second ); - } - friend std::ostream & operator <<( std::ostream & os, const T & instance ) { instance >> os; return os; diff --git a/alib2data/src/container/ObjectsMap.h b/alib2data/src/container/ObjectsMap.h index bc647b3077..178d30ae9e 100644 --- a/alib2data/src/container/ObjectsMap.h +++ b/alib2data/src/container/ObjectsMap.h @@ -33,7 +33,9 @@ public: virtual ContainerBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const ObjectsMap & other ) const; diff --git a/alib2data/src/container/ObjectsPair.h b/alib2data/src/container/ObjectsPair.h index 2b879d2c98..aafd12c5e3 100644 --- a/alib2data/src/container/ObjectsPair.h +++ b/alib2data/src/container/ObjectsPair.h @@ -32,7 +32,9 @@ public: virtual ContainerBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const ObjectsPair & other ) const; diff --git a/alib2data/src/container/ObjectsSet.h b/alib2data/src/container/ObjectsSet.h index 0487478e9d..af31ce951f 100644 --- a/alib2data/src/container/ObjectsSet.h +++ b/alib2data/src/container/ObjectsSet.h @@ -32,7 +32,9 @@ public: virtual ContainerBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const ObjectsSet & other ) const; diff --git a/alib2data/src/container/ObjectsVector.h b/alib2data/src/container/ObjectsVector.h index 97d4782c8e..c5a0ee3c99 100644 --- a/alib2data/src/container/ObjectsVector.h +++ b/alib2data/src/container/ObjectsVector.h @@ -32,7 +32,9 @@ public: virtual ContainerBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const ObjectsVector & other ) const; diff --git a/alib2data/src/exception/AlibException.h b/alib2data/src/exception/AlibException.h index 611fbf1747..5108379c22 100644 --- a/alib2data/src/exception/AlibException.h +++ b/alib2data/src/exception/AlibException.h @@ -56,7 +56,9 @@ public: const std::string & getBacktrace ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const AlibException & other ) const; diff --git a/alib2data/src/grammar/ContextFree/CFG.h b/alib2data/src/grammar/ContextFree/CFG.h index 955c3e3dae..0eeb1ffba1 100644 --- a/alib2data/src/grammar/ContextFree/CFG.h +++ b/alib2data/src/grammar/ContextFree/CFG.h @@ -47,7 +47,9 @@ public: bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const CFG & other ) const; diff --git a/alib2data/src/grammar/ContextFree/CNF.h b/alib2data/src/grammar/ContextFree/CNF.h index d93a5dbaff..abac09f24b 100644 --- a/alib2data/src/grammar/ContextFree/CNF.h +++ b/alib2data/src/grammar/ContextFree/CNF.h @@ -56,7 +56,9 @@ public: bool getGeneratesEpsilon ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const CNF & other ) const; diff --git a/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h b/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h index 2afbe8cfb2..efdad77c4b 100644 --- a/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h +++ b/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h @@ -51,7 +51,9 @@ public: bool getGeneratesEpsilon ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const EpsilonFreeCFG & other ) const; diff --git a/alib2data/src/grammar/ContextFree/GNF.h b/alib2data/src/grammar/ContextFree/GNF.h index 9d2cd6f624..d611d11a8d 100644 --- a/alib2data/src/grammar/ContextFree/GNF.h +++ b/alib2data/src/grammar/ContextFree/GNF.h @@ -52,7 +52,9 @@ public: bool getGeneratesEpsilon ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const GNF & other ) const; diff --git a/alib2data/src/grammar/ContextFree/LG.h b/alib2data/src/grammar/ContextFree/LG.h index c18393883a..15310a8787 100644 --- a/alib2data/src/grammar/ContextFree/LG.h +++ b/alib2data/src/grammar/ContextFree/LG.h @@ -53,7 +53,9 @@ public: bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const LG & other ) const; diff --git a/alib2data/src/grammar/ContextSensitive/CSG.h b/alib2data/src/grammar/ContextSensitive/CSG.h index 48572908f7..d5d685043a 100644 --- a/alib2data/src/grammar/ContextSensitive/CSG.h +++ b/alib2data/src/grammar/ContextSensitive/CSG.h @@ -45,7 +45,9 @@ public: bool getGeneratesEpsilon ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const CSG & other ) const; diff --git a/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h b/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h index 3f5f49bb85..eace857bf1 100644 --- a/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h +++ b/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h @@ -45,7 +45,9 @@ public: bool getGeneratesEpsilon ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const NonContractingGrammar & other ) const; diff --git a/alib2data/src/grammar/Regular/LeftLG.h b/alib2data/src/grammar/Regular/LeftLG.h index 3546666f23..447c83c7cc 100644 --- a/alib2data/src/grammar/Regular/LeftLG.h +++ b/alib2data/src/grammar/Regular/LeftLG.h @@ -52,7 +52,9 @@ public: bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const LeftLG & other ) const; diff --git a/alib2data/src/grammar/Regular/LeftRG.h b/alib2data/src/grammar/Regular/LeftRG.h index 3f3c2ece02..caba6ae1af 100644 --- a/alib2data/src/grammar/Regular/LeftRG.h +++ b/alib2data/src/grammar/Regular/LeftRG.h @@ -125,7 +125,9 @@ public: * double dispatch operator helper */ virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } /** diff --git a/alib2data/src/grammar/Regular/RightLG.h b/alib2data/src/grammar/Regular/RightLG.h index e7978c7045..ec3c9f8b63 100644 --- a/alib2data/src/grammar/Regular/RightLG.h +++ b/alib2data/src/grammar/Regular/RightLG.h @@ -52,7 +52,9 @@ public: bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const RightLG & other ) const; diff --git a/alib2data/src/grammar/Regular/RightRG.h b/alib2data/src/grammar/Regular/RightRG.h index c24d9f3a3a..5c112d9ea5 100644 --- a/alib2data/src/grammar/Regular/RightRG.h +++ b/alib2data/src/grammar/Regular/RightRG.h @@ -72,7 +72,9 @@ public: bool getGeneratesEpsilon ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const RightRG & other ) const; diff --git a/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h b/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h index a025a8af91..948236eea2 100644 --- a/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h +++ b/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h @@ -41,7 +41,9 @@ public: bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const ContextPreservingUnrestrictedGrammar & other ) const; diff --git a/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h b/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h index 0adb0952fd..68499d1681 100644 --- a/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h +++ b/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h @@ -41,7 +41,9 @@ public: bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnrestrictedGrammar & other ) const; diff --git a/alib2data/src/graph/directed/DirectedGraph.h b/alib2data/src/graph/directed/DirectedGraph.h index 9d16ea20c1..c828f99ac0 100644 --- a/alib2data/src/graph/directed/DirectedGraph.h +++ b/alib2data/src/graph/directed/DirectedGraph.h @@ -63,7 +63,9 @@ public: void setEdgeValue ( const DirectedEdge & edge, int value ); int compare ( const ObjectBase & other ) const override { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } int compare ( const DirectedGraph & other ) const; diff --git a/alib2data/src/graph/undirected/UndirectedGraph.h b/alib2data/src/graph/undirected/UndirectedGraph.h index 575c7589d2..422b8fdd34 100644 --- a/alib2data/src/graph/undirected/UndirectedGraph.h +++ b/alib2data/src/graph/undirected/UndirectedGraph.h @@ -63,7 +63,9 @@ public: void setEdgeValue ( const UndirectedEdge & edge, int value ); int compare ( const ObjectBase & other ) const override { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } int compare ( const UndirectedGraph & other ) const; diff --git a/alib2data/src/label/HexavigesimalLabel.h b/alib2data/src/label/HexavigesimalLabel.h index bbb8a5d01d..4926eddbe5 100644 --- a/alib2data/src/label/HexavigesimalLabel.h +++ b/alib2data/src/label/HexavigesimalLabel.h @@ -40,7 +40,9 @@ public: void setData ( int data ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const HexavigesimalLabel & other ) const; diff --git a/alib2data/src/label/LabelPairLabel.h b/alib2data/src/label/LabelPairLabel.h index 43be641a6e..0952c0d231 100644 --- a/alib2data/src/label/LabelPairLabel.h +++ b/alib2data/src/label/LabelPairLabel.h @@ -37,7 +37,9 @@ public: const std::pair < Label, Label > & getData ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const LabelPairLabel & other ) const; diff --git a/alib2data/src/label/LabelSetLabel.h b/alib2data/src/label/LabelSetLabel.h index e97d33be0f..6a2cce0209 100644 --- a/alib2data/src/label/LabelSetLabel.h +++ b/alib2data/src/label/LabelSetLabel.h @@ -37,7 +37,9 @@ public: const std::set < Label > & getData ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const LabelSetLabel & other ) const; diff --git a/alib2data/src/label/ObjectLabel.h b/alib2data/src/label/ObjectLabel.h index dac4c7f921..ac6ae58030 100644 --- a/alib2data/src/label/ObjectLabel.h +++ b/alib2data/src/label/ObjectLabel.h @@ -38,7 +38,9 @@ public: const alib::Object & getData ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const ObjectLabel & other ) const; diff --git a/alib2data/src/label/PrimitiveLabel.h b/alib2data/src/label/PrimitiveLabel.h index 26397e4b40..7832d2f25e 100644 --- a/alib2data/src/label/PrimitiveLabel.h +++ b/alib2data/src/label/PrimitiveLabel.h @@ -40,7 +40,9 @@ public: primitive::Primitive & getData ( ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const PrimitiveLabel & other ) const; diff --git a/alib2data/src/label/UniqueLabel.h b/alib2data/src/label/UniqueLabel.h index 3832c97a85..207d361886 100644 --- a/alib2data/src/label/UniqueLabel.h +++ b/alib2data/src/label/UniqueLabel.h @@ -42,7 +42,9 @@ public: primitive::Integer & getId ( ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UniqueLabel & other ) const; diff --git a/alib2data/src/object/Void.h b/alib2data/src/object/Void.h index 7b624ae1e3..a8f5f64ddb 100644 --- a/alib2data/src/object/Void.h +++ b/alib2data/src/object/Void.h @@ -29,7 +29,9 @@ public: virtual ObjectBase * plunder ( ) &&; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const Void & other ) const; diff --git a/alib2data/src/primitive/Bool.h b/alib2data/src/primitive/Bool.h index 73033ce898..4dc1081110 100644 --- a/alib2data/src/primitive/Bool.h +++ b/alib2data/src/primitive/Bool.h @@ -42,7 +42,9 @@ public: void setData ( bool data ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const Bool & other ) const; diff --git a/alib2data/src/primitive/Character.h b/alib2data/src/primitive/Character.h index 56207ed374..1f6dc22150 100644 --- a/alib2data/src/primitive/Character.h +++ b/alib2data/src/primitive/Character.h @@ -42,7 +42,9 @@ public: void setData ( char data ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const Character & other ) const; diff --git a/alib2data/src/primitive/Integer.h b/alib2data/src/primitive/Integer.h index 0b618eaa11..480b51d61b 100644 --- a/alib2data/src/primitive/Integer.h +++ b/alib2data/src/primitive/Integer.h @@ -42,7 +42,9 @@ public: void setData ( int data ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const Integer & other ) const; diff --git a/alib2data/src/primitive/String.h b/alib2data/src/primitive/String.h index 5f0b74207e..c06de9e3c2 100644 --- a/alib2data/src/primitive/String.h +++ b/alib2data/src/primitive/String.h @@ -45,7 +45,9 @@ public: std::string & getData ( ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const String & other ) const; diff --git a/alib2data/src/primitive/Unsigned.h b/alib2data/src/primitive/Unsigned.h index 84bc44bd51..655f0dced6 100644 --- a/alib2data/src/primitive/Unsigned.h +++ b/alib2data/src/primitive/Unsigned.h @@ -42,7 +42,9 @@ public: void setData ( unsigned data ); virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const Unsigned & other ) const; diff --git a/alib2data/src/regexp/formal/FormalRegExp.h b/alib2data/src/regexp/formal/FormalRegExp.h index ac2cf82806..79005ed3bc 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.h +++ b/alib2data/src/regexp/formal/FormalRegExp.h @@ -97,7 +97,9 @@ public: virtual void operator >>( std::ostream & out ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const FormalRegExp & other ) const; diff --git a/alib2data/src/regexp/formal/FormalRegExpAlternation.h b/alib2data/src/regexp/formal/FormalRegExpAlternation.h index 31ce6bdf44..924c22adbf 100644 --- a/alib2data/src/regexp/formal/FormalRegExpAlternation.h +++ b/alib2data/src/regexp/formal/FormalRegExpAlternation.h @@ -94,7 +94,9 @@ public: void setRightElement ( FormalRegExpElement && element ); virtual int compare ( const FormalRegExpElement & other ) const { - return FormalRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const FormalRegExpAlternation & ) const; diff --git a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h index 5f810727da..67aed5a924 100644 --- a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h +++ b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h @@ -91,7 +91,9 @@ public: void setRightElement ( FormalRegExpElement && element ); virtual int compare ( const FormalRegExpElement & other ) const { - return FormalRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const FormalRegExpConcatenation & ) const; diff --git a/alib2data/src/regexp/formal/FormalRegExpEmpty.h b/alib2data/src/regexp/formal/FormalRegExpEmpty.h index 4d6f365941..da9f25692c 100644 --- a/alib2data/src/regexp/formal/FormalRegExpEmpty.h +++ b/alib2data/src/regexp/formal/FormalRegExpEmpty.h @@ -56,7 +56,9 @@ public: virtual FormalRegExpElement * plunder ( ) &&; virtual int compare ( const FormalRegExpElement & other ) const { - return FormalRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const FormalRegExpEmpty & ) const; diff --git a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h index fcb377cde1..7376efee5e 100644 --- a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h +++ b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h @@ -56,7 +56,9 @@ public: virtual FormalRegExpElement * plunder ( ) &&; virtual int compare ( const FormalRegExpElement & other ) const { - return FormalRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const FormalRegExpEpsilon & ) const; diff --git a/alib2data/src/regexp/formal/FormalRegExpIteration.h b/alib2data/src/regexp/formal/FormalRegExpIteration.h index 5982116539..825ebd29fe 100644 --- a/alib2data/src/regexp/formal/FormalRegExpIteration.h +++ b/alib2data/src/regexp/formal/FormalRegExpIteration.h @@ -85,7 +85,9 @@ public: void setElement ( FormalRegExpElement && element ); virtual int compare ( const FormalRegExpElement & other ) const { - return FormalRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const FormalRegExpIteration & ) const; diff --git a/alib2data/src/regexp/formal/FormalRegExpSymbol.h b/alib2data/src/regexp/formal/FormalRegExpSymbol.h index 147048d47d..ca76c10661 100644 --- a/alib2data/src/regexp/formal/FormalRegExpSymbol.h +++ b/alib2data/src/regexp/formal/FormalRegExpSymbol.h @@ -68,7 +68,9 @@ public: friend bool operator ==( const alphabet::Symbol &, const FormalRegExpSymbol & ); virtual int compare ( const FormalRegExpElement & other ) const { - return FormalRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const FormalRegExpSymbol & ) const; diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.h b/alib2data/src/regexp/unbounded/UnboundedRegExp.h index 8ad0e6978c..e5af6385a8 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.h @@ -98,7 +98,9 @@ public: virtual void operator >>( std::ostream & out ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnboundedRegExp & other ) const; diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h index 80d8ca068a..4bddc57fb8 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h @@ -87,7 +87,9 @@ public: void appendElement ( UnboundedRegExpElement && element ); virtual int compare ( const UnboundedRegExpElement & other ) const { - return UnboundedRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnboundedRegExpAlternation & ) const; diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h index 31ffa7e6e3..d70e012480 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h @@ -84,7 +84,9 @@ public: void appendElement ( UnboundedRegExpElement && element ); virtual int compare ( const UnboundedRegExpElement & other ) const { - return UnboundedRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnboundedRegExpConcatenation & ) const; diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h index d24dcc032c..383ec06049 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h @@ -55,7 +55,9 @@ public: virtual UnboundedRegExpElement * plunder ( ) &&; virtual int compare ( const UnboundedRegExpElement & other ) const { - return UnboundedRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnboundedRegExpEmpty & ) const; diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h index bd0cfefee1..d510508c92 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h @@ -55,7 +55,9 @@ public: virtual UnboundedRegExpElement * plunder ( ) &&; virtual int compare ( const UnboundedRegExpElement & other ) const { - return UnboundedRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnboundedRegExpEpsilon & ) const; diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h index 565635aaa0..797182fabb 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h @@ -85,7 +85,9 @@ public: void setElement ( UnboundedRegExpElement && element ); virtual int compare ( const UnboundedRegExpElement & other ) const { - return UnboundedRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnboundedRegExpIteration & ) const; diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h index 94e4ae15b3..d673e669b0 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h @@ -68,7 +68,9 @@ public: friend bool operator ==( const alphabet::Symbol &, const UnboundedRegExpSymbol & ); virtual int compare ( const UnboundedRegExpElement & other ) const { - return UnboundedRegExpElement::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnboundedRegExpSymbol & ) const; diff --git a/alib2data/src/string/CyclicString.h b/alib2data/src/string/CyclicString.h index 89f7bb52d9..1503a33830 100644 --- a/alib2data/src/string/CyclicString.h +++ b/alib2data/src/string/CyclicString.h @@ -56,7 +56,9 @@ public: bool isEmpty ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const CyclicString & other ) const; diff --git a/alib2data/src/string/Epsilon.h b/alib2data/src/string/Epsilon.h index 127b170572..a850cfbc7f 100644 --- a/alib2data/src/string/Epsilon.h +++ b/alib2data/src/string/Epsilon.h @@ -48,7 +48,9 @@ public: bool isEmpty ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const Epsilon & other ) const; diff --git a/alib2data/src/string/LinearString.h b/alib2data/src/string/LinearString.h index 54b80e9af2..1998501588 100644 --- a/alib2data/src/string/LinearString.h +++ b/alib2data/src/string/LinearString.h @@ -64,7 +64,9 @@ public: bool isEmpty ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const LinearString & other ) const; diff --git a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h index 436effaad7..41e0d973f7 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h @@ -61,7 +61,9 @@ public: bool isEmpty ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const PrefixRankedBarPattern & other ) const; diff --git a/alib2data/src/tree/ranked/PrefixRankedBarTree.h b/alib2data/src/tree/ranked/PrefixRankedBarTree.h index 2939998975..8315b1add1 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarTree.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarTree.h @@ -58,7 +58,9 @@ public: bool isEmpty ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const PrefixRankedBarTree & other ) const; diff --git a/alib2data/src/tree/ranked/PrefixRankedPattern.h b/alib2data/src/tree/ranked/PrefixRankedPattern.h index 5483b15930..2173003d09 100644 --- a/alib2data/src/tree/ranked/PrefixRankedPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedPattern.h @@ -51,7 +51,9 @@ public: bool isEmpty ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const PrefixRankedPattern & other ) const; diff --git a/alib2data/src/tree/ranked/PrefixRankedTree.h b/alib2data/src/tree/ranked/PrefixRankedTree.h index e2e6cabda8..cc9d822e3d 100644 --- a/alib2data/src/tree/ranked/PrefixRankedTree.h +++ b/alib2data/src/tree/ranked/PrefixRankedTree.h @@ -51,7 +51,9 @@ public: bool isEmpty ( ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const PrefixRankedTree & other ) const; diff --git a/alib2data/src/tree/ranked/RankedPattern.h b/alib2data/src/tree/ranked/RankedPattern.h index f51c45c0dd..8ef05bd619 100644 --- a/alib2data/src/tree/ranked/RankedPattern.h +++ b/alib2data/src/tree/ranked/RankedPattern.h @@ -84,7 +84,9 @@ public: virtual void operator >>( std::ostream & out ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const RankedPattern & other ) const; diff --git a/alib2data/src/tree/ranked/RankedTree.h b/alib2data/src/tree/ranked/RankedTree.h index 3a67fe2e44..6bb057aaf3 100644 --- a/alib2data/src/tree/ranked/RankedTree.h +++ b/alib2data/src/tree/ranked/RankedTree.h @@ -84,7 +84,9 @@ public: virtual void operator >>( std::ostream & out ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const RankedTree & other ) const; diff --git a/alib2data/src/tree/unranked/UnrankedPattern.h b/alib2data/src/tree/unranked/UnrankedPattern.h index 13debed747..d10b86ee1e 100644 --- a/alib2data/src/tree/unranked/UnrankedPattern.h +++ b/alib2data/src/tree/unranked/UnrankedPattern.h @@ -84,7 +84,9 @@ public: virtual void operator >>( std::ostream & out ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnrankedPattern & other ) const; diff --git a/alib2data/src/tree/unranked/UnrankedTree.h b/alib2data/src/tree/unranked/UnrankedTree.h index 90dea37642..aa4fbe9a0b 100644 --- a/alib2data/src/tree/unranked/UnrankedTree.h +++ b/alib2data/src/tree/unranked/UnrankedTree.h @@ -84,7 +84,9 @@ public: virtual void operator >>( std::ostream & out ) const; virtual int compare ( const ObjectBase & other ) const { - return ObjectBase::compare ( * this, other ); + if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); + + return std::type_index ( typeid ( * this ) ) - std::type_index ( typeid ( other ) ); } virtual int compare ( const UnrankedTree & other ) const; diff --git a/alib2std/src/extensions/typeindex.h b/alib2std/src/extensions/typeindex.h new file mode 100644 index 0000000000..dda5391b51 --- /dev/null +++ b/alib2std/src/extensions/typeindex.h @@ -0,0 +1,15 @@ +/* + * typeindex.hpp + * + * Created on: Apr 1, 2013 + * Author: Jan Travnicek + */ + +#ifndef TYPEINDEX_H_ +#define TYPEINDEX_H_ + +inline int operator -( const std::type_index & first, const std::type_index & second ) { + return ( first < second ) ? -1 : ( first > second ) ? 1 : 0; +} + +#endif // ifndef TYPEINDEX_H_ diff --git a/alib2std/src/typeindex b/alib2std/src/typeindex new file mode 100644 index 0000000000..3e7f2c6bdb --- /dev/null +++ b/alib2std/src/typeindex @@ -0,0 +1,7 @@ +#ifndef __TYPEINDEX_HEADER_WRAPPER_ +#define __TYPEINDEX_HEADER_WRAPPER_ + +#include <bits/../typeindex> +#include "extensions/typeindex.h" + +#endif /* __TYPEINDEX_HEADER_WRAPPER_ */ -- GitLab