Commit 5d861bf2 by Paolo Carlini Committed by Paolo Carlini

initializer_list: Use noexcept specifier.

2011-05-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* libsupc++/initializer_list: Use noexcept specifier.
	(initializer_list<>::size, begin, end): Qualify as const.
	* include/bits/move.h (__addressof, forward, move, addressof): Specify
	as noexcept.
	* include/std/bitset: Use noexcept specifier throughout.
	* include/debug/bitset: Update.
	* include/profile/bitset: Likewise.

From-SVN: r173871
parent 0bda47a3
2011-05-18 Paolo Carlini <paolo.carlini@oracle.com>
* libsupc++/initializer_list: Use noexcept specifier.
(initializer_list<>::size, begin, end): Qualify as const.
* include/bits/move.h (__addressof, forward, move, addressof): Specify
as noexcept.
* include/std/bitset: Use noexcept specifier throughout.
* include/debug/bitset: Update.
* include/profile/bitset: Likewise.
2011-05-17 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/tuple: Use noexcept where appropriate.
......
......@@ -40,7 +40,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Used, in C++03 mode too, by allocators, etc.
template<typename _Tp>
inline _Tp*
__addressof(_Tp& __r)
__addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
{
return reinterpret_cast<_Tp*>
(&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
......@@ -59,12 +59,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// forward (as per N3143)
template<typename _Tp>
inline _Tp&&
forward(typename std::remove_reference<_Tp>::type& __t)
forward(typename std::remove_reference<_Tp>::type& __t) noexcept
{ return static_cast<_Tp&&>(__t); }
template<typename _Tp>
inline _Tp&&
forward(typename std::remove_reference<_Tp>::type&& __t)
forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
{
static_assert(!std::is_lvalue_reference<_Tp>::value, "template argument"
" substituting _Tp is an lvalue reference type");
......@@ -79,7 +79,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<typename _Tp>
inline typename std::remove_reference<_Tp>::type&&
move(_Tp&& __t)
move(_Tp&& __t) noexcept
{ return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
/**
......@@ -108,7 +108,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<typename _Tp>
inline _Tp*
addressof(_Tp& __r)
addressof(_Tp& __r) noexcept
{ return std::__addressof(__r); }
_GLIBCXX_END_NAMESPACE_VERSION
......@@ -135,6 +135,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
inline void
swap(_Tp& __a, _Tp& __b)
// noexcept has to wait is_nothrow_move_assignable
{
// concept requirements
__glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
......@@ -149,6 +150,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, size_t _Nm>
inline void
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
// noexcept waits for c++/49045
{
for (size_t __n = 0; __n < _Nm; ++__n)
swap(__a[__n], __b[__n]);
......
// Debugging bitset implementation -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -66,19 +66,19 @@ namespace __debug
reference();
reference(const _Base_ref& __base,
bitset* __seq __attribute__((__unused__)))
bitset* __seq __attribute__((__unused__))) _GLIBCXX_NOEXCEPT
: _Base_ref(__base)
, _Safe_iterator_base(__seq, false)
{ }
public:
reference(const reference& __x)
reference(const reference& __x) _GLIBCXX_NOEXCEPT
: _Base_ref(__x)
, _Safe_iterator_base(__x, false)
{ }
reference&
operator=(bool __x)
operator=(bool __x) _GLIBCXX_NOEXCEPT
{
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_write)
......@@ -88,7 +88,7 @@ namespace __debug
}
reference&
operator=(const reference& __x)
operator=(const reference& __x) _GLIBCXX_NOEXCEPT
{
_GLIBCXX_DEBUG_VERIFY(! __x._M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_read)
......@@ -101,7 +101,7 @@ namespace __debug
}
bool
operator~() const
operator~() const _GLIBCXX_NOEXCEPT
{
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_read)
......@@ -109,7 +109,7 @@ namespace __debug
return ~(*static_cast<const _Base_ref*>(this));
}
operator bool() const
operator bool() const _GLIBCXX_NOEXCEPT
{
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_read)
......@@ -118,7 +118,7 @@ namespace __debug
}
reference&
flip()
flip() _GLIBCXX_NOEXCEPT
{
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_flip)
......@@ -130,10 +130,11 @@ namespace __debug
#endif
// 23.3.5.1 constructors:
_GLIBCXX_CONSTEXPR bitset() : _Base() { }
_GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT
: _Base() { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
constexpr bitset(unsigned long long __val)
constexpr bitset(unsigned long long __val) noexcept
#else
bitset(unsigned long __val)
#endif
......@@ -173,42 +174,42 @@ namespace __debug
// 23.3.5.2 bitset operations:
bitset<_Nb>&
operator&=(const bitset<_Nb>& __rhs)
operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
_M_base() &= __rhs;
return *this;
}
bitset<_Nb>&
operator|=(const bitset<_Nb>& __rhs)
operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
_M_base() |= __rhs;
return *this;
}
bitset<_Nb>&
operator^=(const bitset<_Nb>& __rhs)
operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
_M_base() ^= __rhs;
return *this;
}
bitset<_Nb>&
operator<<=(size_t __pos)
operator<<=(size_t __pos) _GLIBCXX_NOEXCEPT
{
_M_base() <<= __pos;
return *this;
}
bitset<_Nb>&
operator>>=(size_t __pos)
operator>>=(size_t __pos) _GLIBCXX_NOEXCEPT
{
_M_base() >>= __pos;
return *this;
}
bitset<_Nb>&
set()
set() _GLIBCXX_NOEXCEPT
{
_Base::set();
return *this;
......@@ -224,7 +225,7 @@ namespace __debug
}
bitset<_Nb>&
reset()
reset() _GLIBCXX_NOEXCEPT
{
_Base::reset();
return *this;
......@@ -237,10 +238,12 @@ namespace __debug
return *this;
}
bitset<_Nb> operator~() const { return bitset(~_M_base()); }
bitset<_Nb>
operator~() const _GLIBCXX_NOEXCEPT
{ return bitset(~_M_base()); }
bitset<_Nb>&
flip()
flip() _GLIBCXX_NOEXCEPT
{
_Base::flip();
return *this;
......@@ -346,11 +349,11 @@ namespace __debug
using _Base::size;
bool
operator==(const bitset<_Nb>& __rhs) const
operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return _M_base() == __rhs; }
bool
operator!=(const bitset<_Nb>& __rhs) const
operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return _M_base() != __rhs; }
using _Base::test;
......@@ -359,33 +362,35 @@ namespace __debug
using _Base::none;
bitset<_Nb>
operator<<(size_t __pos) const
operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(_M_base() << __pos); }
bitset<_Nb>
operator>>(size_t __pos) const
operator>>(size_t __pos) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(_M_base() >> __pos); }
_Base&
_M_base() { return *this; }
_Base&
_M_base() _GLIBCXX_NOEXCEPT
{ return *this; }
const _Base&
_M_base() const { return *this; }
_M_base() const _GLIBCXX_NOEXCEPT
{ return *this; }
};
template<size_t _Nb>
bitset<_Nb>
operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(__x) &= __y; }
template<size_t _Nb>
bitset<_Nb>
operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(__x) |= __y; }
template<size_t _Nb>
bitset<_Nb>
operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(__x) ^= __y; }
template<typename _CharT, typename _Traits, size_t _Nb>
......
// Profiling bitset implementation -*- C++ -*-
// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
//
// 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
......@@ -52,42 +52,42 @@ namespace __profile
friend class bitset;
reference();
reference(const _Base_ref& __base, bitset* __seq)
reference(const _Base_ref& __base, bitset* __seq) _GLIBCXX_NOEXCEPT
: _Base_ref(__base)
{ }
public:
reference(const reference& __x)
reference(const reference& __x) _GLIBCXX_NOEXCEPT
: _Base_ref(__x)
{ }
reference&
operator=(bool __x)
operator=(bool __x) _GLIBCXX_NOEXCEPT
{
*static_cast<_Base_ref*>(this) = __x;
return *this;
}
reference&
operator=(const reference& __x)
operator=(const reference& __x) _GLIBCXX_NOEXCEPT
{
*static_cast<_Base_ref*>(this) = __x;
return *this;
}
bool
operator~() const
operator~() const _GLIBCXX_NOEXCEPT
{
return ~(*static_cast<const _Base_ref*>(this));
}
operator bool() const
operator bool() const _GLIBCXX_NOEXCEPT
{
return *static_cast<const _Base_ref*>(this);
}
reference&
flip()
flip() _GLIBCXX_NOEXCEPT
{
_Base_ref::flip();
return *this;
......@@ -95,10 +95,11 @@ namespace __profile
};
// 23.3.5.1 constructors:
_GLIBCXX_CONSTEXPR bitset() : _Base() { }
_GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT
: _Base() { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
constexpr bitset(unsigned long long __val)
constexpr bitset(unsigned long long __val) noexcept
#else
bitset(unsigned long __val)
#endif
......@@ -138,42 +139,42 @@ namespace __profile
// 23.3.5.2 bitset operations:
bitset<_Nb>&
operator&=(const bitset<_Nb>& __rhs)
operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
_M_base() &= __rhs;
return *this;
}
bitset<_Nb>&
operator|=(const bitset<_Nb>& __rhs)
operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
_M_base() |= __rhs;
return *this;
}
bitset<_Nb>&
operator^=(const bitset<_Nb>& __rhs)
operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
_M_base() ^= __rhs;
return *this;
}
bitset<_Nb>&
operator<<=(size_t __pos)
operator<<=(size_t __pos) _GLIBCXX_NOEXCEPT
{
_M_base() <<= __pos;
return *this;
}
bitset<_Nb>&
operator>>=(size_t __pos)
operator>>=(size_t __pos) _GLIBCXX_NOEXCEPT
{
_M_base() >>= __pos;
return *this;
}
bitset<_Nb>&
set()
set() _GLIBCXX_NOEXCEPT
{
_Base::set();
return *this;
......@@ -189,7 +190,7 @@ namespace __profile
}
bitset<_Nb>&
reset()
reset() _GLIBCXX_NOEXCEPT
{
_Base::reset();
return *this;
......@@ -202,10 +203,12 @@ namespace __profile
return *this;
}
bitset<_Nb> operator~() const { return bitset(~_M_base()); }
bitset<_Nb>
operator~() const _GLIBCXX_NOEXCEPT
{ return bitset(~_M_base()); }
bitset<_Nb>&
flip()
flip() _GLIBCXX_NOEXCEPT
{
_Base::flip();
return *this;
......@@ -305,11 +308,11 @@ namespace __profile
using _Base::size;
bool
operator==(const bitset<_Nb>& __rhs) const
operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return _M_base() == __rhs; }
bool
operator!=(const bitset<_Nb>& __rhs) const
operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return _M_base() != __rhs; }
using _Base::test;
......@@ -318,33 +321,35 @@ namespace __profile
using _Base::none;
bitset<_Nb>
operator<<(size_t __pos) const
operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(_M_base() << __pos); }
bitset<_Nb>
operator>>(size_t __pos) const
operator>>(size_t __pos) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(_M_base() >> __pos); }
_Base&
_M_base() { return *this; }
_M_base() _GLIBCXX_NOEXCEPT
{ return *this; }
const _Base&
_M_base() const { return *this; }
_M_base() const _GLIBCXX_NOEXCEPT
{ return *this; }
};
template<size_t _Nb>
bitset<_Nb>
operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(__x) &= __y; }
template<size_t _Nb>
bitset<_Nb>
operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(__x) |= __y; }
template<size_t _Nb>
bitset<_Nb>
operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(__x) ^= __y; }
template<typename _CharT, typename _Traits, size_t _Nb>
......
// std::initializer_list support -*- C++ -*-
// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
......@@ -61,19 +61,20 @@ namespace std
: _M_array(__a), _M_len(__l) { }
public:
constexpr initializer_list() : _M_array(0), _M_len(0) { }
constexpr initializer_list() noexcept
: _M_array(0), _M_len(0) { }
// Number of elements.
constexpr size_type
size() { return _M_len; }
size() const noexcept { return _M_len; }
// First element.
constexpr const_iterator
begin() { return _M_array; }
begin() const noexcept { return _M_array; }
// One past the last element.
constexpr const_iterator
end() { return begin() + size(); }
end() const noexcept { return begin() + size(); }
};
/**
......@@ -83,7 +84,7 @@ namespace std
*/
template<class _Tp>
constexpr const _Tp*
begin(initializer_list<_Tp> __ils)
begin(initializer_list<_Tp> __ils) noexcept
{ return __ils.begin(); }
/**
......@@ -93,7 +94,7 @@ namespace std
*/
template<class _Tp>
constexpr const _Tp*
end(initializer_list<_Tp> __ils)
end(initializer_list<_Tp> __ils) noexcept
{ return __ils.end(); }
}
......
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