From 6f5a793da060334e431fc434607ba0c4c245ac32 Mon Sep 17 00:00:00 2001 From: Johannes Schanda Date: Fri, 11 Jan 2013 12:43:02 +0100 Subject: [PATCH] Remove experimental tests --- src/test/DBusVariantTest.cpp | 98 -------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 src/test/DBusVariantTest.cpp diff --git a/src/test/DBusVariantTest.cpp b/src/test/DBusVariantTest.cpp deleted file mode 100644 index 7928b16..0000000 --- a/src/test/DBusVariantTest.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include -#include -#include -#include - -template -struct VariantTypeSelector: VariantTypeSelector<_SearchType, _RestTypes...> { -}; - -template -struct VariantTypeSelector<_SearchType, _SearchType, _RestTypes...> { - typedef _SearchType type; -}; - -template -class Variant { - private: - typedef std::tuple_size> TypesTupleSize; - - public: - Variant(): valueType_(TypesTupleSize::value) { - } - - Variant(const Variant& fromVariant): - valueType_(fromVariant.valueType_), - valueStorage_(fromVariant.valueStorage_) { - } - - Variant(Variant&& fromVariant): - valueType_(std::move(fromVariant.valueType_)), - valueStorage_(std::move(fromVariant.valueStorage_)) { - fromVariant.valueType_ = TypesTupleSize::value; - } - - ~Variant() { - if (hasValue()) { - // TODO call value destructor - } - } - - Variant& operator=(const Variant& fromVariant) { - // TODO - return *this; - } - - Variant& operator=(Variant&& fromVariant) { - // TODO - return *this; - } - - // TODO use std::enable_if - template - Variant(const _Type& value) { - // TODO index by type - valueType_ = 0; - new (&valueStorage_) _Type(value); - } - - // TODO use std::enable_if - template - Variant(_Type && value) { - // TODO index by type - valueType_ = 0; - new (&valueStorage_) typename std::remove_reference<_Type>::type(std::move(value)); - } - - template - const typename VariantTypeSelector<_Type, _Types...>::type & get(bool& success) const { - // TODO assert _Type in _Types - success = true; - return *(reinterpret_cast(&valueStorage_)); - } - - private: - inline bool hasValue() const { - return valueType_ < TypesTupleSize::value; - } - - size_t valueType_; - // TODO calculate maximum storage - std::aligned_storage<80>::type valueStorage_; -}; - - - -int main(int argc, char** argv) { - int fromInt = 5; - Variant myVariant(fromInt); - bool success; - const int& myInt = myVariant.get(success); -// const float& myFloat = myVariant.get(success); - - std::cout << "myInt = " << myInt << " (" << std::boolalpha << success << ")\n"; - return 0; -} -- 2.7.4