X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fvalue.h;h=ba6118181260c1c92c2a53f8f885507914a4d759;hb=refs%2Fheads%2Fwip;hp=1b12db9a22db5f40e77578199bdfd7817fff4093;hpb=a582163d380833b1370ba067a1fd0ad5c2984723;p=libs%2Fdatafile.git diff --git a/source/value.h b/source/value.h index 1b12db9..ba61181 100644 --- a/source/value.h +++ b/source/value.h @@ -1,17 +1,11 @@ -/* $Id$ - -This file is part of libmspdatafile -Copyright © 2006-2008, 2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_DATAFILE_VALUE_H_ #define MSP_DATAFILE_VALUE_H_ #include +#include +#include #include #include -#include "except.h" #include "type.h" namespace Msp { @@ -25,15 +19,16 @@ private: public: template - Value(T d): + Value(T &&d, typename std::enable_if::type, Value>::value, int>::type = 0): sig(TypeInfo::signature), - data(static_cast::Store>(d)) + data(static_cast::Store>(std::forward(d))) { } - Value(Symbol d): sig(TypeInfo::signature), data(d) { } + Value(const Symbol &d): sig(TypeInfo::signature), data(d) { } + Value(Symbol &&d): sig(TypeInfo::signature), data(std::move(d)) { } template - typename RemoveReference::Type get() const + typename TypeInfo::Load get() const { return get_::Store>(); } char get_signature() const { return sig; } @@ -42,14 +37,9 @@ private: T get_() const; }; -typedef std::vector ValueArray __attribute__((deprecated)); - template inline T Value::get_() const { - if(sig!=TypeInfo::signature) - throw TypeError("Type mismatch"); - return data.value::Store>(); } @@ -58,10 +48,8 @@ inline FloatType::Store Value::get_() const { if(sig==IntType::signature) return data.value(); - else if(sig!=FloatType::signature) - throw TypeError("Type mismatch"); - - return data.value(); + else + return data.value(); } } // namespace DataFile