summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/unique_ptr.h
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-06 00:11:57 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-06 00:11:57 +0000
commite50a7faac600da70a5486a897460349160cec62e (patch)
tree68897208905b15c8ebef7fedfd4db48f0bbfa56e /libstdc++-v3/include/bits/unique_ptr.h
parent567123633cde83d84b94e0051ac8668c03a33104 (diff)
downloadgcc-e50a7faac600da70a5486a897460349160cec62e.tar.gz
2010-11-05 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (shared_ptr<>::__shared_ptr(), shared_ptr<>::shared_ptr(nullptr_t), weak_ptr<>::weak_ptr(), enable_shared_from_this::enable_shared_from_this()): Add constexpr specifier. * include/bits/shared_ptr_base.h (__shared_count::__shared_count(), __shared_count::__shared_count(), __shared_ptr<>::__shared_ptr(), __shared_ptr<>::__shared_ptr(nullptr_t), __weak_ptr<>::__weak_ptr(), __enable_shared_from_this::__enable_shared_from_this()): Likewise. * include/bits/unique_ptr.h (default_delete, unique_ptr<>::unique_ptr(), unique_ptr<>::unique_ptr(nullptr_t)): Likewise. * testsuite/20_util/default_delete/cons/constexpr.cc: Do not xfail. * testsuite/20_util/shared_ptr/cons/constexpr.cc: Remove, the test cannot work for a non-literal type like std::shared_ptr. * testsuite/20_util/weak_ptr/cons/constexpr.cc: Likewise. * testsuite/util/testsuite_common_types.h: Add comments. * testsuite/20_util/unique_ptr/cons/constexpr.cc: Likewise. * testsuite/20_util/shared_ptr/cons/43820.cc: Adjust dg-error line numbers. * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166386 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits/unique_ptr.h')
-rw-r--r--libstdc++-v3/include/bits/unique_ptr.h36
1 files changed, 19 insertions, 17 deletions
diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h
index ebbc521873a..4dc4dddb28e 100644
--- a/libstdc++-v3/include/bits/unique_ptr.h
+++ b/libstdc++-v3/include/bits/unique_ptr.h
@@ -46,20 +46,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// Primary template, default_delete.
template<typename _Tp>
struct default_delete
- {
- default_delete() { }
+ {
+ constexpr default_delete() { }
- template<typename _Up, typename = typename
- std::enable_if<std::is_convertible<_Up*, _Tp*>::value>::type>
- default_delete(const default_delete<_Up>&) { }
+ template<typename _Up, typename = typename
+ std::enable_if<std::is_convertible<_Up*, _Tp*>::value>::type>
+ default_delete(const default_delete<_Up>&) { }
- void
- operator()(_Tp* __ptr) const
- {
- static_assert(sizeof(_Tp)>0,
- "can't delete pointer to incomplete type");
- delete __ptr;
- }
+ void
+ operator()(_Tp* __ptr) const
+ {
+ static_assert(sizeof(_Tp)>0,
+ "can't delete pointer to incomplete type");
+ delete __ptr;
+ }
};
// _GLIBCXX_RESOLVE_LIB_DEFECTS
@@ -68,6 +68,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp>
struct default_delete<_Tp[]>
{
+ constexpr default_delete() { }
+
void
operator()(_Tp* __ptr) const
{
@@ -108,8 +110,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
"constructed with null function pointer deleter");
// Constructors.
- unique_ptr()
- : _M_t(pointer(), deleter_type())
+ constexpr unique_ptr()
+ : _M_t()
{ }
explicit
@@ -129,7 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ static_assert(!std::is_reference<deleter_type>::value,
"rvalue deleter bound to reference"); }
- unique_ptr(nullptr_t)
+ constexpr unique_ptr(nullptr_t)
: _M_t(pointer(), deleter_type())
{ }
@@ -271,7 +273,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
"constructed with null function pointer deleter");
// Constructors.
- unique_ptr()
+ constexpr unique_ptr()
: _M_t(pointer(), deleter_type())
{ }
@@ -292,7 +294,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
"rvalue deleter bound to reference"); }
/* TODO: use delegating constructor */
- unique_ptr(nullptr_t)
+ constexpr unique_ptr(nullptr_t)
: _M_t(pointer(), deleter_type())
{ }