[EMAIL PROTECTED] wrote:
Author: elemings
Date: Fri Jun 13 13:16:06 2008
New Revision: 667636

URL: http://svn.apache.org/viewvc?rev=667636&view=rev
Log:
2008-06-13  Eric Lemings <[EMAIL PROTECTED]>

        STDCXX-958
        * include/rw/_forward.h: New header file containing initial
        implementation of std::identity class template; std::forward()
        and std::move() functions; and internal _RWSTD_MOVE() macro.


Added:
    stdcxx/branches/4.3.x/include/rw/_forward.h

Added: stdcxx/branches/4.3.x/include/rw/_forward.h
URL: 
http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_forward.h?rev=667636&view=auto
==============================================================================
--- stdcxx/branches/4.3.x/include/rw/_forward.h (added)
+++ stdcxx/branches/4.3.x/include/rw/_forward.h Fri Jun 13 13:16:06 2008
[...]
+template <class _Type>

Please follow the current naming convention for the names
of template parameters.

+struct identity
+{
+    /** Identifies template parameter type. */
+    typedef _Type type;
+
+    /**
+     * Conversion operator.  This operator converts the parameter value
+     * to the wrapped identity type.
+     *
+     * @param __x An value convertible to identity type.
+     * @returns Same value as the function argument with identity type.
+     */
+    const _Type& operator() (const _Type& __x) {

The member function is supposed to be const.

+        return __x;
+    }
+};
+
+
+#    if !defined _RWSTD_NO_RVALUE_REFERENCES
+
+/**
+ * Forwards appropriate rvalue or lvalue reference type.  This function
+ * is used to ensure that the appropriate reference type is used in move
+ * semantics.
+ *
+ * @param _Type An lvalue or rvalue reference type.
+ * @param __x An lvalue reference or rvalue reference.
+ * @returns An lvalue if __x is an lvalue reference; otherwise, an rvalue.
+ */
+_EXPORT

Only out-of-line templates need to be declared exported.
Out-of-line function templates must be defined in .cc
files, and .cc files containing exported definitions
need to be explicitly #included in export.cpp.

This function template as well as move() below should be
declared inline.

+template <class _Type>
+_Type&&
+forward (_TYPENAME identity<_Type>::type&& __x)
+{
+    return __x;
+}
+
+/**
+ * Move a value to an rvalue reference.  This function is used to
+ * explicitly bind constructors and other functions with rvalue
+ * references that employ move semantics.
+ *
+ * @param __x An lvalue or rvalue.
+ * @returns Same value as parameter with rvalue reference type.
+ */
+_EXPORT
+template <class _Type>
+_TYPENAME _RW::__rw_remove_reference<_Type>::type&&
+move (_Type&& __x)
+{
+    return __x;
+}
+
+/**
+ * @internal
+ * Internal wrapper macro to utilize move semantics if available.
+ * @param __x An lvalue or rvalue.
+ */
+#      define _RWSTD_MOVE(__x)   std::move (__x)
                                    ^^^^^^^^^

This should be _STD::move (__x).

Thanks!
Martin

+#    else   // no rvalue references
+#      define _RWSTD_MOVE(__x)   (__x)
+
+#    endif   // !defined _RWSTD_NO_RVALUE_REFERENCES
+
+
+}   // namespace std
+
+
+#  endif   // !defined _RWSTD_NO_EXT_CXX_0X
+
+#endif   // _RWSTD_RW_FORWARD_INCLUDED



Reply via email to