Commit 13901e4b by Jonathan Wakely Committed by Jonathan Wakely

type_traits: Doxygen improvements.

	* include/std/type_traits: Doxygen improvements.
	* include/bits/move.h: Likewise.
	* include/tr1/type_traits:  Likewise.
	* include/tr2/type_traits:  Likewise.
	* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
	line numbers
	* testsuite/20_util/forward/c_neg.cc: Likewise.
	* testsuite/20_util/forward/f_neg.cc: Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
	Likewise.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.

From-SVN: r181993
parent 02139671
2011-12-04 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/std/type_traits: Doxygen improvements.
* include/bits/move.h: Likewise.
* include/tr1/type_traits: Likewise.
* include/tr2/type_traits: Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
line numbers
* testsuite/20_util/forward/c_neg.cc: Likewise.
* testsuite/20_util/forward/f_neg.cc: Likewise.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
2011-12-04 Markus Trippelsdorf <markus@trippelsdorf.de> 2011-12-04 Markus Trippelsdorf <markus@trippelsdorf.de>
Jonathan Wakely <jwakely.gcc@gmail.com> Jonathan Wakely <jwakely.gcc@gmail.com>
......
...@@ -38,6 +38,10 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -38,6 +38,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Used, in C++03 mode too, by allocators, etc. // Used, in C++03 mode too, by allocators, etc.
/**
* @brief Same as C++11 std::addressof
* @ingroup utilities
*/
template<typename _Tp> template<typename _Tp>
inline _Tp* inline _Tp*
__addressof(_Tp& __r) _GLIBCXX_NOEXCEPT __addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
...@@ -56,12 +60,29 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -56,12 +60,29 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _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> template<typename _Tp>
constexpr _Tp&& constexpr _Tp&&
forward(typename std::remove_reference<_Tp>::type& __t) noexcept forward(typename std::remove_reference<_Tp>::type& __t) noexcept
{ return static_cast<_Tp&&>(__t); } { 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> template<typename _Tp>
constexpr _Tp&& constexpr _Tp&&
forward(typename std::remove_reference<_Tp>::type&& __t) noexcept forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
...@@ -72,10 +93,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -72,10 +93,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
/** /**
* @brief Move a value. * @brief Convert a value to an rvalue.
* @ingroup utilities
* @param __t A thing of arbitrary type. * @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> template<typename _Tp>
constexpr typename std::remove_reference<_Tp>::type&& constexpr typename std::remove_reference<_Tp>::type&&
...@@ -89,10 +109,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -89,10 +109,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
is_copy_constructible<_Tp>>::type { }; is_copy_constructible<_Tp>>::type { };
/** /**
* @brief Move unless it could throw and the type is copyable. * @brief Conditionally convert a value to an rvalue.
* @ingroup utilities
* @param __x A thing of arbitrary type. * @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> template<typename _Tp>
inline typename inline typename
...@@ -100,13 +122,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -100,13 +122,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
move_if_noexcept(_Tp& __x) noexcept move_if_noexcept(_Tp& __x) noexcept
{ return std::move(__x); } { return std::move(__x); }
/// declval, from type_traits. // declval, from type_traits.
/** /**
* @brief Returns the actual address of the object or function * @brief Returns the actual address of the object or function
* referenced by r, even in the presence of an overloaded * referenced by r, even in the presence of an overloaded
* operator&. * operator&.
* @ingroup utilities
* @param __r Reference to an object or function. * @param __r Reference to an object or function.
* @return The actual address. * @return The actual address.
*/ */
...@@ -115,6 +136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -115,6 +136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
addressof(_Tp& __r) noexcept addressof(_Tp& __r) noexcept
{ return std::__addressof(__r); } { return std::__addressof(__r); }
/// @} group utilities
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace } // namespace
...@@ -130,8 +152,12 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -130,8 +152,12 @@ namespace std _GLIBCXX_VISIBILITY(default)
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** /**
* @addtogroup utilities
* @{
*/
/**
* @brief Swaps two values. * @brief Swaps two values.
* @ingroup utilities
* @param __a A thing of arbitrary type. * @param __a A thing of arbitrary type.
* @param __b Another thing of arbitrary type. * @param __b Another thing of arbitrary type.
* @return Nothing. * @return Nothing.
...@@ -154,6 +180,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -154,6 +180,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 809. std::swap should be overloaded for array types. // DR 809. std::swap should be overloaded for array types.
/// Swap the contents of two arrays.
template<typename _Tp, size_t _Nm> template<typename _Tp, size_t _Nm>
inline void inline void
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
...@@ -165,6 +192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -165,6 +192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
swap(__a[__n], __b[__n]); swap(__a[__n], __b[__n]);
} }
/// @} group utilities
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace } // namespace
......
// C++0x type_traits -*- C++ -*- // C++11 type_traits -*- C++ -*-
// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. // Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
...@@ -42,7 +42,13 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -42,7 +42,13 @@ namespace std _GLIBCXX_VISIBILITY(default)
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** /**
* @addtogroup metaprogramming * @defgroup metaprogramming Metaprogramming and type traits
* @ingroup utilities
*
* Template utilities for compile-time introspection and modification,
* including type classification traits, type property inspection traits
* and type transformation traits.
*
* @{ * @{
*/ */
...@@ -56,10 +62,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -56,10 +62,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr operator value_type() { return value; } constexpr operator value_type() { return value; }
}; };
/// typedef for true_type /// The type used as a compile-time boolean with true value.
typedef integral_constant<bool, true> true_type; typedef integral_constant<bool, true> true_type;
/// typedef for false_type /// The type used as a compile-time boolean with false value.
typedef integral_constant<bool, false> false_type; typedef integral_constant<bool, false> false_type;
template<typename _Tp, _Tp __v> template<typename _Tp, _Tp __v>
...@@ -451,7 +457,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -451,7 +457,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct is_compound struct is_compound
: public integral_constant<bool, !is_fundamental<_Tp>::value> { }; : public integral_constant<bool, !is_fundamental<_Tp>::value> { };
/// is_member_pointer
template<typename _Tp> template<typename _Tp>
struct __is_member_pointer_helper struct __is_member_pointer_helper
: public false_type { }; : public false_type { };
...@@ -460,6 +465,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -460,6 +465,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __is_member_pointer_helper<_Tp _Cp::*> struct __is_member_pointer_helper<_Tp _Cp::*>
: public true_type { }; : public true_type { };
/// is_member_pointer
template<typename _Tp> template<typename _Tp>
struct is_member_pointer struct is_member_pointer
: public integral_constant<bool, (__is_member_pointer_helper< : public integral_constant<bool, (__is_member_pointer_helper<
...@@ -492,7 +498,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -492,7 +498,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public integral_constant<bool, __is_trivial(_Tp)> : public integral_constant<bool, __is_trivial(_Tp)>
{ }; { };
/// is_trivially_copyable (still unimplemented) // is_trivially_copyable (still unimplemented)
/// is_standard_layout /// is_standard_layout
template<typename _Tp> template<typename _Tp>
...@@ -564,6 +570,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -564,6 +570,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename> template<typename>
struct add_rvalue_reference; struct add_rvalue_reference;
/**
* @brief Utility to simplify expressions used in unevaluated operands
* @ingroup utilities
*/
template<typename _Tp> template<typename _Tp>
typename add_rvalue_reference<_Tp>::type declval() noexcept; typename add_rvalue_reference<_Tp>::type declval() noexcept;
...@@ -1702,9 +1712,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1702,9 +1712,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}; };
// Define a nested type if some predicate holds.
// Primary template. // Primary template.
/// enable_if /// Define a member typedef @c type only if a boolean constant is true.
template<bool, typename _Tp = void> template<bool, typename _Tp = void>
struct enable_if struct enable_if
{ }; { };
...@@ -1715,9 +1724,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1715,9 +1724,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ typedef _Tp type; }; { typedef _Tp type; };
// A conditional expression, but for types. If true, first, if false, second.
// Primary template. // Primary template.
/// conditional /// Define a member typedef @c type to one of two argument types.
template<bool _Cond, typename _Iftrue, typename _Iffalse> template<bool _Cond, typename _Iftrue, typename _Iffalse>
struct conditional struct conditional
{ typedef _Iftrue type; }; { typedef _Iftrue type; };
...@@ -1747,14 +1755,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1747,14 +1755,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type; common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
}; };
/// underlying_type /// The underlying type of an enum.
template<typename _Tp> template<typename _Tp>
struct underlying_type struct underlying_type
{ {
typedef __underlying_type(_Tp) type; typedef __underlying_type(_Tp) type;
}; };
/// declval
template<typename _Tp> template<typename _Tp>
struct __declval_protector struct __declval_protector
{ {
...@@ -1892,7 +1899,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1892,7 +1899,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
<typename remove_cv<_Tp>::type>::value> \ <typename remove_cv<_Tp>::type>::value> \
{ }; { };
// @} group metaprogramming /// @} group metaprogramming
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace } // namespace
......
// TR1 type_traits -*- C++ -*- // TR1 type_traits -*- C++ -*-
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -41,10 +41,7 @@ namespace tr1 ...@@ -41,10 +41,7 @@ namespace tr1
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** /**
* @defgroup metaprogramming Type Traits * @addtogroup metaprogramming
* @ingroup utilities
*
* Compile time type transformation and information.
* @{ * @{
*/ */
...@@ -682,6 +679,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -682,6 +679,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#undef _DEFINE_SPEC_2_HELPER #undef _DEFINE_SPEC_2_HELPER
#undef _DEFINE_SPEC #undef _DEFINE_SPEC
/// @} group metaprogramming
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} }
} }
......
...@@ -40,9 +40,7 @@ namespace tr2 ...@@ -40,9 +40,7 @@ namespace tr2
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** /**
* @defgroup metaprogramming Type Traits * @addtogroup metaprogramming
* @ingroup utilities
*
* @{ * @{
*/ */
...@@ -111,6 +109,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -111,6 +109,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef typelist<__direct_bases(_Tp)...> type; typedef typelist<__direct_bases(_Tp)...> type;
}; };
/// @} group metaprogramming
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} }
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-error "static assertion failed" "" { target *-*-* } 1769 } // { dg-error "static assertion failed" "" { target *-*-* } 1776 }
#include <utility> #include <utility>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-error "static assertion failed" "" { target *-*-* } 69 } // { dg-error "static assertion failed" "" { target *-*-* } 90 }
#include <list> #include <list>
......
// { dg-do compile } // { dg-do compile }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2010 Free Software Foundation, Inc. // Copyright (C) 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-error "static assertion failed" "" { target *-*-* } 69 } // { dg-error "static assertion failed" "" { target *-*-* } 90 }
#include <utility> #include <utility>
......
...@@ -48,5 +48,5 @@ void test01() ...@@ -48,5 +48,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 } // { dg-error "required from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1555 } // { dg-error "invalid use of incomplete type" "" { target *-*-* } 1565 }
// { dg-error "declaration of" "" { target *-*-* } 1519 } // { dg-error "declaration of" "" { target *-*-* } 1529 }
...@@ -48,5 +48,5 @@ void test01() ...@@ -48,5 +48,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 } // { dg-error "required from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1473 } // { dg-error "invalid use of incomplete type" "" { target *-*-* } 1483 }
// { dg-error "declaration of" "" { target *-*-* } 1437 } // { dg-error "declaration of" "" { target *-*-* } 1447 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment