Commit 6b14c6d7 by Paolo Carlini Committed by Paolo Carlini

functional: Use noexcept.

2011-06-14  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/functional: Use noexcept.
	* include/bits/stl_tempbuf.h: Likewise.

From-SVN: r175026
parent 5e59d472
2011-06-14 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/functional: Use noexcept.
* include/bits/stl_tempbuf.h: Likewise.
2011-06-12 François Dumont <francois.cppdevs@free.fr> 2011-06-12 François Dumont <francois.cppdevs@free.fr>
Paolo Carlini <paolo.carlini@oracle.com> Paolo Carlini <paolo.carlini@oracle.com>
......
// Temporary buffer implementation -*- C++ -*- // Temporary buffer implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 // Copyright (C) 2001, 2002, 2003, 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
...@@ -83,7 +84,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -83,7 +84,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Tp> template<typename _Tp>
pair<_Tp*, ptrdiff_t> pair<_Tp*, ptrdiff_t>
get_temporary_buffer(ptrdiff_t __len) get_temporary_buffer(ptrdiff_t __len) _GLIBCXX_NOEXCEPT
{ {
const ptrdiff_t __max = const ptrdiff_t __max =
__gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp); __gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp);
......
...@@ -437,28 +437,28 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -437,28 +437,28 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
public: public:
typedef _Tp type; typedef _Tp type;
reference_wrapper(_Tp& __indata) reference_wrapper(_Tp& __indata) noexcept
: _M_data(std::__addressof(__indata)) : _M_data(std::__addressof(__indata))
{ } { }
reference_wrapper(_Tp&&) = delete; reference_wrapper(_Tp&&) = delete;
reference_wrapper(const reference_wrapper<_Tp>& __inref): reference_wrapper(const reference_wrapper<_Tp>& __inref) noexcept
_M_data(__inref._M_data) : _M_data(__inref._M_data)
{ } { }
reference_wrapper& reference_wrapper&
operator=(const reference_wrapper<_Tp>& __inref) operator=(const reference_wrapper<_Tp>& __inref) noexcept
{ {
_M_data = __inref._M_data; _M_data = __inref._M_data;
return *this; return *this;
} }
operator _Tp&() const operator _Tp&() const noexcept
{ return this->get(); } { return this->get(); }
_Tp& _Tp&
get() const get() const noexcept
{ return *_M_data; } { return *_M_data; }
template<typename... _Args> template<typename... _Args>
...@@ -473,13 +473,13 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -473,13 +473,13 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
/// Denotes a reference should be taken to a variable. /// Denotes a reference should be taken to a variable.
template<typename _Tp> template<typename _Tp>
inline reference_wrapper<_Tp> inline reference_wrapper<_Tp>
ref(_Tp& __t) ref(_Tp& __t) noexcept
{ return reference_wrapper<_Tp>(__t); } { return reference_wrapper<_Tp>(__t); }
/// Denotes a const reference should be taken to a variable. /// Denotes a const reference should be taken to a variable.
template<typename _Tp> template<typename _Tp>
inline reference_wrapper<const _Tp> inline reference_wrapper<const _Tp>
cref(const _Tp& __t) cref(const _Tp& __t) noexcept
{ return reference_wrapper<const _Tp>(__t); } { return reference_wrapper<const _Tp>(__t); }
template<typename _Tp> template<typename _Tp>
...@@ -491,13 +491,13 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -491,13 +491,13 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
/// Partial specialization. /// Partial specialization.
template<typename _Tp> template<typename _Tp>
inline reference_wrapper<_Tp> inline reference_wrapper<_Tp>
ref(reference_wrapper<_Tp> __t) ref(reference_wrapper<_Tp> __t) noexcept
{ return ref(__t.get()); } { return ref(__t.get()); }
/// Partial specialization. /// Partial specialization.
template<typename _Tp> template<typename _Tp>
inline reference_wrapper<const _Tp> inline reference_wrapper<const _Tp>
cref(reference_wrapper<_Tp> __t) cref(reference_wrapper<_Tp> __t) noexcept
{ return cref(__t.get()); } { return cref(__t.get()); }
// @} group functors // @} group functors
...@@ -1913,13 +1913,15 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -1913,13 +1913,15 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
* @brief Default construct creates an empty function call wrapper. * @brief Default construct creates an empty function call wrapper.
* @post @c !(bool)*this * @post @c !(bool)*this
*/ */
function() : _Function_base() { } function() noexcept
: _Function_base() { }
/** /**
* @brief Creates an empty function call wrapper. * @brief Creates an empty function call wrapper.
* @post @c !(bool)*this * @post @c !(bool)*this
*/ */
function(nullptr_t) : _Function_base() { } function(nullptr_t) noexcept
: _Function_base() { }
/** /**
* @brief %Function copy constructor. * @brief %Function copy constructor.
...@@ -2050,7 +2052,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2050,7 +2052,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
/// @overload /// @overload
template<typename _Functor> template<typename _Functor>
typename enable_if<!is_integral<_Functor>::value, function&>::type typename enable_if<!is_integral<_Functor>::value, function&>::type
operator=(reference_wrapper<_Functor> __f) operator=(reference_wrapper<_Functor> __f) noexcept
{ {
function(__f).swap(*this); function(__f).swap(*this);
return *this; return *this;
...@@ -2093,7 +2095,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2093,7 +2095,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
* *
* This function will not throw an %exception. * This function will not throw an %exception.
*/ */
explicit operator bool() const explicit operator bool() const noexcept
{ return !_M_empty(); } { return !_M_empty(); }
// [3.7.2.4] function invocation // [3.7.2.4] function invocation
...@@ -2119,7 +2121,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2119,7 +2121,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
* *
* This function will not throw an %exception. * This function will not throw an %exception.
*/ */
const type_info& target_type() const; const type_info& target_type() const noexcept;
/** /**
* @brief Access the stored target function object. * @brief Access the stored target function object.
...@@ -2130,10 +2132,10 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2130,10 +2132,10 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
* *
* This function will not throw an %exception. * This function will not throw an %exception.
*/ */
template<typename _Functor> _Functor* target(); template<typename _Functor> _Functor* target() noexcept;
/// @overload /// @overload
template<typename _Functor> const _Functor* target() const; template<typename _Functor> const _Functor* target() const noexcept;
#endif #endif
private: private:
...@@ -2187,7 +2189,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2187,7 +2189,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
template<typename _Res, typename... _ArgTypes> template<typename _Res, typename... _ArgTypes>
const type_info& const type_info&
function<_Res(_ArgTypes...)>:: function<_Res(_ArgTypes...)>::
target_type() const target_type() const noexcept
{ {
if (_M_manager) if (_M_manager)
{ {
...@@ -2203,7 +2205,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2203,7 +2205,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
template<typename _Functor> template<typename _Functor>
_Functor* _Functor*
function<_Res(_ArgTypes...)>:: function<_Res(_ArgTypes...)>::
target() target() noexcept
{ {
if (typeid(_Functor) == target_type() && _M_manager) if (typeid(_Functor) == target_type() && _M_manager)
{ {
...@@ -2222,7 +2224,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2222,7 +2224,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
template<typename _Functor> template<typename _Functor>
const _Functor* const _Functor*
function<_Res(_ArgTypes...)>:: function<_Res(_ArgTypes...)>::
target() const target() const noexcept
{ {
if (typeid(_Functor) == target_type() && _M_manager) if (typeid(_Functor) == target_type() && _M_manager)
{ {
...@@ -2246,13 +2248,13 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2246,13 +2248,13 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
*/ */
template<typename _Res, typename... _Args> template<typename _Res, typename... _Args>
inline bool inline bool
operator==(const function<_Res(_Args...)>& __f, nullptr_t) operator==(const function<_Res(_Args...)>& __f, nullptr_t) noexcept
{ return !static_cast<bool>(__f); } { return !static_cast<bool>(__f); }
/// @overload /// @overload
template<typename _Res, typename... _Args> template<typename _Res, typename... _Args>
inline bool inline bool
operator==(nullptr_t, const function<_Res(_Args...)>& __f) operator==(nullptr_t, const function<_Res(_Args...)>& __f) noexcept
{ return !static_cast<bool>(__f); } { return !static_cast<bool>(__f); }
/** /**
...@@ -2264,13 +2266,13 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2264,13 +2266,13 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
*/ */
template<typename _Res, typename... _Args> template<typename _Res, typename... _Args>
inline bool inline bool
operator!=(const function<_Res(_Args...)>& __f, nullptr_t) operator!=(const function<_Res(_Args...)>& __f, nullptr_t) noexcept
{ return static_cast<bool>(__f); } { return static_cast<bool>(__f); }
/// @overload /// @overload
template<typename _Res, typename... _Args> template<typename _Res, typename... _Args>
inline bool inline bool
operator!=(nullptr_t, const function<_Res(_Args...)>& __f) operator!=(nullptr_t, const function<_Res(_Args...)>& __f) noexcept
{ return static_cast<bool>(__f); } { return static_cast<bool>(__f); }
// [20.7.15.2.7] specialized algorithms // [20.7.15.2.7] specialized algorithms
......
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