Implement LWG3035: std::allocator's constructors should be constexpr.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@328059 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -126,9 +126,10 @@ public:
|
|||||||
|
|
||||||
template <class U> struct rebind {typedef allocator<U> other;};
|
template <class U> struct rebind {typedef allocator<U> other;};
|
||||||
|
|
||||||
allocator() noexcept;
|
constexpr allocator() noexcept; // constexpr in C++20
|
||||||
allocator(const allocator&) noexcept;
|
constexpr allocator(const allocator&) noexcept; // constexpr in C++20
|
||||||
template <class U> allocator(const allocator<U>&) noexcept;
|
template <class U>
|
||||||
|
constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20
|
||||||
~allocator();
|
~allocator();
|
||||||
pointer address(reference x) const noexcept;
|
pointer address(reference x) const noexcept;
|
||||||
const_pointer address(const_reference x) const noexcept;
|
const_pointer address(const_reference x) const noexcept;
|
||||||
@@ -1778,8 +1779,13 @@ public:
|
|||||||
|
|
||||||
template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {}
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||||
template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {}
|
allocator() _NOEXCEPT {}
|
||||||
|
|
||||||
|
template <class _Up>
|
||||||
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||||
|
allocator(const allocator<_Up>&) _NOEXCEPT {}
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT
|
_LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT
|
||||||
{return _VSTD::addressof(__x);}
|
{return _VSTD::addressof(__x);}
|
||||||
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
||||||
@@ -1877,8 +1883,13 @@ public:
|
|||||||
|
|
||||||
template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {}
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||||
template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {}
|
allocator() _NOEXCEPT {}
|
||||||
|
|
||||||
|
template <class _Up>
|
||||||
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||||
|
allocator(const allocator<_Up>&) _NOEXCEPT {}
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
||||||
{return _VSTD::addressof(__x);}
|
{return _VSTD::addressof(__x);}
|
||||||
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
|
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// <memory>
|
||||||
|
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||||
|
//
|
||||||
|
// template <class T>
|
||||||
|
// class allocator
|
||||||
|
// {
|
||||||
|
// public: // All of these are constexpr after C++17
|
||||||
|
// constexpr allocator() noexcept;
|
||||||
|
// constexpr allocator(const allocator&) noexcept;
|
||||||
|
// template<class U> constexpr allocator(const allocator<U>&) noexcept;
|
||||||
|
// ...
|
||||||
|
// };
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
typedef std::allocator<char> AC;
|
||||||
|
typedef std::allocator<long> AL;
|
||||||
|
|
||||||
|
constexpr AC a1;
|
||||||
|
constexpr AC a2{a1};
|
||||||
|
constexpr AL a3{a2};
|
||||||
|
(void) a3;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef std::allocator<const char> AC;
|
||||||
|
typedef std::allocator<const long> AL;
|
||||||
|
|
||||||
|
constexpr AC a1;
|
||||||
|
constexpr AC a2{a1};
|
||||||
|
constexpr AL a3{a2};
|
||||||
|
(void) a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user