diff --git a/alib2common/src/common/createUnique.hpp b/alib2common/src/common/createUnique.hpp index fac85d8c7ee42e481dc42507138acd9193fba45c..6c47cb06471355362574f45dec0497b765bc6813 100644 --- a/alib2common/src/common/createUnique.hpp +++ b/alib2common/src/common/createUnique.hpp @@ -24,7 +24,7 @@ namespace common { * @return created symbol */ template < class T, class ... Alphabets > -typename std::enable_if < ext::all_same < ext::set < T >, Alphabets ... >::value, T >::type createUnique ( const T & base, const Alphabets & ... alphabets ) { +T createUnique ( const T & base, const Alphabets & ... alphabets ) { T attempt = base; unsigned i = 0; diff --git a/alib2common/src/container/ContainerFeatures.h b/alib2common/src/container/ContainerFeatures.h deleted file mode 100644 index 1e6efaa9fd9a8c3b35484868cc5f8a23526ed3b4..0000000000000000000000000000000000000000 --- a/alib2common/src/container/ContainerFeatures.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ContainerFeatures.h - * - * Created on: Jun 19, 2014 - * Author: Jan Travnicek - */ - -#ifndef CONTAINER_FEATURES_H_ -#define CONTAINER_FEATURES_H_ - -#include <object/Object.h> - -namespace container { - -enum class FEATURES { - SET, - VECTOR, - PAIR, - MAP -}; - -class Container; -class ContainerBase; - -template < class ElementType = object::Object > -class ObjectsDeque; -template < class ElementType = object::Object > -class ObjectsList; -template < class KeyType = object::Object, class ValueType = object::Object > -class ObjectsMap; -template < class FirstType = object::Object, class SecondType = object::Object > -class ObjectsPair; -template < class ElementType = object::Object > -class ObjectsSet; -template < class ElementType = object::Object > -class ObjectsTree; -template < class KeyType = object::Object, class ValueType = object::Object > -class ObjectsTrie; -template < class ElementType = object::Object > -class ObjectsVector; - -} /* namespace container */ - -#endif /* CONTAINER_FEATURES_H_ */ diff --git a/alib2common/src/container/ObjectsDeque.h b/alib2common/src/container/ObjectsDeque.h index 4d87b8e0a7a75e0f0f5726aa7f2758f2a45cb652..3abc1439f4b35e27fd73f351d365c0f59ed5c53d 100644 --- a/alib2common/src/container/ObjectsDeque.h +++ b/alib2common/src/container/ObjectsDeque.h @@ -13,7 +13,6 @@ #include <sstream> #include "ContainerBase.h" -#include "ContainerFeatures.h" #include <object/UniqueObject.h> #include <object/ObjectFactory.h> @@ -26,7 +25,7 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occurred. */ -template < class ElementType > +template < class ElementType = object::Object > class ObjectsDeque final : public ext::deque < ElementType >, public ContainerBase { public: explicit ObjectsDeque ( ext::deque < ElementType > ); diff --git a/alib2common/src/container/ObjectsList.h b/alib2common/src/container/ObjectsList.h index 9d86a22aa9702f95eeef5976ee608b614fe95f60..8911a56de320340d857f8b5e2d0bb6b961ec48ee 100644 --- a/alib2common/src/container/ObjectsList.h +++ b/alib2common/src/container/ObjectsList.h @@ -13,7 +13,6 @@ #include <sstream> #include "ContainerBase.h" -#include "ContainerFeatures.h" #include <object/UniqueObject.h> #include <object/ObjectFactory.h> @@ -26,7 +25,7 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -template < class ElementType > +template < class ElementType = object::Object > class ObjectsList final : public ext::list < ElementType >, public ContainerBase { public: explicit ObjectsList ( ext::list < ElementType > ); diff --git a/alib2common/src/container/ObjectsMap.h b/alib2common/src/container/ObjectsMap.h index 5be8ce6930a766fdfa63f7ef503446ddf10cd652..f1e1b14e3cd275ddaba700cafc326d6cc5e2a70f 100644 --- a/alib2common/src/container/ObjectsMap.h +++ b/alib2common/src/container/ObjectsMap.h @@ -13,7 +13,6 @@ #include <sstream> #include "ContainerBase.h" -#include "ContainerFeatures.h" #include <object/UniqueObject.h> #include <object/ObjectFactory.h> @@ -27,7 +26,7 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -template < class KeyType, class ValueType > +template < class KeyType = object::Object, class ValueType = object::Object > class ObjectsMap final : public ext::map < KeyType, ValueType >, public ContainerBase { public: explicit ObjectsMap ( ext::map < KeyType, ValueType > ); diff --git a/alib2common/src/container/ObjectsPair.h b/alib2common/src/container/ObjectsPair.h index 21223d4fd6c05f379601782cd1eb12c1f9f7e518..e08ed37d0dc9e468089b7cd93430343975b765d7 100644 --- a/alib2common/src/container/ObjectsPair.h +++ b/alib2common/src/container/ObjectsPair.h @@ -13,7 +13,6 @@ #include <sstream> #include "ContainerBase.h" -#include "ContainerFeatures.h" #include <object/UniqueObject.h> #include <object/ObjectFactory.h> @@ -26,7 +25,7 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -template < class FirstType, class SecondType > +template < class FirstType = object::Object, class SecondType = object::Object > class ObjectsPair final : public ext::pair < FirstType, SecondType >, public ContainerBase { public: explicit ObjectsPair ( FirstType firstObject, SecondType secondObject ); diff --git a/alib2common/src/container/ObjectsSet.h b/alib2common/src/container/ObjectsSet.h index 631249cc815580c921b446e1f438a98af1aab7a5..0485d5d8da21f23a4d4219f0d0082dcfc510e854 100644 --- a/alib2common/src/container/ObjectsSet.h +++ b/alib2common/src/container/ObjectsSet.h @@ -13,7 +13,6 @@ #include <sstream> #include "ContainerBase.h" -#include "ContainerFeatures.h" #include <object/UniqueObject.h> #include <object/ObjectFactory.h> @@ -26,7 +25,7 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -template < class ElementType > +template < class ElementType = object::Object > class ObjectsSet final : public ext::set < ElementType >, public ContainerBase { public: explicit ObjectsSet ( ext::set < ElementType > ); diff --git a/alib2common/src/container/ObjectsTree.h b/alib2common/src/container/ObjectsTree.h index 4a4cd3448ea08735a09c062ad38e5ce09c01c539..b18c952abfb8aeec0d28ea91dada36897da574ef 100644 --- a/alib2common/src/container/ObjectsTree.h +++ b/alib2common/src/container/ObjectsTree.h @@ -13,7 +13,6 @@ #include <sstream> #include "ContainerBase.h" -#include "ContainerFeatures.h" #include <object/UniqueObject.h> #include <object/ObjectFactory.h> @@ -26,7 +25,7 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -template < class ElementType > +template < class ElementType = object::Object > class ObjectsTree final : public ext::tree < ElementType >, public ContainerBase { public: explicit ObjectsTree ( ext::tree < ElementType > ); diff --git a/alib2common/src/container/ObjectsTrie.h b/alib2common/src/container/ObjectsTrie.h index 65e49a2085228cbe0e1cc6125b750e89e8711b16..4634f28ac5e86d48880c41d4d0802fbba6af61a1 100644 --- a/alib2common/src/container/ObjectsTrie.h +++ b/alib2common/src/container/ObjectsTrie.h @@ -13,7 +13,6 @@ #include <sstream> #include "ContainerBase.h" -#include "ContainerFeatures.h" #include <object/UniqueObject.h> #include <object/ObjectFactory.h> @@ -26,7 +25,7 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -template < class KeyType, class ValueType > +template < class KeyType = object::Object, class ValueType = object::Object > class ObjectsTrie final : public ext::trie < KeyType, ValueType >, public ContainerBase { public: explicit ObjectsTrie ( ext::trie < KeyType, ValueType > ); diff --git a/alib2common/src/container/ObjectsVector.h b/alib2common/src/container/ObjectsVector.h index c9fefc9dcc40f0acac552281bae0b08c16ea0ff5..bdf41b9db1fbaa98a842ca3b952e7881100aa833 100644 --- a/alib2common/src/container/ObjectsVector.h +++ b/alib2common/src/container/ObjectsVector.h @@ -13,7 +13,6 @@ #include <sstream> #include "ContainerBase.h" -#include "ContainerFeatures.h" #include <object/UniqueObject.h> #include <object/ObjectFactory.h> @@ -26,7 +25,7 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -template < class ElementType > +template < class ElementType = object::Object > class ObjectsVector final : public ext::vector < ElementType >, public ContainerBase { public: explicit ObjectsVector ( ext::vector < ElementType > ); diff --git a/alib2common/src/primitive/PrimitiveFeatures.h b/alib2common/src/primitive/PrimitiveFeatures.h deleted file mode 100644 index e66479e7a78aef43f2497a5f6273d433ad1b0275..0000000000000000000000000000000000000000 --- a/alib2common/src/primitive/PrimitiveFeatures.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * PrimitiveFeatures.h - * - * Created on: Jun 19, 2014 - * Author: Jan Travnicek - */ - -#ifndef PRIMITIVE_FEATURES_H_ -#define PRIMITIVE_FEATURES_H_ - -namespace primitive { - -enum class FEATURES { - STRING, - CHAR, - INTEGER, - UNSIGNED, - BOOL -}; - -class Primitive; -class PrimitiveBase; - -class String; -class Integer; -class Character; -class Unsigned; -class Bool; - -} /* namespace primitive */ - -#endif /* PRIMITIVE_FEATURES_H_ */ diff --git a/alib2std/src/extensions/variant.hpp b/alib2std/src/extensions/variant.hpp index 3b6b5255d8dce62bb69396c31e28d7ad76857f60..9bf2bc7863e6472c35be4ca9d5644619fe93a73a 100644 --- a/alib2std/src/extensions/variant.hpp +++ b/alib2std/src/extensions/variant.hpp @@ -357,6 +357,29 @@ std::string to_string ( const ext::variant < Ts ... > & value ) { return ( std::string ) value; } +template < class Res, class T, class ... Ts > +struct variant_builder_int { +}; + +template < class T > +struct variant_builder_int < ext::variant < >, T > { + typedef T type; +}; + +template < class ... ResTs, class T > +struct variant_builder_int < ext::variant < ResTs ... >, T > { + typedef ext::variant < ResTs ..., T > type; +}; + +template < class ... ResTs, class T, class ... Ts > +struct variant_builder_int < ext::variant < ResTs ... >, T, Ts ... > { + typedef typename variant_builder_int < typename std::conditional < is_in < T, Ts ... >::value, ext::variant < ResTs ... >, ext::variant < ResTs ..., T > >::type, Ts ... >::type type; +}; + +template < class ... Ts > +struct variant_builder : public variant_builder_int < ext::variant < >, Ts ... > { +}; + } /* namespace ext */ #endif /* __VARIANT_HPP_ */ diff --git a/alib2std/test-src/extensions/VariantTest.cpp b/alib2std/test-src/extensions/VariantTest.cpp index 7cd176aa0a004ca0964b3d481174c51812ed5831..079ad78fc133e016988099d12bca09a44c442453 100644 --- a/alib2std/test-src/extensions/VariantTest.cpp +++ b/alib2std/test-src/extensions/VariantTest.cpp @@ -192,3 +192,18 @@ void VariantTest::testSetVariant ( ) { v = std::move ( v2 ); v.get < std::set < int > > ( ).insert ( 1 ); } + +void VariantTest::testVariantBuilder ( ) { + bool same; + same = std::is_same < ext::variant_builder < int >::type, int >::value; + CPPUNIT_ASSERT ( same ); + + same = std::is_same < ext::variant_builder < int, int, int >::type, int >::value; + CPPUNIT_ASSERT ( same ); + + same = std::is_same < ext::variant_builder < double, int, char >::type, ext::variant < double, int, char > >::value; + CPPUNIT_ASSERT ( same ); + + same = std::is_same < ext::variant_builder < double, int, char, char, int, double >::type, ext::variant < char, int, double > >::value; + CPPUNIT_ASSERT ( same ); +} diff --git a/alib2std/test-src/extensions/VariantTest.h b/alib2std/test-src/extensions/VariantTest.h index 9fc101e2bb0078bdd2ded161d393ba45ddd2865d..da2eb7ea55d40381b955b49b80eede775559892f 100644 --- a/alib2std/test-src/extensions/VariantTest.h +++ b/alib2std/test-src/extensions/VariantTest.h @@ -16,6 +16,7 @@ class VariantTest : public CppUnit::TestFixture CPPUNIT_TEST( testSizeT ); CPPUNIT_TEST( testMoveSemantics ); CPPUNIT_TEST( testSetVariant ); + CPPUNIT_TEST( testVariantBuilder ); CPPUNIT_TEST_SUITE_END(); public: @@ -80,6 +81,7 @@ public: void testSizeT(); void testMoveSemantics(); void testSetVariant ( ); + void testVariantBuilder ( ); }; namespace ext {