felipealmeida pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=b713342987703e08b455b1c579084b35c41c6169

commit b713342987703e08b455b1c579084b35c41c6169
Author: Vitor Sousa <[email protected]>
Date:   Mon Jan 5 15:35:49 2015 -0200

    eina_cxx: Allow creating an eina::optional<T> from a type convertible to T
---
 src/bindings/eina_cxx/eina_optional.hh | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/bindings/eina_cxx/eina_optional.hh 
b/src/bindings/eina_cxx/eina_optional.hh
index 2517412..64e42d7 100644
--- a/src/bindings/eina_cxx/eina_optional.hh
+++ b/src/bindings/eina_cxx/eina_optional.hh
@@ -4,6 +4,7 @@
 #include <cstddef>
 #include <algorithm>
 #include <utility>
+#include <type_traits>
 
 /**
  * @addtogroup Eina_Cxx_Data_Types_Group
@@ -86,7 +87,7 @@ struct optional
     */
    optional(T&& other) : engaged(false)
    {
-      _construct(std::move(other));
+      _construct(std::forward<T>(other));
    }
 
    /**
@@ -99,7 +100,35 @@ struct optional
     */
    optional(T const& other) : engaged(false)
    {
-     _construct(std::move(other));
+     _construct(other);
+   }
+
+   /**
+    * @brief Create an engaged object by moving @p other content.
+    * @param other R-value reference to the desired type.
+    *
+    * This constructor creates an <tt>eina::optional</tt> object in an
+    * engaged state. The contained value is initialized by moving
+    * @p other.
+    */
+   template <typename U>
+   optional(U&& other, typename std::enable_if<std::is_convertible<U, 
T>::value>::type* = 0) : engaged(false)
+   {
+     _construct(std::forward<U>(other));
+   }
+
+   /**
+    * @brief Create an engaged object by copying @p other content.
+    * @param other Constant reference to the desired type.
+    *
+    * This constructor creates an <tt>eina::optional</tt> object in an
+    * engaged state. The contained value is initialized by copying
+    * @p other.
+    */
+   template <typename U>
+   optional(U const& other, typename std::enable_if<std::is_convertible<U, 
T>::value>::type* = 0) : engaged(false)
+   {
+     _construct(other);
    }
 
    /**

-- 


Reply via email to