From a2e7d6937bb79caca876123040b36be09510bc2f Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Thu, 3 May 2018 10:29:48 +0200 Subject: [PATCH] fix new normalization of containers --- alib2common/src/container/ObjectsDeque.h | 9 +++------ alib2common/src/container/ObjectsList.h | 9 +++------ alib2common/src/container/ObjectsMap.h | 11 ++++------- alib2common/src/container/ObjectsPair.h | 14 ++++---------- alib2common/src/container/ObjectsSet.h | 9 +++------ alib2common/src/container/ObjectsTree.h | 11 ++++------- alib2common/src/container/ObjectsTrie.h | 11 ++++------- alib2common/src/container/ObjectsVector.h | 9 +++------ alib2common/test-src/container/ContainerTest.cpp | 4 ++-- 9 files changed, 30 insertions(+), 57 deletions(-) diff --git a/alib2common/src/container/ObjectsDeque.h b/alib2common/src/container/ObjectsDeque.h index aa421c50ec..4d87b8e0a7 100644 --- a/alib2common/src/container/ObjectsDeque.h +++ b/alib2common/src/container/ObjectsDeque.h @@ -98,8 +98,8 @@ object::ObjectBase* ObjectsDeque < ElementType >::inc() && { namespace core { template < class ElementType > -struct normalize < ext::deque < ElementType > > { - static ext::deque < object::Object > eval ( ext::deque < ElementType > && source ) { +struct normalize < container::ObjectsDeque < ElementType > > { + static ext::deque < object::Object > raw ( ext::deque < ElementType > && source ) { ext::deque < object::Object > res; for ( ElementType & element : source ) @@ -107,12 +107,9 @@ struct normalize < ext::deque < ElementType > > { return res; } -}; -template < class ElementType > -struct normalize < container::ObjectsDeque < ElementType > > { static container::ObjectsDeque < > eval ( container::ObjectsDeque < ElementType > && value ) { - return container::ObjectsDeque < > ( normalize < ext::deque < ElementType > >::eval ( std::move ( value ) ) ); + return container::ObjectsDeque < > ( raw ( std::move ( value ) ) ); } }; diff --git a/alib2common/src/container/ObjectsList.h b/alib2common/src/container/ObjectsList.h index 693dbc2a8e..9d86a22aa9 100644 --- a/alib2common/src/container/ObjectsList.h +++ b/alib2common/src/container/ObjectsList.h @@ -98,8 +98,8 @@ object::ObjectBase* ObjectsList < ElementType >::inc() && { namespace core { template < class ElementType > -struct normalize < ext::list < ElementType > > { - static ext::list < object::Object > eval ( ext::list < ElementType > && source ) { +struct normalize < container::ObjectsList < ElementType > > { + static ext::list < object::Object > raw ( ext::list < ElementType > && source ) { ext::list < object::Object > res; for ( ElementType & element : source ) @@ -107,12 +107,9 @@ struct normalize < ext::list < ElementType > > { return res; } -}; -template < class ElementType > -struct normalize < container::ObjectsList < ElementType > > { static container::ObjectsList < > eval ( container::ObjectsList < ElementType > && value ) { - return container::ObjectsList < > ( normalize < ext::list < ElementType > >::eval ( std::move ( value ) ) ); + return container::ObjectsList < > ( raw ( std::move ( value ) ) ); } }; diff --git a/alib2common/src/container/ObjectsMap.h b/alib2common/src/container/ObjectsMap.h index 5f07f1c730..5be8ce6930 100644 --- a/alib2common/src/container/ObjectsMap.h +++ b/alib2common/src/container/ObjectsMap.h @@ -100,21 +100,18 @@ object::ObjectBase* ObjectsMap < KeyType, ValueType >::inc() && { namespace core { template < class KeyType, class ValueType > -struct normalize < ext::map < KeyType, ValueType > > { - static ext::map < object::Object, object::Object > eval ( ext::map < KeyType, ValueType > && source ) { +struct normalize < container::ObjectsMap < KeyType, ValueType > > { + static ext::map < object::Object, object::Object > raw ( ext::map < KeyType, ValueType > && source ) { ext::map < object::Object, object::Object > res; for ( std::pair < KeyType, ValueType > && element : ext::make_moveable_map ( source ) ) - res.insert ( normalize < std::pair < KeyType, ValueType > >::eval ( std::move ( element ) ) ); + res.insert ( normalize < container::ObjectsPair < KeyType, ValueType > >::raw2 ( std::move ( element ) ) ); return res; } -}; -template < class KeyType, class ValueType > -struct normalize < container::ObjectsMap < KeyType, ValueType > > { static container::ObjectsMap < > eval ( container::ObjectsMap < KeyType, ValueType > && value ) { - return container::ObjectsMap < > ( normalize < ext::map < KeyType, ValueType > >::eval ( std::move ( value ) ) ); + return container::ObjectsMap < > ( raw ( std::move ( value ) ) ); } }; diff --git a/alib2common/src/container/ObjectsPair.h b/alib2common/src/container/ObjectsPair.h index 138bd26edb..21223d4fd6 100644 --- a/alib2common/src/container/ObjectsPair.h +++ b/alib2common/src/container/ObjectsPair.h @@ -99,23 +99,17 @@ object::ObjectBase* ObjectsPair < FirstType, SecondType >::inc() && { namespace core { template < class FirstType, class SecondType > -struct normalize < std::pair < FirstType, SecondType > > { - static std::pair < object::Object, object::Object > eval ( std::pair < FirstType, SecondType > && source ) { +struct normalize < container::ObjectsPair < FirstType, SecondType > > { + static std::pair < object::Object, object::Object > raw2 ( std::pair < FirstType, SecondType > && source ) { return std::make_pair ( object::ObjectFactory::make ( std::move ( source.first ) ), object::ObjectFactory::make ( std::move ( source.second ) ) ); } -}; -template < class FirstType, class SecondType > -struct normalize < ext::pair < FirstType, SecondType > > { - static ext::pair < object::Object, object::Object > eval ( ext::pair < FirstType, SecondType > && source ) { + static ext::pair < object::Object, object::Object > raw ( ext::pair < FirstType, SecondType > && source ) { return ext::make_pair ( object::ObjectFactory::make ( std::move ( source.first ) ), object::ObjectFactory::make ( std::move ( source.second ) ) ); } -}; -template < class FirstType, class SecondType > -struct normalize < container::ObjectsPair < FirstType, SecondType > > { static container::ObjectsPair < > eval ( container::ObjectsPair < FirstType, SecondType > && value ) { - return container::ObjectsPair < > ( normalize < ext::pair < FirstType, SecondType > >::eval ( std::move ( value ) ) ); + return container::ObjectsPair < > ( raw ( std::move ( value ) ) ); } }; diff --git a/alib2common/src/container/ObjectsSet.h b/alib2common/src/container/ObjectsSet.h index 0bddd728dd..631249cc81 100644 --- a/alib2common/src/container/ObjectsSet.h +++ b/alib2common/src/container/ObjectsSet.h @@ -99,8 +99,8 @@ object::ObjectBase* ObjectsSet < ElementType >::inc() && { namespace core { template < class ElementType > -struct normalize < ext::set < ElementType > > { - static ext::set < object::Object > eval ( ext::set < ElementType > && source ) { +struct normalize < container::ObjectsSet < ElementType > > { + static ext::set < object::Object > raw ( ext::set < ElementType > && source ) { ext::set < object::Object > res; for ( ElementType && element : ext::make_moveable_set ( source ) ) @@ -108,12 +108,9 @@ struct normalize < ext::set < ElementType > > { return res; } -}; -template < class ElementType > -struct normalize < container::ObjectsSet < ElementType > > { static container::ObjectsSet < > eval ( container::ObjectsSet < ElementType > && value ) { - return container::ObjectsSet < > ( normalize < ext::set < ElementType > >::eval ( std::move ( value ) ) ); + return container::ObjectsSet < > ( raw ( std::move ( value ) ) ); } }; diff --git a/alib2common/src/container/ObjectsTree.h b/alib2common/src/container/ObjectsTree.h index 09a2b7d2af..4a4cd3448e 100644 --- a/alib2common/src/container/ObjectsTree.h +++ b/alib2common/src/container/ObjectsTree.h @@ -93,22 +93,19 @@ object::ObjectBase* ObjectsTree < ElementType >::inc() && { namespace core { template < class ElementType > -struct normalize < ext::tree < ElementType > > { - static ext::tree < object::Object > eval ( ext::tree < ElementType > && source ) { +struct normalize < container::ObjectsTree < ElementType > > { + static ext::tree < object::Object > raw ( ext::tree < ElementType > && source ) { ext::vector < ext::tree < object::Object > > children; for ( ext::tree < ElementType > & child : source.getChildren ( ) ) { - children.push_back ( normalize < ext::tree < ElementType > >::eval ( std::move ( child ) ) ); + children.push_back ( raw ( std::move ( child ) ) ); } return ext::tree < object::Object > ( object::ObjectFactory::make ( std::move ( source.getData ( ) ) ), std::move ( children ) ); } -}; -template < class ElementType > -struct normalize < container::ObjectsTree < ElementType > > { static container::ObjectsTree < > eval ( container::ObjectsTree < ElementType > && value ) { - return container::ObjectsTree < > ( normalize < ext::tree < ElementType > >::eval ( std::move ( value ) ) ); + return container::ObjectsTree < > ( raw ( std::move ( value ) ) ); } }; diff --git a/alib2common/src/container/ObjectsTrie.h b/alib2common/src/container/ObjectsTrie.h index 6c0c81d57e..65e49a2085 100644 --- a/alib2common/src/container/ObjectsTrie.h +++ b/alib2common/src/container/ObjectsTrie.h @@ -93,22 +93,19 @@ object::ObjectBase* ObjectsTrie < KeyType, ValueType >::inc() && { namespace core { template < class KeyType, class ValueType > -struct normalize < ext::trie < KeyType, ValueType > > { - static ext::trie < object::Object, object::Object > eval ( ext::trie < KeyType, ValueType > && source ) { +struct normalize < container::ObjectsTrie < KeyType, ValueType > > { + static ext::trie < object::Object, object::Object > raw ( ext::trie < KeyType, ValueType > && source ) { ext::map < object::Object, ext::trie < object::Object, object::Object > > children; for ( std::pair < KeyType, ext::trie < KeyType, ValueType > > && child : ext::make_moveable_map ( source.getChildren ( ) ) ) { - children.insert ( std::make_pair ( object::ObjectFactory::make ( std::move ( child.first ) ), normalize < ext::trie < KeyType, ValueType > >::eval ( std::move ( child.second ) ) ) ); + children.insert ( std::make_pair ( object::ObjectFactory::make ( std::move ( child.first ) ), raw ( std::move ( child.second ) ) ) ); } return ext::trie < object::Object, object::Object > ( object::ObjectFactory::make ( std::move ( source.getData ( ) ) ), std::move ( children ) ); } -}; -template < class KeyType, class ValueType > -struct normalize < container::ObjectsTrie < KeyType, ValueType > > { static container::ObjectsTrie < > eval ( container::ObjectsTrie < KeyType, ValueType > && value ) { - return container::ObjectsTrie < > ( normalize < ext::trie < KeyType, ValueType > >::eval ( std::move ( value ) ) ); + return container::ObjectsTrie < > ( raw ( std::move ( value ) ) ); } }; diff --git a/alib2common/src/container/ObjectsVector.h b/alib2common/src/container/ObjectsVector.h index dc96857165..c9fefc9dcc 100644 --- a/alib2common/src/container/ObjectsVector.h +++ b/alib2common/src/container/ObjectsVector.h @@ -98,8 +98,8 @@ object::ObjectBase* ObjectsVector < ElementType >::inc() && { namespace core { template < class ElementType > -struct normalize < ext::vector < ElementType > > { - static ext::vector < object::Object > eval ( ext::vector < ElementType > && source ) { +struct normalize < container::ObjectsVector < ElementType > > { + static ext::vector < object::Object > raw ( ext::vector < ElementType > && source ) { ext::vector < object::Object > res; for ( ElementType & element : source ) @@ -107,12 +107,9 @@ struct normalize < ext::vector < ElementType > > { return res; } -}; -template < class ElementType > -struct normalize < container::ObjectsVector < ElementType > > { static container::ObjectsVector < > eval ( container::ObjectsVector < ElementType > && value ) { - return container::ObjectsVector < > ( normalize < ext::vector < ElementType > >::eval ( std::move ( value ) ) ); + return container::ObjectsVector < > ( raw ( std::move ( value ) ) ); } }; diff --git a/alib2common/test-src/container/ContainerTest.cpp b/alib2common/test-src/container/ContainerTest.cpp index f06c5aee22..2ffbb9d595 100644 --- a/alib2common/test-src/container/ContainerTest.cpp +++ b/alib2common/test-src/container/ContainerTest.cpp @@ -25,8 +25,8 @@ void ContainerTest::testProperties ( ) { void ContainerTest::testNormalize ( ) { ext::deque < int > dint; - ext::deque < object::Object > dnor = core::normalize < ext::deque < int > >::eval ( std::move ( dint ) ); - ext::deque < object::Object > dnor2 = core::normalize < ext::deque < object::Object > >::eval ( std::move ( dnor ) ); + ext::deque < object::Object > dnor = core::normalize < container::ObjectsDeque < int > >::raw ( std::move ( dint ) ); + ext::deque < object::Object > dnor2 = core::normalize < container::ObjectsDeque < object::Object > >::raw ( std::move ( dnor ) ); container::ObjectsDeque < int > Dint; container::ObjectsDeque < object::Object > Dnor = core::normalize < container::ObjectsDeque < int > >::eval ( std::move ( Dint ) ); -- GitLab