eina-cxx: Restrict templated constructor
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>
Mon, 6 Jun 2016 05:49:28 +0000 (02:49 -0300)
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>
Mon, 6 Jun 2016 05:49:28 +0000 (02:49 -0300)
src/bindings/cxx/eina_cxx/eina_value.hh

index cc57191..0f348c1 100644 (file)
@@ -35,7 +35,10 @@ template <typename T>
 struct _eina_value_traits_base;
 
 template <typename T>
-struct _eina_value_traits_aux;
+struct _eina_value_traits_aux
+{
+   typedef std::false_type is_specialized;
+};
 
 /**
  * @internal
@@ -44,6 +47,7 @@ template <typename T>
 struct _eina_value_traits_base
 {
   typedef T type;
+  typedef std::true_type is_specialized;
 
   static ::Eina_Value* create()
   {
@@ -335,7 +339,7 @@ public:
    * @param v Value to be stored.
    */
   template <typename T>
-  value(T v)
+  value(T v, typename std::enable_if<_eina_value_traits<T>::is_specialized::value>::type* = 0)
   {
     primitive_init(v);
   }
@@ -438,6 +442,9 @@ public:
     eina_value_free(_raw);
   }
 
+  value(Eina_Value* raw)
+    : _raw(raw) {}
+
   /**
    * @brief Copy Constructor. Create an generic value storage holding the same value of @p other.
    * @param other Another <tt>eina::value</tt> object.