summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/move.h
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/bits/move.h')
-rw-r--r--libstdc++-v3/include/bits/move.h50
1 files changed, 39 insertions, 11 deletions
diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h
index f5beb22bb8d..353c466d8fc 100644
--- a/libstdc++-v3/include/bits/move.h
+++ b/libstdc++-v3/include/bits/move.h
@@ -38,6 +38,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Used, in C++03 mode too, by allocators, etc.
+ /**
+ * @brief Same as C++11 std::addressof
+ * @ingroup utilities
+ */
template<typename _Tp>
inline _Tp*
__addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
@@ -55,13 +59,30 @@ _GLIBCXX_END_NAMESPACE_VERSION
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
- /// forward (as per N3143)
+
+ /**
+ * @addtogroup utilities
+ * @{
+ */
+
+ // forward (as per N3143)
+ /**
+ * @brief Forward an lvalue.
+ * @return The parameter cast to the specified type.
+ *
+ * This function is used to implement "perfect forwarding".
+ */
template<typename _Tp>
constexpr _Tp&&
forward(typename std::remove_reference<_Tp>::type& __t) noexcept
{ return static_cast<_Tp&&>(__t); }
+ /**
+ * @brief Forward an rvalue.
+ * @return The parameter cast to the specified type.
+ *
+ * This function is used to implement "perfect forwarding".
+ */
template<typename _Tp>
constexpr _Tp&&
forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
@@ -72,10 +93,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
/**
- * @brief Move a value.
- * @ingroup utilities
+ * @brief Convert a value to an rvalue.
* @param __t A thing of arbitrary type.
- * @return Same, moved.
+ * @return The parameter cast to an rvalue-reference to allow moving it.
*/
template<typename _Tp>
constexpr typename std::remove_reference<_Tp>::type&&
@@ -89,10 +109,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
is_copy_constructible<_Tp>>::type { };
/**
- * @brief Move unless it could throw and the type is copyable.
- * @ingroup utilities
+ * @brief Conditionally convert a value to an rvalue.
* @param __x A thing of arbitrary type.
- * @return Same, possibly moved.
+ * @return The parameter, possibly cast to an rvalue-reference.
+ *
+ * Same as std::move unless the type's move constructor could throw and the
+ * type is copyable, in which case an lvalue-reference is returned instead.
*/
template<typename _Tp>
inline typename
@@ -100,13 +122,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
move_if_noexcept(_Tp& __x) noexcept
{ return std::move(__x); }
- /// declval, from type_traits.
+ // declval, from type_traits.
/**
* @brief Returns the actual address of the object or function
* referenced by r, even in the presence of an overloaded
* operator&.
- * @ingroup utilities
* @param __r Reference to an object or function.
* @return The actual address.
*/
@@ -115,6 +136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
addressof(_Tp& __r) noexcept
{ return std::__addressof(__r); }
+ /// @} group utilities
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
@@ -130,8 +152,12 @@ namespace std _GLIBCXX_VISIBILITY(default)
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
+ * @addtogroup utilities
+ * @{
+ */
+
+ /**
* @brief Swaps two values.
- * @ingroup utilities
* @param __a A thing of arbitrary type.
* @param __b Another thing of arbitrary type.
* @return Nothing.
@@ -154,6 +180,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 809. std::swap should be overloaded for array types.
+ /// Swap the contents of two arrays.
template<typename _Tp, size_t _Nm>
inline void
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
@@ -165,6 +192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
swap(__a[__n], __b[__n]);
}
+ /// @} group utilities
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace