From c1c168694d408114005dd86a7074574a3833faec Mon Sep 17 00:00:00 2001 From: Johannes Schanda Date: Mon, 14 Jan 2013 11:17:02 +0100 Subject: [PATCH] Fix warnings in return --- src/test/DBusVariantTest.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/test/DBusVariantTest.cpp b/src/test/DBusVariantTest.cpp index af1ee9e..e72adde 100644 --- a/src/test/DBusVariantTest.cpp +++ b/src/test/DBusVariantTest.cpp @@ -210,18 +210,22 @@ class Variant { return *this; } - /*Variant& operator=(const Variant& fromVariant) { - // TODO - return *this; + Variant& operator=(Variant&& rhs) { + assign_visitor<_Types...> visitor(*this); + apply_void_visitor, Variant<_Types...>, _Types...>::visit(visitor, rhs); + return *this; } -*/ - Variant& operator=(Variant&& fromVariant) { - // TODO - return *this; + + template + typename std::enable_if>::value, Variant<_Types...>&>::type + operator=(const _Type& value) + { + set::type>(value); + return *this; } template - const bool& isType() const { + const bool isType() const { typedef typename select_type<_Type, _Types...>::type selected_type_t; unsigned int cType = type_index_getter<_Types...>::template get(); if(cType == valueType_) { @@ -231,30 +235,23 @@ class Variant { } } - // TODO use std::enable_if template Variant(const _Type& value, typename std::enable_if::value>::type* = 0, typename std::enable_if::value>::type* = 0, typename std::enable_if::value>::type* = 0) { - /*typedef typename select_type<_Type, _Types...>::type selected_type_t; - valueType_ = type_index_getter<_Types...>::template get(); - new (&valueStorage_) _Type(value);*/ set::type>(value, false); } - // TODO use std::enable_if template Variant(_Type && value, typename std::enable_if::value>::type* = 0, typename std::enable_if::value>::type* = 0, typename std::enable_if::value>::type* = 0) { - /*typedef typename select_type<_Type, _Types...>::type selected_type_t; - valueType_ = type_index_getter<_Types...>::template get(); - new (&valueStorage_) typename std::remove_reference<_Type>::type(std::move(value));*/ set2::type>(std::move(value), false); } + //TODO: Return type??? template const typename VariantTypeSelector<_Type, _Types...>::type & get(bool& success) const { typedef typename select_type<_Type, _Types...>::type selected_type_t; @@ -264,8 +261,7 @@ class Variant { return *(reinterpret_cast(&valueStorage_)); } else { success = false; - //TODO: Fix return temporary - return _Type(); + return *(reinterpret_cast(&valueStorage_)); } } -- 2.7.4