]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/value.h
Move the definition of Input's operator bool to the header
[libs/datafile.git] / source / value.h
index c272bcf81dc57b34e9e87f66112a997691aec282..ba6118181260c1c92c2a53f8f885507914a4d759 100644 (file)
@@ -2,6 +2,7 @@
 #define MSP_DATAFILE_VALUE_H_
 
 #include <vector>
+#include <type_traits>
 #include <msp/core/attributes.h>
 #include <msp/core/meta.h>
 #include <msp/core/variant.h>
@@ -18,12 +19,13 @@ private:
 
 public:
        template<typename T>
-       Value(T d):
+       Value(T &&d, typename std::enable_if<!std::is_same<typename std::remove_reference<T>::type, Value>::value, int>::type = 0):
                sig(TypeInfo<T>::signature),
-               data(static_cast<typename TypeInfo<T>::Store>(d))
+               data(static_cast<typename TypeInfo<T>::Store>(std::forward<T>(d)))
        { }
 
-       Value(Symbol d): sig(TypeInfo<Symbol>::signature), data(d) { }
+       Value(const Symbol &d): sig(TypeInfo<Symbol>::signature), data(d) { }
+       Value(Symbol &&d): sig(TypeInfo<Symbol>::signature), data(std::move(d)) { }
 
        template<typename T>
        typename TypeInfo<T>::Load get() const