Commit 3be9ded2 by Jonathan Wakely Committed by Jonathan Wakely

LWG 3035. std::allocator's constructors should be constexpr

	LWG 3035. std::allocator's constructors should be constexpr
	* include/bits/allocator.h (allocator): Add constexpr to constructors
	for C++2a. Replace dynamic exception specifications with NOTHROW
	macro.
	(allocator, operator==, operator!=): Replace USE_NOEXCEPT macro with
	NOTHROW.
	* include/bits/c++config (_GLIBCXX20_CONSTEXPR): Define.
	* include/ext/malloc_allocator.h (malloc_allocator): Add constexpr
	to constructors for C++2a.
	* include/ext/new_allocator.h (new_allocator): Likewise.

From-SVN: r261703
parent 9a977ce3
2018-06-18 Jonathan Wakely <jwakely@redhat.com>
LWG 3035. std::allocator's constructors should be constexpr
* include/bits/allocator.h (allocator): Add constexpr to constructors
for C++2a. Replace dynamic exception specifications with NOTHROW
macro.
(allocator, operator==, operator!=): Replace USE_NOEXCEPT macro with
NOTHROW.
* include/bits/c++config (_GLIBCXX20_CONSTEXPR): Define.
* include/ext/malloc_allocator.h (malloc_allocator): Add constexpr
to constructors for C++2a.
* include/ext/new_allocator.h (new_allocator): Likewise.
2018-06-16 Jonathan Wakely <jwakely@redhat.com> 2018-06-16 Jonathan Wakely <jwakely@redhat.com>
LWG 3076 basic_string CTAD ambiguity LWG 3076 basic_string CTAD ambiguity
......
...@@ -128,19 +128,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -128,19 +128,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef true_type is_always_equal; typedef true_type is_always_equal;
#endif #endif
allocator() throw() { } // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 3035. std::allocator's constructors should be constexpr
_GLIBCXX20_CONSTEXPR
allocator() _GLIBCXX_NOTHROW { }
allocator(const allocator& __a) throw() _GLIBCXX20_CONSTEXPR
allocator(const allocator& __a) _GLIBCXX_NOTHROW
: __allocator_base<_Tp>(__a) { } : __allocator_base<_Tp>(__a) { }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
// Avoid implicit deprecation. // Avoid implicit deprecation.
allocator& operator=(const allocator&) = default; allocator& operator=(const allocator&) = default;
#endif #endif
template<typename _Tp1> template<typename _Tp1>
allocator(const allocator<_Tp1>&) throw() { } _GLIBCXX20_CONSTEXPR
allocator(const allocator<_Tp1>&) _GLIBCXX_NOTHROW { }
~allocator() throw() { } ~allocator() _GLIBCXX_NOTHROW { }
// Inherit everything else. // Inherit everything else.
}; };
...@@ -148,25 +154,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -148,25 +154,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _T1, typename _T2> template<typename _T1, typename _T2>
inline bool inline bool
operator==(const allocator<_T1>&, const allocator<_T2>&) operator==(const allocator<_T1>&, const allocator<_T2>&)
_GLIBCXX_USE_NOEXCEPT _GLIBCXX_NOTHROW
{ return true; } { return true; }
template<typename _Tp> template<typename _Tp>
inline bool inline bool
operator==(const allocator<_Tp>&, const allocator<_Tp>&) operator==(const allocator<_Tp>&, const allocator<_Tp>&)
_GLIBCXX_USE_NOEXCEPT _GLIBCXX_NOTHROW
{ return true; } { return true; }
template<typename _T1, typename _T2> template<typename _T1, typename _T2>
inline bool inline bool
operator!=(const allocator<_T1>&, const allocator<_T2>&) operator!=(const allocator<_T1>&, const allocator<_T2>&)
_GLIBCXX_USE_NOEXCEPT _GLIBCXX_NOTHROW
{ return false; } { return false; }
template<typename _Tp> template<typename _Tp>
inline bool inline bool
operator!=(const allocator<_Tp>&, const allocator<_Tp>&) operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
_GLIBCXX_USE_NOEXCEPT _GLIBCXX_NOTHROW
{ return false; } { return false; }
// Invalid allocator<cv T> partial specializations. // Invalid allocator<cv T> partial specializations.
......
...@@ -122,15 +122,23 @@ ...@@ -122,15 +122,23 @@
#endif #endif
#ifndef _GLIBCXX17_CONSTEXPR #ifndef _GLIBCXX17_CONSTEXPR
# if __cplusplus > 201402L # if __cplusplus >= 201703L
# define _GLIBCXX17_CONSTEXPR constexpr # define _GLIBCXX17_CONSTEXPR constexpr
# else # else
# define _GLIBCXX17_CONSTEXPR # define _GLIBCXX17_CONSTEXPR
# endif # endif
#endif #endif
#ifndef _GLIBCXX20_CONSTEXPR
# if __cplusplus > 201703L
# define _GLIBCXX20_CONSTEXPR constexpr
# else
# define _GLIBCXX20_CONSTEXPR
# endif
#endif
#ifndef _GLIBCXX17_INLINE #ifndef _GLIBCXX17_INLINE
# if __cplusplus > 201402L # if __cplusplus >= 201703L
# define _GLIBCXX17_INLINE inline # define _GLIBCXX17_INLINE inline
# else # else
# define _GLIBCXX17_INLINE # define _GLIBCXX17_INLINE
......
...@@ -75,11 +75,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -75,11 +75,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef std::true_type propagate_on_container_move_assignment; typedef std::true_type propagate_on_container_move_assignment;
#endif #endif
_GLIBCXX20_CONSTEXPR
malloc_allocator() _GLIBCXX_USE_NOEXCEPT { } malloc_allocator() _GLIBCXX_USE_NOEXCEPT { }
_GLIBCXX20_CONSTEXPR
malloc_allocator(const malloc_allocator&) _GLIBCXX_USE_NOEXCEPT { } malloc_allocator(const malloc_allocator&) _GLIBCXX_USE_NOEXCEPT { }
template<typename _Tp1> template<typename _Tp1>
_GLIBCXX20_CONSTEXPR
malloc_allocator(const malloc_allocator<_Tp1>&) malloc_allocator(const malloc_allocator<_Tp1>&)
_GLIBCXX_USE_NOEXCEPT { } _GLIBCXX_USE_NOEXCEPT { }
......
...@@ -76,11 +76,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -76,11 +76,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef std::true_type propagate_on_container_move_assignment; typedef std::true_type propagate_on_container_move_assignment;
#endif #endif
_GLIBCXX20_CONSTEXPR
new_allocator() _GLIBCXX_USE_NOEXCEPT { } new_allocator() _GLIBCXX_USE_NOEXCEPT { }
_GLIBCXX20_CONSTEXPR
new_allocator(const new_allocator&) _GLIBCXX_USE_NOEXCEPT { } new_allocator(const new_allocator&) _GLIBCXX_USE_NOEXCEPT { }
template<typename _Tp1> template<typename _Tp1>
_GLIBCXX20_CONSTEXPR
new_allocator(const new_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { } new_allocator(const new_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { }
~new_allocator() _GLIBCXX_USE_NOEXCEPT { } ~new_allocator() _GLIBCXX_USE_NOEXCEPT { }
......
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