summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog77
-rw-r--r--libstdc++-v3/doc/html/manual/status.html4
-rw-r--r--libstdc++-v3/doc/xml/manual/status_cxx2017.xml3
-rw-r--r--libstdc++-v3/include/bits/move.h5
-rw-r--r--libstdc++-v3/include/bits/shared_ptr.h14
-rw-r--r--libstdc++-v3/include/bits/shared_ptr_base.h224
-rw-r--r--libstdc++-v3/include/experimental/bits/shared_ptr.h666
-rw-r--r--libstdc++-v3/include/experimental/memory_resource1
-rw-r--r--libstdc++-v3/include/std/future35
-rw-r--r--libstdc++-v3/include/std/string_view30
-rw-r--r--libstdc++-v3/src/filesystem/ops.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/cons/array.cc273
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc17
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/observers/array.cc73
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/literals/types.cc45
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/literals/values.cc72
-rw-r--r--libstdc++-v3/testsuite/30_threads/future/requirements/explicit_instantiation.cc11
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc11
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc11
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc11
-rw-r--r--libstdc++-v3/testsuite/experimental/string_view/literals/values.cc28
-rw-r--r--libstdc++-v3/testsuite/ext/numeric_traits/numeric_traits.cc7
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc9
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc9
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/2.cc7
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc9
-rw-r--r--libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/2.cc9
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/hash/requirements/explicit_instantiation.cc36
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc8
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc8
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc8
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc14
34 files changed, 948 insertions, 793 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index e1a4764afd7..57a7be64b84 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,80 @@
+2016-11-14 Jonathan Wakely <jwakely@redhat.com>
+
+ * include/bits/move.h (addressof(const _Tp&&)): Add deleted overload,
+ as per LWG 2598.
+
+ * include/std/future (future::share(), future<R&>::share())
+ (future<void>::share()): Add noexcept, as per LWG 2556.
+
+2016-11-13 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/78326
+ * include/experimental/memory_resource (memory_resource::_S_max_align):
+ Change access to protected.
+
+ * doc/xml/manual/status_cxx2017.xml: Update status.
+ * doc/html/manual/status.html: Regenerate.
+ * include/bits/shared_ptr.h (shared_ptr(unique_ptr<_Yp, _Del>)): Add
+ extension constructor to maintain C++14 behaviour.
+ * include/bits/shared_ptr_base.h (__sp_array_delete): Add new struct.
+ (__shared_count(_Ptr, false_type), __shared_count(_Ptr, true_type)):
+ New constructors.
+ (__sp_compatible_with, __sp_is_constructible): Add specializations
+ for array support.
+ (__sp_is_constructible_arr, __sp_is_constructible_arrN): New helpers.
+ (__shared_ptr_access): New base class for observer member functions.
+ (__shared_ptr::element_type): Use remove_extent.
+ (__shared_ptr::_UniqCompatible): Add __sp_compatible_with check.
+ (__shared_ptr(_Yp*)): Use tag dispatching to call new __shared_count
+ constructor.
+ (__shared_ptr(unique_ptr<_Yp, _Del>)): Add extension constructor.
+ (__shared_ptr::operator*, __shared_ptr::operator->): Remove and
+ inherit from __shared_ptr_access base class.
+ (__shared_ptr::__has_esft_base): Return false for array types.
+ (__weak_ptr::element_type): Use remove_extent.
+ * include/experimental/bits/shared_ptr.h (__libfund_v1): Remove.
+ (__shared_ptr<__libfund_v1<_Tp>>): Remove specializations.
+ (__wak_ptr<__libfund_v1<_Tp>>): Likewise.
+ (experimental::__sp_compatible_v): Redefine using
+ __sp_compatible_with.
+ (experimental::__sp_is_constructible_v): Redefine using
+ __sp_is_constructible.
+ (get_deleter, operator<<): Change argument from __shared_ptr to
+ shared_ptr.
+ * testsuite/20_util/shared_ptr/cons/array.cc: New test.
+ * testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc: Adjust for
+ new behaviour.
+ * testsuite/20_util/shared_ptr/observers/array.cc: Test observers for
+ arrays.
+ * testsuite/20_util/shared_ptr/observers/array_neg.cc: New test.
+
+2016-11-13 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ Implement P0403R1, Literal suffixes for basic_string_view.
+ * include/std/string_view
+ (operator""sv(const char*, size_t)): New.
+ (operator""sv(const wchar_t*, size_t)): Likewise.
+ (operator""sv(const char16_t*, size_t)): Likewise.
+ (operator""sv(const char32_t*, size_t)): Likewise.
+ * testsuite/21_strings/basic_string_view/literals/types.cc: New.
+ * testsuite/21_strings/basic_string_view/literals/values.cc: Likewise.
+ * testsuite/experimental/string_view/literals/values.cc: Add
+ tests for literals with embedded NULs.
+
+2016-11-12 Jonathan Wakely <jwakely@redhat.com>
+
+ * src/filesystem/ops.cc (is_empty): Fix typo in exception message.
+
+ * include/std/future (future_error): Fix public typo to private.
+
+2016-11-11 Jonathan Wakely <jwakely@redhat.com>
+
+ * include/std/future (future_error): Make existing constructor
+ private and add constructor from future_errc.
+
+ * include/bits/shared_ptr.h (hash<shared_ptr<T>>): Use element_type.
+ * include/bits/shared_ptr_base.h (hash<__shared_ptr<T, L>>): Likewise.
+
2016-11-10 François Dumont <fdumont@gcc.gnu.org>
* src/c++11/debug.cc (format_word): Delete.
diff --git a/libstdc++-v3/doc/html/manual/status.html b/libstdc++-v3/doc/html/manual/status.html
index 554d519a0a6..08c9ad06dea 100644
--- a/libstdc++-v3/doc/html/manual/status.html
+++ b/libstdc++-v3/doc/html/manual/status.html
@@ -565,11 +565,11 @@ Feature-testing recommendations for C++</a>.
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0220r1.html" target="_top">
P0220R1
</a>
- </td><td align="center"> 7 </td><td align="left"> <code class="code">__cpp_lib_apply &gt;= 201603</code> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> Library Fundamentals V1 TS Components: <code class="code">shared_ptr&lt;T[]&gt;</code> </td><td align="left">
+ </td><td align="center"> 7 </td><td align="left"> <code class="code">__cpp_lib_apply &gt;= 201603</code> </td></tr><tr><td align="left"> Library Fundamentals V1 TS Components: <code class="code">shared_ptr&lt;T[]&gt;</code> </td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0220r1.html" target="_top">
P0220R1
</a>
- </td><td align="center"> No </td><td align="left"> <code class="code">__cpp_lib_shared_ptr_arrays &gt;= 201603</code> </td></tr><tr><td align="left"> Library Fundamentals V1 TS Components: Searchers </td><td align="left">
+ </td><td align="center"> 7 </td><td align="left"> <code class="code">__cpp_lib_shared_ptr_arrays &gt;= 201603</code> </td></tr><tr><td align="left"> Library Fundamentals V1 TS Components: Searchers </td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0220r1.html" target="_top">
P0220R1
</a>
diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
index d008bd9eb9b..dbb26c8f867 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
@@ -158,14 +158,13 @@ Feature-testing recommendations for C++</link>.
</row>
<row>
- <?dbhtml bgcolor="#C8B0B0" ?>
<entry> Library Fundamentals V1 TS Components: <code>shared_ptr&lt;T[]&gt;</code> </entry>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0220r1.html">
P0220R1
</link>
</entry>
- <entry align="center"> No </entry>
+ <entry align="center"> 7 </entry>
<entry> <code>__cpp_lib_shared_ptr_arrays >= 201603</code> </entry>
</row>
diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h
index a5002fca422..d0aefe76cf0 100644
--- a/libstdc++-v3/include/bits/move.h
+++ b/libstdc++-v3/include/bits/move.h
@@ -137,6 +137,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
addressof(_Tp& __r) noexcept
{ return std::__addressof(__r); }
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2598. addressof works on temporaries
+ template<typename _Tp>
+ const _Tp* addressof(const _Tp&&) = delete;
+
// C++11 version of std::exchange for internal use.
template <typename _Tp, typename _Up = _Tp>
inline _Tp
diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index 9f7a40c5e1e..cbe4144359e 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -277,6 +277,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
shared_ptr(unique_ptr<_Yp, _Del>&& __r)
: __shared_ptr<_Tp>(std::move(__r)) { }
+#if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED
+ // This non-standard constructor exists to support conversions that
+ // were possible in C++11 and C++14 but are ill-formed in C++17.
+ // If an exception is thrown this constructor has no effect.
+ template<typename _Yp, typename _Del,
+ _Constructible<unique_ptr<_Yp, _Del>, __sp_array_delete>* = 0>
+ shared_ptr(unique_ptr<_Yp, _Del>&& __r)
+ : __shared_ptr<_Tp>(std::move(__r), __sp_array_delete()) { }
+#endif
+
/**
* @brief Construct an empty %shared_ptr.
* @post use_count() == 0 && get() == nullptr
@@ -692,7 +702,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
size_t
operator()(const shared_ptr<_Tp>& __s) const noexcept
- { return std::hash<_Tp*>()(__s.get()); }
+ {
+ return std::hash<typename shared_ptr<_Tp>::element_type*>()(__s.get());
+ }
};
// @} group pointer_abstractions
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 1a9e3e901e9..953aa87436e 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -559,6 +559,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Impl _M_impl;
};
+ // The default deleter for shared_ptr<T[]> and shared_ptr<T[N]>.
+ struct __sp_array_delete
+ {
+ template<typename _Yp>
+ void operator()(_Yp* __p) const { delete[] __p; }
+ };
template<_Lock_policy _Lp>
class __shared_count
@@ -582,6 +588,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
}
+ template<typename _Ptr>
+ __shared_count(_Ptr __p, /* is_array = */ false_type)
+ : __shared_count(__p)
+ { }
+
+ template<typename _Ptr>
+ __shared_count(_Ptr __p, /* is_array = */ true_type)
+ : __shared_count(__p, __sp_array_delete{}, allocator<void>())
+ { }
+
template<typename _Ptr, typename _Deleter>
__shared_count(_Ptr __p, _Deleter __d)
: __shared_count(__p, std::move(__d), allocator<void>())
@@ -848,8 +864,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_pi = nullptr;
}
- // Helper traits for shared_ptr
+#define __cpp_lib_shared_ptr_arrays 201603
+
+ // Helper traits for shared_ptr of array:
+ // A pointer type Y* is said to be compatible with a pointer type T* when
+ // either Y* is convertible to T* or Y is U[N] and T is U cv [].
template<typename _Yp_ptr, typename _Tp_ptr>
struct __sp_compatible_with
: false_type
@@ -860,17 +880,161 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: is_convertible<_Yp*, _Tp*>::type
{ };
+ template<typename _Up, size_t _Nm>
+ struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]>
+ : true_type
+ { };
+
+ template<typename _Up, size_t _Nm>
+ struct __sp_compatible_with<_Up(*)[_Nm], const _Up(*)[]>
+ : true_type
+ { };
+
+ template<typename _Up, size_t _Nm>
+ struct __sp_compatible_with<_Up(*)[_Nm], volatile _Up(*)[]>
+ : true_type
+ { };
+
+ template<typename _Up, size_t _Nm>
+ struct __sp_compatible_with<_Up(*)[_Nm], const volatile _Up(*)[]>
+ : true_type
+ { };
+
+ // Test conversion from Y(*)[N] to U(*)[N] without forming invalid type Y[N].
+ template<typename _Up, size_t _Nm, typename _Yp, typename = void>
+ struct __sp_is_constructible_arrN
+ : false_type
+ { };
+
+ template<typename _Up, size_t _Nm, typename _Yp>
+ struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>>
+ : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type
+ { };
+
+ // Test conversion from Y(*)[] to U(*)[] without forming invalid type Y[].
+ template<typename _Up, typename _Yp, typename = void>
+ struct __sp_is_constructible_arr
+ : false_type
+ { };
+
+ template<typename _Up, typename _Yp>
+ struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>>
+ : is_convertible<_Yp(*)[], _Up(*)[]>::type
+ { };
+
+ // Trait to check if shared_ptr<T> can be constructed from Y*.
+ template<typename _Tp, typename _Yp>
+ struct __sp_is_constructible;
+
+ // When T is U[N], Y(*)[N] shall be convertible to T*;
+ template<typename _Up, size_t _Nm, typename _Yp>
+ struct __sp_is_constructible<_Up[_Nm], _Yp>
+ : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type
+ { };
+
+ // when T is U[], Y(*)[] shall be convertible to T*;
+ template<typename _Up, typename _Yp>
+ struct __sp_is_constructible<_Up[], _Yp>
+ : __sp_is_constructible_arr<_Up, _Yp>::type
+ { };
+
+ // otherwise, Y* shall be convertible to T*.
+ template<typename _Tp, typename _Yp>
+ struct __sp_is_constructible
+ : is_convertible<_Yp*, _Tp*>::type
+ { };
+
+
+ // Define operator* and operator-> for shared_ptr<T>.
+ template<typename _Tp, _Lock_policy _Lp,
+ bool = is_array<_Tp>::value, bool = is_void<_Tp>::value>
+ class __shared_ptr_access
+ {
+ public:
+ using element_type = _Tp;
+
+ element_type&
+ operator*() const noexcept
+ {
+ __glibcxx_assert(_M_get() != nullptr);
+ return *_M_get();
+ }
+
+ element_type*
+ operator->() const noexcept
+ {
+ _GLIBCXX_DEBUG_PEDASSERT(_M_get() != nullptr);
+ return _M_get();
+ }
+
+ private:
+ element_type*
+ _M_get() const noexcept
+ { return static_cast<const __shared_ptr<_Tp, _Lp>*>(this)->get(); }
+ };
+
+ // Define operator-> for shared_ptr<cv void>.
template<typename _Tp, _Lock_policy _Lp>
- class __shared_ptr
+ class __shared_ptr_access<_Tp, _Lp, false, true>
{
public:
using element_type = _Tp;
+ element_type*
+ operator->() const noexcept
+ {
+ _GLIBCXX_DEBUG_PEDASSERT(_M_get() != nullptr);
+ return static_cast<const __shared_ptr<_Tp, _Lp>*>(this)->get();
+ }
+ };
+
+ // Define operator[] for shared_ptr<T[]> and shared_ptr<T[N]>.
+ template<typename _Tp, _Lock_policy _Lp>
+ class __shared_ptr_access<_Tp, _Lp, true, false>
+ {
+ public:
+ using element_type = typename remove_extent<_Tp>::type;
+
+#if __cplusplus <= 201402L
+ [[__deprecated__("shared_ptr<T[]>::operator* is absent from C++17")]]
+ element_type&
+ operator*() const noexcept
+ {
+ __glibcxx_assert(_M_ptr != nullptr);
+ return *_M_get();
+ }
+
+ [[__deprecated__("shared_ptr<T[]>::operator-> is absent from C++17")]]
+ element_type*
+ operator->() const noexcept
+ {
+ _GLIBCXX_DEBUG_PEDASSERT(_M_get() != nullptr);
+ return _M_get();
+ }
+#endif
+
+ element_type&
+ operator[](ptrdiff_t __i) const
+ {
+ __glibcxx_assert(_M_get() != nullptr);
+ __glibcxx_assert(!extent<_Tp>::value || __i < extent<_Tp>::value);
+ return _M_get()[__i];
+ }
+
private:
- // Trait to check if shared_ptr<T> can be constructed from Y*.
- template<typename _Tp1, typename _Yp>
- using __sp_is_constructible = is_convertible<_Yp*, _Tp1*>;
+ element_type*
+ _M_get() const noexcept
+ { return static_cast<const __shared_ptr<_Tp, _Lp>*>(this)->get(); }
+ };
+
+ template<typename _Tp, _Lock_policy _Lp>
+ class __shared_ptr
+ : public __shared_ptr_access<_Tp, _Lp>
+ {
+ public:
+ using element_type = typename remove_extent<_Tp>::type;
+ private:
// Constraint for taking ownership of a pointer of type _Yp*:
template<typename _Yp>
using _SafeConv
@@ -888,9 +1052,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Constraint for construction from unique_ptr:
template<typename _Yp, typename _Del, typename _Res = void,
typename _Ptr = typename unique_ptr<_Yp, _Del>::pointer>
- using _UniqCompatible = typename enable_if<
- is_convertible<_Ptr, element_type*>::value
- , _Res>::type;
+ using _UniqCompatible = typename enable_if<__and_<
+ __sp_compatible_with<_Yp*, _Tp*>, is_convertible<_Ptr, element_type*>
+ >::value, _Res>::type;
// Constraint for assignment from unique_ptr:
template<typename _Yp, typename _Del>
@@ -909,7 +1073,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Yp, typename = _SafeConv<_Yp>>
explicit
__shared_ptr(_Yp* __p)
- : _M_ptr(__p), _M_refcount(__p)
+ : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type())
{
static_assert( !is_void<_Yp>::value, "incomplete type" );
static_assert( sizeof(_Yp) > 0, "incomplete type" );
@@ -995,6 +1159,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_enable_shared_from_this_with(__raw);
}
+#if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED
+ protected:
+ // If an exception is thrown this constructor has no effect.
+ template<typename _Tp1, typename _Del,
+ typename enable_if<__and_<
+ __not_<is_array<_Tp>>, is_array<_Tp1>,
+ is_convertible<typename unique_ptr<_Tp1, _Del>::pointer, _Tp*>
+ >::value, bool>::type = true>
+ __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete)
+ : _M_ptr(__r.get()), _M_refcount()
+ {
+ auto __raw = _S_raw_ptr(__r.get());
+ _M_refcount = __shared_count<_Lp>(std::move(__r));
+ _M_enable_shared_from_this_with(__raw);
+ }
+ public:
+#endif
+
#if _GLIBCXX_USE_DEPRECATED
// Postcondition: use_count() == 1 and __r.get() == 0
template<typename _Yp, typename = _Compatible<_Yp>>
@@ -1068,21 +1250,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
reset(_Yp* __p, _Deleter __d, _Alloc __a)
{ __shared_ptr(__p, __d, std::move(__a)).swap(*this); }
- // Allow class instantiation when _Tp is [cv-qual] void.
- typename std::add_lvalue_reference<element_type>::type
- operator*() const noexcept
- {
- __glibcxx_assert(_M_ptr != 0);
- return *_M_ptr;
- }
-
- element_type*
- operator->() const noexcept
- {
- _GLIBCXX_DEBUG_PEDASSERT(_M_ptr != 0);
- return _M_ptr;
- }
-
element_type*
get() const noexcept
{ return _M_ptr; }
@@ -1193,7 +1360,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Yp>
struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>>
- : true_type { };
+ : __not_<is_array<_Tp>> { }; // No enable shared_from_this for arrays
template<typename _Yp>
typename enable_if<__has_esft_base<_Yp>::value>::type
@@ -1428,7 +1595,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using _Assignable = _Compatible<_Yp, __weak_ptr&>;
public:
- using element_type = _Tp;
+ using element_type = typename remove_extent<_Tp>::type;
constexpr __weak_ptr() noexcept
: _M_ptr(nullptr), _M_refcount()
@@ -1681,7 +1848,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
size_t
operator()(const __shared_ptr<_Tp, _Lp>& __s) const noexcept
- { return std::hash<_Tp*>()(__s.get()); }
+ {
+ return hash<typename __shared_ptr<_Tp, _Lp>::element_type*>()(
+ __s.get());
+ }
};
_GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/include/experimental/bits/shared_ptr.h b/libstdc++-v3/include/experimental/bits/shared_ptr.h
index e8c533e158c..8a1fc52caf8 100644
--- a/libstdc++-v3/include/experimental/bits/shared_ptr.h
+++ b/libstdc++-v3/include/experimental/bits/shared_ptr.h
@@ -46,665 +46,20 @@ namespace experimental
inline namespace fundamentals_v2
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
- template<typename _Tp> class enable_shared_from_this;
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace fundamentals_v2
-} // namespace experimental
-
-#define __cpp_lib_experimental_shared_ptr_arrays 201406
-
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
- /*
- * The specification of std::experimental::shared_ptr is slightly different
- * to std::shared_ptr (specifically in terms of "compatible" pointers) so
- * to implement std::experimental::shared_ptr without too much duplication
- * we make it derive from a partial specialization of std::__shared_ptr
- * using a special tag type, __libfund_v1.
- *
- * There are two partial specializations for the tag type, supporting the
- * different interfaces of the array and non-array forms.
- */
-
- template <typename _Tp, bool = is_array<_Tp>::value>
- struct __libfund_v1 { using type = _Tp; };
-
- // Partial specialization for base class of experimental::shared_ptr<T>
- // (i.e. the non-array form of experimental::shared_ptr)
- template<typename _Tp, _Lock_policy _Lp>
- class __shared_ptr<__libfund_v1<_Tp, false>, _Lp>
- : private __shared_ptr<_Tp, _Lp>
- {
- // For non-arrays, Y* is compatible with T* if Y* is convertible to T*.
- template<typename _Yp, typename _Res = void>
- using _Compatible
- = enable_if_t<experimental::is_convertible_v<_Yp*, _Tp*>, _Res>;
-
- template<typename _Yp, typename _Del,
- typename _Ptr = typename unique_ptr<_Yp, _Del>::pointer,
- typename _Res = void>
- using _UniqCompatible = enable_if_t<
- experimental::is_convertible_v<_Yp*, _Tp*>
- && experimental::is_convertible_v<_Ptr, _Tp*>,
- _Res>;
-
- using _Base_type = __shared_ptr<_Tp>;
-
- _Base_type& _M_get_base() { return *this; }
- const _Base_type& _M_get_base() const { return *this; }
-
- public:
- using element_type = _Tp;
-
- constexpr __shared_ptr() noexcept = default;
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- explicit
- __shared_ptr(_Tp1* __p)
- : _Base_type(__p)
- { }
-
- template<typename _Tp1, typename _Deleter, typename = _Compatible<_Tp1>>
- __shared_ptr(_Tp1* __p, _Deleter __d)
- : _Base_type(__p, __d)
- { }
-
- template<typename _Tp1, typename _Deleter, typename _Alloc,
- typename = _Compatible<_Tp1>>
- __shared_ptr(_Tp1* __p, _Deleter __d, _Alloc __a)
- : _Base_type(__p, __d, __a)
- { }
-
- template<typename _Deleter>
- __shared_ptr(nullptr_t __p, _Deleter __d)
- : _Base_type(__p, __d)
- { }
-
- template<typename _Deleter, typename _Alloc>
- __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
- : _Base_type(__p, __d, __a)
- { }
-
- template<typename _Tp1>
- __shared_ptr(const __shared_ptr<__libfund_v1<_Tp1>, _Lp>& __r,
- element_type* __p) noexcept
- : _Base_type(__r._M_get_base(), __p)
- { }
-
- __shared_ptr(const __shared_ptr&) noexcept = default;
- __shared_ptr(__shared_ptr&&) noexcept = default;
- __shared_ptr& operator=(const __shared_ptr&) noexcept = default;
- __shared_ptr& operator=(__shared_ptr&&) noexcept = default;
- ~__shared_ptr() = default;
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- __shared_ptr(const __shared_ptr<__libfund_v1<_Tp1>, _Lp>& __r) noexcept
- : _Base_type(__r._M_get_base())
- { }
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- __shared_ptr(__shared_ptr<__libfund_v1<_Tp1>, _Lp>&& __r) noexcept
- : _Base_type(std::move((__r._M_get_base())))
- { }
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- explicit
- __shared_ptr(const __weak_ptr<__libfund_v1<_Tp1>, _Lp>& __r)
- : _Base_type(__r._M_get_base())
- { }
-
- template<typename _Tp1, typename _Del,
- typename = _UniqCompatible<_Tp1, _Del>>
- __shared_ptr(unique_ptr<_Tp1, _Del>&& __r)
- : _Base_type(std::move(__r))
- { }
-
-#if _GLIBCXX_USE_DEPRECATED
- // Postcondition: use_count() == 1 and __r.get() == 0
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- __shared_ptr(std::auto_ptr<_Tp1>&& __r)
- : _Base_type(std::move(__r))
- { }
-#endif
-
- constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
-
- // reset
- void
- reset() noexcept
- { __shared_ptr(nullptr).swap(*this); }
-
- template<typename _Tp1>
- _Compatible<_Tp1>
- reset(_Tp1* __p)
- {
- _GLIBCXX_DEBUG_ASSERT(__p == 0 || __p != get());
- __shared_ptr(__p).swap(*this);
- }
-
- template<typename _Tp1, typename _Deleter>
- _Compatible<_Tp1>
- reset(_Tp1* __p, _Deleter __d)
- { __shared_ptr(__p, __d).swap(*this); }
-
- template<typename _Tp1, typename _Deleter, typename _Alloc>
- _Compatible<_Tp1>
- reset(_Tp1* __p, _Deleter __d, _Alloc __a)
- { __shared_ptr(__p, __d, std::move(__a)).swap(*this); }
-
- using _Base_type::operator*;
- using _Base_type::operator->;
-
- template<typename _Tp1>
- _Compatible<_Tp1, __shared_ptr&>
- operator=(const __shared_ptr<__libfund_v1<_Tp1>, _Lp>& __r) noexcept
- {
- _Base_type::operator=(__r._M_get_base());
- return *this;
- }
-
- template<class _Tp1>
- _Compatible<_Tp1, __shared_ptr&>
- operator=(__shared_ptr<__libfund_v1<_Tp1>, _Lp>&& __r) noexcept
- {
- _Base_type::operator=(std::move(__r._M_get_base()));
- return *this;
- }
-
- template<typename _Tp1, typename _Del>
- _UniqCompatible<_Tp1, _Del, __shared_ptr&>
- operator=(unique_ptr<_Tp1, _Del>&& __r)
- {
- _Base_type::operator=(std::move(__r));
- return *this;
- }
-
-#if _GLIBCXX_USE_DEPRECATED
- template<typename _Tp1>
- _Compatible<_Tp1, __shared_ptr&>
- operator=(std::auto_ptr<_Tp1>&& __r)
- {
- _Base_type::operator=(std::move(__r));
- return *this;
- }
-#endif
-
- void
- swap(__shared_ptr& __other) noexcept
- { _Base_type::swap(__other); }
-
- template<typename _Tp1>
- bool
- owner_before(__shared_ptr<__libfund_v1<_Tp1>, _Lp> const& __rhs) const
- { return _Base_type::owner_before(__rhs._M_get_base()); }
-
- template<typename _Tp1>
- bool
- owner_before(__weak_ptr<__libfund_v1<_Tp1>, _Lp> const& __rhs) const
- { return _Base_type::owner_before(__rhs._M_get_base()); }
-
- using _Base_type::operator bool;
- using _Base_type::get;
- using _Base_type::unique;
- using _Base_type::use_count;
-
- protected:
-
- // make_shared not yet support for shared_ptr_arrays
- //template<typename _Alloc, typename... _Args>
- // __shared_ptr(_Sp_make_shared_tag __tag, const _Alloc& __a,
- // _Args&&... __args)
- // : _M_ptr(), _M_refcount(__tag, (_Tp*)0, __a,
- // std::forward<_Args>(__args)...)
- // {
- // void* __p = _M_refcount._M_get_deleter(typeid(__tag));
- // _M_ptr = static_cast<_Tp*>(__p);
- // }
-
- // __weak_ptr::lock()
- __shared_ptr(const __weak_ptr<__libfund_v1<_Tp>, _Lp>& __r,
- std::nothrow_t)
- : _Base_type(__r._M_get_base(), std::nothrow)
- { }
-
- private:
- template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr;
- template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr;
-
- // TODO
- template<typename _Del, typename _Tp1, _Lock_policy _Lp1>
- friend _Del* get_deleter(const __shared_ptr<_Tp1, _Lp1>&) noexcept;
- };
-
- // Helper traits for shared_ptr of array:
- // Trait that tests if Y* is compatible with T*, for shared_ptr purposes.
- template<typename _Yp, typename _Tp>
- struct __sp_compatible
- : is_convertible<_Yp*, _Tp*>::type
- { };
+ // 8.2.1
- template<size_t _Nm, typename _Tp>
- struct __sp_compatible<_Tp[_Nm], _Tp[]>
- : true_type
- { };
-
- template<size_t _Nm, typename _Tp>
- struct __sp_compatible<_Tp[_Nm], const _Tp[]>
- : true_type
- { };
+ template<typename _Tp> class shared_ptr;
+ template<typename _Tp> class weak_ptr;
+ template<typename _Tp> class enable_shared_from_this;
template<typename _Yp, typename _Tp>
constexpr bool __sp_compatible_v
- = __sp_compatible<_Yp, _Tp>::value;
-
- // Test conversion from Y(*)[N] to U(*)[N] without forming invalid type Y[N].
- template<typename _Up, size_t _Nm, typename _Yp, typename = void>
- struct __sp_is_constructible_arrN
- : false_type
- { };
-
- template<typename _Up, size_t _Nm, typename _Yp>
- struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>>
- : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type
- { };
-
- // Test conversion from Y(*)[] to U(*)[] without forming invalid type Y[].
- template<typename _Up, typename _Yp, typename = void>
- struct __sp_is_constructible_arr
- : false_type
- { };
-
- template<typename _Up, typename _Yp>
- struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>>
- : is_convertible<_Yp(*)[], _Up(*)[]>::type
- { };
-
- // Trait to check if shared_ptr<T> can be constructed from Y*.
- template<typename _Tp, typename _Yp>
- struct __sp_is_constructible;
-
- // When T is U[N], Y(*)[N] shall be convertible to T*;
- template<typename _Up, size_t _Nm, typename _Yp>
- struct __sp_is_constructible<_Up[_Nm], _Yp>
- : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type
- { };
-
- // when T is U[], Y(*)[] shall be convertible to T*;
- template<typename _Up, typename _Yp>
- struct __sp_is_constructible<_Up[], _Yp>
- : __sp_is_constructible_arr<_Up, _Yp>::type
- { };
-
- // otherwise, Y* shall be convertible to T*.
- template<typename _Tp, typename _Yp>
- struct __sp_is_constructible
- : is_convertible<_Yp*, _Tp*>::type
- { };
+ = std::__sp_compatible_with<_Yp*, _Tp*>::value;
template<typename _Tp, typename _Yp>
constexpr bool __sp_is_constructible_v
- = __sp_is_constructible<_Tp, _Yp>::value;
-
-
- // Partial specialization for base class of experimental::shared_ptr<T[N]>
- // and experimental::shared_ptr<T[]> (i.e. the array forms).
- template<typename _Tp, _Lock_policy _Lp>
- class __shared_ptr<__libfund_v1<_Tp, true>, _Lp>
- : private __shared_ptr<remove_extent_t<_Tp>, _Lp>
- {
- public:
- using element_type = remove_extent_t<_Tp>;
-
- private:
- struct _Array_deleter
- {
- void
- operator()(element_type const *__p) const
- { delete [] __p; }
- };
-
- // Constraint for constructing/resetting with a pointer of type _Yp*:
- template<typename _Yp>
- using _SafeConv = enable_if_t<__sp_is_constructible_v<_Tp, _Yp>>;
-
- // Constraint for constructing/assigning from smart_pointer<_Tp1>:
- template<typename _Tp1, typename _Res = void>
- using _Compatible = enable_if_t<__sp_compatible_v<_Tp1, _Tp>, _Res>;
-
- // Constraint for constructing/assigning from unique_ptr<_Tp1, _Del>:
- template<typename _Tp1, typename _Del,
- typename _Ptr = typename unique_ptr<_Tp1, _Del>::pointer,
- typename _Res = void>
- using _UniqCompatible = enable_if_t<
- __sp_compatible_v<_Tp1, _Tp>
- && experimental::is_convertible_v<_Ptr, element_type*>,
- _Res>;
-
- using _Base_type = __shared_ptr<element_type>;
-
- _Base_type& _M_get_base() { return *this; }
- const _Base_type& _M_get_base() const { return *this; }
-
- public:
- constexpr __shared_ptr() noexcept
- : _Base_type()
- { }
-
- template<typename _Tp1, typename = _SafeConv<_Tp1>>
- explicit
- __shared_ptr(_Tp1* __p)
- : _Base_type(__p, _Array_deleter())
- { }
-
- template<typename _Tp1, typename _Deleter, typename = _SafeConv<_Tp1>>
- __shared_ptr(_Tp1* __p, _Deleter __d)
- : _Base_type(__p, __d)
- { }
-
- template<typename _Tp1, typename _Deleter, typename _Alloc,
- typename = _SafeConv<_Tp1>>
- __shared_ptr(_Tp1* __p, _Deleter __d, _Alloc __a)
- : _Base_type(__p, __d, __a)
- { }
-
- template<typename _Deleter>
- __shared_ptr(nullptr_t __p, _Deleter __d)
- : _Base_type(__p, __d)
- { }
-
- template<typename _Deleter, typename _Alloc>
- __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
- : _Base_type(__p, __d, __a)
- { }
-
- template<typename _Tp1>
- __shared_ptr(const __shared_ptr<__libfund_v1<_Tp1>, _Lp>& __r,
- element_type* __p) noexcept
- : _Base_type(__r._M_get_base(), __p)
- { }
-
- __shared_ptr(const __shared_ptr&) noexcept = default;
- __shared_ptr(__shared_ptr&&) noexcept = default;
- __shared_ptr& operator=(const __shared_ptr&) noexcept = default;
- __shared_ptr& operator=(__shared_ptr&&) noexcept = default;
- ~__shared_ptr() = default;
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- __shared_ptr(const __shared_ptr<__libfund_v1<_Tp1>, _Lp>& __r) noexcept
- : _Base_type(__r._M_get_base())
- { }
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- __shared_ptr(__shared_ptr<__libfund_v1<_Tp1>, _Lp>&& __r) noexcept
- : _Base_type(std::move((__r._M_get_base())))
- { }
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- explicit
- __shared_ptr(const __weak_ptr<__libfund_v1<_Tp1>, _Lp>& __r)
- : _Base_type(__r._M_get_base())
- { }
-
- template<typename _Tp1, typename _Del,
- typename = _UniqCompatible<_Tp1, _Del>>
- __shared_ptr(unique_ptr<_Tp1, _Del>&& __r)
- : _Base_type(std::move(__r))
- { }
-
-#if _GLIBCXX_USE_DEPRECATED
- // Postcondition: use_count() == 1 and __r.get() == 0
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- __shared_ptr(auto_ptr<_Tp1>&& __r)
- : _Base_type(std::move(__r))
- { }
-#endif
-
- constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
-
- // reset
- void
- reset() noexcept
- { __shared_ptr(nullptr).swap(*this); }
-
- template<typename _Tp1>
- _SafeConv<_Tp1>
- reset(_Tp1* __p)
- {
- _GLIBCXX_DEBUG_ASSERT(__p == 0 || __p != get());
- __shared_ptr(__p, _Array_deleter()).swap(*this);
- }
-
- template<typename _Tp1, typename _Deleter>
- _SafeConv<_Tp1>
- reset(_Tp1* __p, _Deleter __d)
- { __shared_ptr(__p, __d).swap(*this); }
-
- template<typename _Tp1, typename _Deleter, typename _Alloc>
- _SafeConv<_Tp1>
- reset(_Tp1* __p, _Deleter __d, _Alloc __a)
- { __shared_ptr(__p, __d, std::move(__a)).swap(*this); }
-
- element_type&
- operator[](ptrdiff_t i) const noexcept
- {
- _GLIBCXX_DEBUG_ASSERT(get() != 0 && i >= 0);
- return get()[i];
- }
-
- template<typename _Tp1>
- _Compatible<_Tp1, __shared_ptr&>
- operator=(const __shared_ptr<__libfund_v1<_Tp1>, _Lp>& __r) noexcept
- {
- _Base_type::operator=(__r._M_get_base());
- return *this;
- }
-
- template<class _Tp1>
- _Compatible<_Tp1, __shared_ptr&>
- operator=(__shared_ptr<__libfund_v1<_Tp1>, _Lp>&& __r) noexcept
- {
- _Base_type::operator=(std::move(__r._M_get_base()));
- return *this;
- }
-
- template<typename _Tp1, typename _Del>
- _UniqCompatible<_Tp1, _Del, __shared_ptr&>
- operator=(unique_ptr<_Tp1, _Del>&& __r)
- {
- _Base_type::operator=(std::move(__r));
- return *this;
- }
-
-#if _GLIBCXX_USE_DEPRECATED
- template<typename _Tp1>
- _Compatible<_Tp1, __shared_ptr&>
- operator=(auto_ptr<_Tp1>&& __r)
- {
- _Base_type::operator=(std::move(__r));
- return *this;
- }
-#endif
-
- void
- swap(__shared_ptr& __other) noexcept
- { _Base_type::swap(__other); }
-
- template<typename _Tp1>
- bool
- owner_before(__shared_ptr<__libfund_v1<_Tp1>, _Lp> const& __rhs) const
- { return _Base_type::owner_before(__rhs._M_get_base()); }
-
- template<typename _Tp1>
- bool
- owner_before(__weak_ptr<__libfund_v1<_Tp1>, _Lp> const& __rhs) const
- { return _Base_type::owner_before(__rhs._M_get_base()); }
-
- using _Base_type::operator bool;
- using _Base_type::get;
- using _Base_type::unique;
- using _Base_type::use_count;
-
- protected:
-
- // make_shared not yet support for shared_ptr_arrays
- //template<typename _Alloc, typename... _Args>
- // __shared_ptr(_Sp_make_shared_tag __tag, const _Alloc& __a,
- // _Args&&... __args)
- // : _M_ptr(), _M_refcount(__tag, (_Tp*)0, __a,
- // std::forward<_Args>(__args)...)
- // {
- // void* __p = _M_refcount._M_get_deleter(typeid(__tag));
- // _M_ptr = static_cast<_Tp*>(__p);
- // }
-
- // __weak_ptr::lock()
- __shared_ptr(const __weak_ptr<__libfund_v1<_Tp>, _Lp>& __r,
- std::nothrow_t)
- : _Base_type(__r._M_get_base(), std::nothrow)
- { }
-
- private:
- template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr;
- template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr;
-
- // TODO
- template<typename _Del, typename _Tp1, _Lock_policy _Lp1>
- friend _Del* get_deleter(const __shared_ptr<_Tp1, _Lp1>&) noexcept;
- };
-
- // weak_ptr specialization for __shared_ptr array
- template<typename _Tp, _Lock_policy _Lp>
- class __weak_ptr<__libfund_v1<_Tp>, _Lp>
- : __weak_ptr<remove_extent_t<_Tp>, _Lp>
- {
- template<typename _Tp1, typename _Res = void>
- using _Compatible
- = enable_if_t<__sp_compatible_v<_Tp1, _Tp>, _Res>;
-
- using _Base_type = __weak_ptr<remove_extent_t<_Tp>>;
-
- _Base_type& _M_get_base() { return *this; }
- const _Base_type& _M_get_base() const { return *this; }
-
- public:
- using element_type = remove_extent_t<_Tp>;
-
- constexpr __weak_ptr() noexcept
- : _Base_type()
- { }
-
- __weak_ptr(const __weak_ptr&) noexcept = default;
-
- ~__weak_ptr() = default;
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- __weak_ptr(const __weak_ptr<__libfund_v1<_Tp1>, _Lp>& __r) noexcept
- : _Base_type(__r._M_get_base())
- { }
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- __weak_ptr(const __shared_ptr<__libfund_v1<_Tp1>, _Lp>& __r) noexcept
- : _Base_type(__r._M_get_base())
- { }
-
- __weak_ptr(__weak_ptr&& __r) noexcept
- : _Base_type(std::move(__r))
- { }
-
- template<typename _Tp1, typename = _Compatible<_Tp1>>
- __weak_ptr(__weak_ptr<__libfund_v1<_Tp1>, _Lp>&& __r) noexcept
- : _Base_type(std::move(__r._M_get_base()))
- { }
-
- __weak_ptr&
- operator=(const __weak_ptr& __r) noexcept = default;
-
- template<typename _Tp1>
- _Compatible<_Tp1, __weak_ptr&>
- operator=(const __weak_ptr<__libfund_v1<_Tp1>, _Lp>& __r) noexcept
- {
- this->_Base_type::operator=(__r._M_get_base());
- return *this;
- }
-
- template<typename _Tp1>
- _Compatible<_Tp1, __weak_ptr&>
- operator=(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
- {
- this->_Base_type::operator=(__r._M_get_base());
- return *this;
- }
-
- __weak_ptr&
- operator=(__weak_ptr&& __r) noexcept
- {
- this->_Base_type::operator=(std::move(__r));
- return *this;
- }
-
- template<typename _Tp1>
- _Compatible<_Tp1, __weak_ptr&>
- operator=(__weak_ptr<_Tp1, _Lp>&& __r) noexcept
- {
- this->_Base_type::operator=(std::move(__r._M_get_base()));
- return *this;
- }
-
- void
- swap(__weak_ptr& __other) noexcept
- { this->_Base_type::swap(__other); }
-
- template<typename _Tp1>
- bool
- owner_before(const __shared_ptr<__libfund_v1<_Tp1>, _Lp>& __rhs) const
- { return _Base_type::owner_before(__rhs._M_get_base()); }
-
- template<typename _Tp1>
- bool
- owner_before(const __weak_ptr<__libfund_v1<_Tp1>, _Lp>& __rhs) const
- { return _Base_type::owner_before(__rhs._M_get_base()); }
-
- __shared_ptr<__libfund_v1<_Tp>, _Lp>
- lock() const noexcept // should not be element_type
- { return __shared_ptr<__libfund_v1<_Tp>, _Lp>(*this, std::nothrow); }
-
- using _Base_type::use_count;
- using _Base_type::expired;
- using _Base_type::reset;
-
- private:
- // Used by __enable_shared_from_this.
- void
- _M_assign(element_type* __ptr,
- const __shared_count<_Lp>& __refcount) noexcept
- { this->_Base_type::_M_assign(__ptr, __refcount); }
-
- template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr;
- template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr;
- friend class __enable_shared_from_this<_Tp, _Lp>;
- friend class experimental::enable_shared_from_this<_Tp>;
- friend class enable_shared_from_this<_Tp>;
- };
-
-_GLIBCXX_END_NAMESPACE_VERSION
-
-namespace experimental
-{
-inline namespace fundamentals_v2
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
- // 8.2.1
-
- template<typename _Tp> class shared_ptr;
- template<typename _Tp> class weak_ptr;
-
- template<typename _Tp, _Lock_policy _Lp = __default_lock_policy>
- using __shared_ptr = std::__shared_ptr<__libfund_v1<_Tp>, _Lp>;
-
- template<typename _Tp, _Lock_policy _Lp = __default_lock_policy>
- using __weak_ptr = std::__weak_ptr<__libfund_v1<_Tp>, _Lp>;
+ = std::__sp_is_constructible<_Tp, _Yp>::value;
template<typename _Tp>
class shared_ptr : public __shared_ptr<_Tp>
@@ -1128,16 +483,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ __a.swap(__b); }
/// C++14 §20.8.2.2.10
- template<typename _Del, typename _Tp, _Lock_policy _Lp>
+ template<typename _Del, typename _Tp>
inline _Del*
- get_deleter(const __shared_ptr<_Tp, _Lp>& __p) noexcept
+ get_deleter(const shared_ptr<_Tp>& __p) noexcept
{ return std::get_deleter<_Del>(__p); }
// C++14 §20.8.2.2.11
- template<typename _Ch, typename _Tr, typename _Tp, _Lock_policy _Lp>
+ template<typename _Ch, typename _Tr, typename _Tp>
inline std::basic_ostream<_Ch, _Tr>&
- operator<<(std::basic_ostream<_Ch, _Tr>& __os,
- const __shared_ptr<_Tp, _Lp>& __p)
+ operator<<(std::basic_ostream<_Ch, _Tr>& __os, const shared_ptr<_Tp>& __p)
{
__os << __p.get();
return __os;
diff --git a/libstdc++-v3/include/experimental/memory_resource b/libstdc++-v3/include/experimental/memory_resource
index 39187c50881..52e0b031653 100644
--- a/libstdc++-v3/include/experimental/memory_resource
+++ b/libstdc++-v3/include/experimental/memory_resource
@@ -72,6 +72,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 8.5 Class memory_resource
class memory_resource
{
+ protected:
static constexpr size_t _S_max_align = alignof(max_align_t);
public:
diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index fea915b0a87..8ba13069510 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -95,11 +95,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
class future_error : public logic_error
{
- error_code _M_code;
-
public:
- explicit future_error(error_code __ec)
- : logic_error("std::future_error: " + __ec.message()), _M_code(__ec)
+ explicit
+ future_error(future_errc __errc)
+ : future_error(std::make_error_code(__errc))
{ }
virtual ~future_error() noexcept;
@@ -109,6 +108,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const error_code&
code() const noexcept { return _M_code; }
+
+ private:
+ explicit
+ future_error(error_code __ec)
+ : logic_error("std::future_error: " + __ec.message()), _M_code(__ec)
+ { }
+
+ friend void __throw_future_error(int);
+
+ error_code _M_code;
};
// Forward declarations.
@@ -426,8 +435,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
if (static_cast<bool>(__res))
{
- error_code __ec(make_error_code(future_errc::broken_promise));
- __res->_M_error = make_exception_ptr(future_error(__ec));
+ __res->_M_error =
+ make_exception_ptr(future_error(future_errc::broken_promise));
// This function is only called when the last asynchronous result
// provider is abandoning this shared state, so noone can be
// trying to make the shared state ready at the same time, and
@@ -769,7 +778,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return std::move(this->_M_get_result()._M_value());
}
- shared_future<_Res> share();
+ shared_future<_Res> share() noexcept;
};
/// Partial specialization for future<R&>
@@ -812,7 +821,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return this->_M_get_result()._M_get();
}
- shared_future<_Res&> share();
+ shared_future<_Res&> share() noexcept;
};
/// Explicit specialization for future<void>
@@ -855,7 +864,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
this->_M_get_result();
}
- shared_future<void> share();
+ shared_future<void> share() noexcept;
};
@@ -995,18 +1004,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_state(std::move(__uf._M_state))
{ }
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2556. Wide contract for future::share()
template<typename _Res>
inline shared_future<_Res>
- future<_Res>::share()
+ future<_Res>::share() noexcept
{ return shared_future<_Res>(std::move(*this)); }
template<typename _Res>
inline shared_future<_Res&>
- future<_Res&>::share()
+ future<_Res&>::share() noexcept
{ return shared_future<_Res&>(std::move(*this)); }
inline shared_future<void>
- future<void>::share()
+ future<void>::share() noexcept
{ return shared_future<void>(std::move(*this)); }
/// Primary template for promise
diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view
index b2d2a296ba4..cf728dd83e9 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -640,6 +640,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ };
#endif
+ inline namespace literals
+ {
+ inline namespace string_view_literals
+ {
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ inline constexpr basic_string_view<char>
+ operator""sv(const char* __str, size_t __len)
+ { return basic_string_view<char>{__str, __len}; }
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ inline constexpr basic_string_view<wchar_t>
+ operator""sv(const wchar_t* __str, size_t __len)
+ { return basic_string_view<wchar_t>{__str, __len}; }
+#endif
+
+#ifdef _GLIBCXX_USE_C99_STDINT_TR1
+ inline constexpr basic_string_view<char16_t>
+ operator""sv(const char16_t* __str, size_t __len)
+ { return basic_string_view<char16_t>{__str, __len}; }
+
+ inline constexpr basic_string_view<char32_t>
+ operator""sv(const char32_t* __str, size_t __len)
+ { return basic_string_view<char32_t>{__str, __len}; }
+#endif
+
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace string_literals
+ } // namespace literals
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc
index 8ed0a105dfa..0dcb1b410fc 100644
--- a/libstdc++-v3/src/filesystem/ops.cc
+++ b/libstdc++-v3/src/filesystem/ops.cc
@@ -1054,7 +1054,7 @@ fs::is_empty(const path& p)
error_code ec;
bool e = is_empty(p, ec);
if (ec)
- _GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot check is file is empty",
+ _GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot check if file is empty",
p, ec));
return e;
}
diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
index 4f0720af412..a65971633fa 100644
--- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
@@ -41,7 +41,7 @@ void test01()
typedef make_signed<float>::type test5_type;
}
-// { dg-error "does not name a type" "" { target *-*-* } 32 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 32 }
// { dg-error "required from here" "" { target *-*-* } 34 }
// { dg-error "required from here" "" { target *-*-* } 36 }
// { dg-error "required from here" "" { target *-*-* } 39 }
diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
index 8eea6b967f3..6a93e2f3640 100644
--- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
@@ -41,7 +41,7 @@ void test01()
typedef make_unsigned<float>::type test5_type;
}
-// { dg-error "does not name a type" "" { target *-*-* } 32 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 32 }
// { dg-error "required from here" "" { target *-*-* } 34 }
// { dg-error "required from here" "" { target *-*-* } 36 }
// { dg-error "required from here" "" { target *-*-* } 39 }
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/array.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/array.cc
new file mode 100644
index 00000000000..d56dc6692e9
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/array.cc
@@ -0,0 +1,273 @@
+// { dg-do run { target c++11 } }
+
+// Copyright (C) 2016 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// C++1z 20.11.2.2.1 shared_ptr constructors [util.smartptr.shared.const]
+
+template<typename To, typename From>
+constexpr bool check()
+{
+ using std::shared_ptr;
+ using std::is_constructible;
+ return !is_constructible<shared_ptr<To>, shared_ptr<From>>::value
+ && !is_constructible<shared_ptr<To>, shared_ptr<From>&>::value;
+}
+
+static_assert( check<int, int[]>() );
+static_assert( check<int, int[2]>() );
+static_assert( check<int[2], void>() );
+static_assert( check<int[2], int>() );
+static_assert( check<int[2], int[]>() );
+static_assert( check<int[], void>() );
+static_assert( check<int[], int>() );
+
+int count = 0;
+
+struct A {
+ A() { ++count; }
+ ~A() { --count; }
+};
+
+struct B : A { };
+
+static_assert( check<A, B[2]>() );
+static_assert( check<A, B[]>() );
+static_assert( check<A[2], B>() );
+static_assert( check<A[2], B[2]>() );
+static_assert( check<A[2], B[]>() );
+static_assert( check<A[], B>() );
+static_assert( check<A[], B[2]>() );
+static_assert( check<A[], B[]>() );
+
+void
+test01()
+{
+ std::shared_ptr<A[2]> p;
+ VERIFY( p.get() == nullptr );
+ VERIFY( p.use_count() == 0 );
+ p.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test02()
+{
+ std::shared_ptr<A[]> p;
+ VERIFY( p.get() == nullptr );
+ VERIFY( p.use_count() == 0 );
+ p.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test03()
+{
+ std::shared_ptr<A[2]> p(nullptr);
+ VERIFY( p.get() == nullptr );
+ VERIFY( p.use_count() == 0 );
+ p.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test04()
+{
+ std::shared_ptr<A[]> p(nullptr);
+ VERIFY( p.get() == nullptr );
+ VERIFY( p.use_count() == 0 );
+ p.reset();
+ VERIFY( count == 0 );
+}
+
+// Construction from pointer
+
+void
+test05()
+{
+ A * const a = nullptr;
+ std::shared_ptr<A[2]> p(a);
+ VERIFY( p.get() == nullptr );
+ VERIFY( p.use_count() == 1 );
+ p.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test06()
+{
+ A * const a = nullptr;
+ std::shared_ptr<A[]> p(a);
+ VERIFY( p.get() == nullptr );
+ VERIFY( p.use_count() == 1 );
+ p.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test07()
+{
+ A * const a = new A[2];
+ std::shared_ptr<A[2]> p(a);
+ VERIFY( p.get() == a );
+ VERIFY( p.use_count() == 1 );
+ p.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test08()
+{
+ A * const a = new A[2];
+ std::shared_ptr<A[]> p(a);
+ VERIFY( p.get() == a );
+ VERIFY( p.use_count() == 1 );
+ p.reset();
+ VERIFY( count == 0 );
+}
+
+// Converting constrcutor
+
+void
+test09()
+{
+ A * const a = new A[2];
+ std::shared_ptr<A[2]> p(a);
+ std::shared_ptr<const A[2]> p2(p);
+ VERIFY( p2.get() == a );
+ VERIFY( p.use_count() == 2 );
+ VERIFY( p2.use_count() == 2 );
+ p.reset();
+ VERIFY( count != 0 );
+ p2.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test10()
+{
+ A * const a = new A[2];
+ std::shared_ptr<A[]> p(a);
+ std::shared_ptr<const A[]> p2(p);
+ VERIFY( p2.get() == a );
+ VERIFY( p.use_count() == 2 );
+ VERIFY( p2.use_count() == 2 );
+ p.reset();
+ VERIFY( count != 0 );
+ p2.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test11()
+{
+ A * const a = new A[2];
+ std::shared_ptr<A[2]> p(a);
+ std::shared_ptr<const A[]> p2(p);
+ VERIFY( p2.get() == a );
+ VERIFY( p.use_count() == 2 );
+ VERIFY( p2.use_count() == 2 );
+ p.reset();
+ VERIFY( count != 0 );
+ p2.reset();
+ VERIFY( count == 0 );
+}
+
+// Copy construction
+
+void
+test12()
+{
+ A * const a = new A[2];
+ std::shared_ptr<A[2]> p(a);
+ std::shared_ptr<A[2]> p2(p);
+ VERIFY( p2.get() == a );
+ VERIFY( p.use_count() == 2 );
+ VERIFY( p2.use_count() == 2 );
+ p.reset();
+ VERIFY( count != 0 );
+ p2.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test13()
+{
+ A * const a = new A[2];
+ std::shared_ptr<A[2]> p(a);
+ std::shared_ptr<A[]> p2(p);
+ VERIFY( p2.get() == a );
+ VERIFY( p.use_count() == 2 );
+ VERIFY( p2.use_count() == 2 );
+ p.reset();
+ VERIFY( count != 0 );
+ p2.reset();
+ VERIFY( count == 0 );
+}
+
+// Move construction
+
+void
+test14()
+{
+ A * const a = new A[2];
+ std::shared_ptr<A[2]> p(a);
+ std::shared_ptr<A[2]> p2(std::move(p));
+ VERIFY( p.get() == nullptr );
+ VERIFY( p2.get() == a );
+ VERIFY( p.use_count() == 0 );
+ VERIFY( p2.use_count() == 1 );
+ p2.reset();
+ VERIFY( count == 0 );
+}
+
+void
+test15()
+{
+ A * const a = new A[2];
+ std::shared_ptr<A[2]> p(a);
+ std::shared_ptr<A[]> p2(std::move(p));
+ VERIFY( p.get() == nullptr );
+ VERIFY( p2.get() == a );
+ VERIFY( p.use_count() == 0 );
+ VERIFY( p2.use_count() == 1 );
+ p2.reset();
+ VERIFY( count == 0 );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ test05();
+ test06();
+ test07();
+ test08();
+ test09();
+ test10();
+ test11();
+ test12();
+ test13();
+ test14();
+ test15();
+}
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc
index 72eed477c8f..bc1fcf12225 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc
@@ -22,6 +22,13 @@
#include <memory>
#include <testsuite_hooks.h>
+#if __cpp_lib_shared_ptr_arrays >= 201603
+# define SHARED_PTR_ARRAYS
+#endif
+#if __cpp_lib_enable_shared_from_this >= 201603
+# define WEAK_FROM_THIS
+#endif
+
int destroyed = 0;
struct A : std::enable_shared_from_this<A>
@@ -36,12 +43,22 @@ int
test01()
{
std::unique_ptr<A[]> up(new A[2]);
+#ifdef SHARED_PTR_ARRAYS
+ std::shared_ptr<A[]> sp(std::move(up));
+#else
std::shared_ptr<A> sp(std::move(up));
+#endif
VERIFY( up.get() == 0 );
VERIFY( sp.get() != 0 );
VERIFY( sp.use_count() == 1 );
+#ifdef SHARED_PTR_ARRAYS
+# ifdef WEAK_FROM_THIS
+ VERIFY( sp[0].weak_from_this().expired() );
+# endif
+#else
VERIFY( sp->shared_from_this() != nullptr );
+#endif
sp.reset();
VERIFY( destroyed == 2 );
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/array.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/array.cc
new file mode 100644
index 00000000000..c47859d659a
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/array.cc
@@ -0,0 +1,73 @@
+// { dg-do run { target c++11 } }
+
+// Copyright (C) 2016 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct A
+{
+ int i = 0;
+};
+
+// C++1z 20.11.2.2.5 shared_ptr observers [util.smartptr.shared.obs]
+
+// get
+void
+test01()
+{
+ A * const a = new A[2];
+ const std::shared_ptr<A[2]> p(a);
+ VERIFY( p.get() == a );
+}
+
+// get
+void
+test02()
+{
+ A * const a = new A[2];
+ const std::shared_ptr<A[]> p(a);
+ VERIFY( p.get() == a );
+}
+
+// operator[]
+void
+test03()
+{
+ A * const a = new A[2];
+ const std::shared_ptr<A[2]> p(a);
+ VERIFY( &p[0] == a );
+}
+
+// operator[]
+void
+test04()
+{
+ A * const a = new A[2];
+ const std::shared_ptr<A[]> p(a);
+ VERIFY( &p[0] == a );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/literals/types.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/literals/types.cc
new file mode 100644
index 00000000000..42e8b16070e
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/literals/types.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2013-2016 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string_view>
+#include <type_traits>
+
+void
+test01()
+{
+ using namespace std::literals::string_view_literals;
+
+ static_assert(std::is_same<decltype("Hello"sv), std::string_view>::value,
+ "\"Hello\"s is std::string_view");
+
+ static_assert(std::is_same<decltype(u8"Hello"sv), std::string_view>::value,
+ "u8\"Hello\"s is std::string_view");
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ static_assert(std::is_same<decltype(L"Hello"sv), std::wstring_view>::value,
+ "L\"Hello\"s is std::wstring_view");
+#endif
+
+ static_assert(std::is_same<decltype(u"Hello"sv), std::u16string_view>::value,
+ "u\"Hello\"s is std::u16string_view");
+
+ static_assert(std::is_same<decltype(U"Hello"sv), std::u32string_view>::value,
+ "U\"Hello\"s is std::u32string_view");
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/literals/values.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/literals/values.cc
new file mode 100644
index 00000000000..bbaa70e854a
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/literals/values.cc
@@ -0,0 +1,72 @@
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2013-2016 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string_view>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ using namespace std::literals::string_view_literals;
+
+ std::string_view planet = "Mercury"sv;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ std::wstring_view wplanet = L"Venus"sv;
+#endif
+ std::string_view u8planet = u8"Mars"sv;
+ std::u16string_view u16planet = u"Jupiter"sv;
+ std::u32string_view u32planet = U"Saturn"sv;
+
+ VERIFY( planet == std::string_view("Mercury") );
+#ifdef _GLIBCXX_USE_WCHAR_T
+ VERIFY( wplanet == std::wstring_view(L"Venus") );
+#endif
+ VERIFY( u8planet == std::string_view(u8"Mars") );
+ VERIFY( u16planet == std::u16string_view(u"Jupiter") );
+ VERIFY( u32planet == std::u32string_view(U"Saturn") );
+}
+
+void
+test02()
+{
+ using namespace std::literals::string_view_literals;
+
+ std::string_view planet_cratered = "Mercury\0cratered"sv;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ std::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
+#endif
+ std::string_view u8planet_cratered = u8"Mars\0cratered"sv;
+ std::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
+ std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
+
+ VERIFY( planet_cratered == std::string_view("Mercury\0cratered", 16) );
+#ifdef _GLIBCXX_USE_WCHAR_T
+ VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) );
+#endif
+ VERIFY( u8planet_cratered == std::string_view(u8"Mars\0cratered", 13) );
+ VERIFY( u16planet_cratered == std::u16string_view(u"Jupiter\0cratered", 16) );
+ VERIFY( u32planet_cratered == std::u32string_view(U"Saturn\0cratered", 15) );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+}
diff --git a/libstdc++-v3/testsuite/30_threads/future/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/future/requirements/explicit_instantiation.cc
index 16325232204..87d423f1e8b 100644
--- a/libstdc++-v3/testsuite/30_threads/future/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/30_threads/future/requirements/explicit_instantiation.cc
@@ -25,9 +25,8 @@
#include <testsuite_tr1.h>
using namespace __gnu_test;
-using std::future;
-template class future<int>;
-template class future<int&>;
-template class future<void>;
-template class future<ClassType>;
-template class future<ClassType&>;
+template class std::future<int>;
+template class std::future<int&>;
+template class std::future<void>;
+template class std::future<ClassType>;
+template class std::future<ClassType&>;
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc
index db90ff2c0f5..e3b61e4f418 100644
--- a/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc
@@ -25,9 +25,8 @@
#include <testsuite_tr1.h>
using namespace __gnu_test;
-using std::packaged_task;
-template class packaged_task<int()>;
-template class packaged_task<int&()>;
-template class packaged_task<void()>;
-template class packaged_task<ClassType(int)>;
-template class packaged_task<AbstractClass&(int)>;
+template class std::packaged_task<int()>;
+template class std::packaged_task<int&()>;
+template class std::packaged_task<void()>;
+template class std::packaged_task<ClassType(int)>;
+template class std::packaged_task<AbstractClass&(int)>;
diff --git a/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc
index 9691ab0445d..4a220a9deb6 100644
--- a/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc
@@ -25,9 +25,8 @@
#include <testsuite_tr1.h>
using namespace __gnu_test;
-using std::promise;
-template class promise<int>;
-template class promise<int&>;
-template class promise<void>;
-template class promise<ClassType>;
-template class promise<ClassType&>;
+template class std::promise<int>;
+template class std::promise<int&>;
+template class std::promise<void>;
+template class std::promise<ClassType>;
+template class std::promise<ClassType&>;
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc
index a992b882fb0..715b7fe39c4 100644
--- a/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc
@@ -25,9 +25,8 @@
#include <testsuite_tr1.h>
using namespace __gnu_test;
-using std::shared_future;
-template class shared_future<int>;
-template class shared_future<int&>;
-template class shared_future<void>;
-template class shared_future<ClassType>;
-template class shared_future<ClassType&>;
+template class std::shared_future<int>;
+template class std::shared_future<int&>;
+template class std::shared_future<void>;
+template class std::shared_future<ClassType>;
+template class std::shared_future<ClassType&>;
diff --git a/libstdc++-v3/testsuite/experimental/string_view/literals/values.cc b/libstdc++-v3/testsuite/experimental/string_view/literals/values.cc
index 19c64abdc1b..b51fd4555ff 100644
--- a/libstdc++-v3/testsuite/experimental/string_view/literals/values.cc
+++ b/libstdc++-v3/testsuite/experimental/string_view/literals/values.cc
@@ -42,8 +42,36 @@ test01()
VERIFY( u32planet == std::experimental::u32string_view(U"Saturn") );
}
+void
+test02()
+{
+ using namespace std::experimental::literals::string_view_literals;
+
+ std::experimental::string_view planet_cratered = "Mercury\0cratered"sv;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ std::experimental::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
+#endif
+ std::experimental::string_view u8planet_cratered = u8"Mars\0cratered"sv;
+ std::experimental::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
+ std::experimental::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
+
+ VERIFY( planet_cratered ==
+ std::experimental::string_view("Mercury\0cratered", 16) );
+#ifdef _GLIBCXX_USE_WCHAR_T
+ VERIFY( wplanet_cratered ==
+ std::experimental::wstring_view(L"Venus\0cratered", 14) );
+#endif
+ VERIFY( u8planet_cratered ==
+ std::experimental::string_view(u8"Mars\0cratered", 13) );
+ VERIFY( u16planet_cratered ==
+ std::experimental::u16string_view(u"Jupiter\0cratered", 16) );
+ VERIFY( u32planet_cratered ==
+ std::experimental::u32string_view(U"Saturn\0cratered", 15) );
+}
+
int
main()
{
test01();
+ test02();
}
diff --git a/libstdc++-v3/testsuite/ext/numeric_traits/numeric_traits.cc b/libstdc++-v3/testsuite/ext/numeric_traits/numeric_traits.cc
index 61987433954..6653625be8c 100644
--- a/libstdc++-v3/testsuite/ext/numeric_traits/numeric_traits.cc
+++ b/libstdc++-v3/testsuite/ext/numeric_traits/numeric_traits.cc
@@ -21,7 +21,6 @@
#include <ext/numeric_traits.h>
-using __gnu_cxx::__numeric_traits;
-template struct __numeric_traits<short>;
-template struct __numeric_traits<unsigned short>;
-template struct __numeric_traits<double>;
+template struct __gnu_cxx::__numeric_traits<short>;
+template struct __gnu_cxx::__numeric_traits<unsigned short>;
+template struct __gnu_cxx::__numeric_traits<double>;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc
index a7b967f30ab..18d94dfa71c 100644
--- a/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/enable_shared_from_this/requirements/explicit_instantiation/1.cc
@@ -23,8 +23,7 @@
// { dg-do compile }
using namespace __gnu_test;
-using std::tr1::enable_shared_from_this;
-template class enable_shared_from_this<int>;
-template class enable_shared_from_this<void>;
-template class enable_shared_from_this<ClassType>;
-template class enable_shared_from_this<IncompleteClass>;
+template class std::tr1::enable_shared_from_this<int>;
+template class std::tr1::enable_shared_from_this<void>;
+template class std::tr1::enable_shared_from_this<ClassType>;
+template class std::tr1::enable_shared_from_this<IncompleteClass>;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc
index 794deaffe8d..918822d0681 100644
--- a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/1.cc
@@ -23,8 +23,7 @@
// { dg-do compile }
using namespace __gnu_test;
-using std::tr1::shared_ptr;
-template class shared_ptr<int>;
-template class shared_ptr<void>;
-template class shared_ptr<ClassType>;
-template class shared_ptr<IncompleteClass>;
+template class std::tr1::shared_ptr<int>;
+template class std::tr1::shared_ptr<void>;
+template class std::tr1::shared_ptr<ClassType>;
+template class std::tr1::shared_ptr<IncompleteClass>;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/2.cc
index 93587b293f7..870e888b382 100644
--- a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/2.cc
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/requirements/explicit_instantiation/2.cc
@@ -26,8 +26,7 @@
// library this checks the templates can be instantiated for non-default
// lock policy, for a single-threaded lib this is redundant but harmless.
using namespace __gnu_test;
-using std::tr1::__shared_ptr;
using std::tr1::_S_single;
-template class __shared_ptr<int, _S_single>;
-template class __shared_ptr<ClassType, _S_single>;
-template class __shared_ptr<IncompleteClass, _S_single>;
+template class std::tr1::__shared_ptr<int, _S_single>;
+template class std::tr1::__shared_ptr<ClassType, _S_single>;
+template class std::tr1::__shared_ptr<IncompleteClass, _S_single>;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc
index d64517c30c4..0680ead9c3e 100644
--- a/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/1.cc
@@ -23,8 +23,7 @@
// { dg-do compile }
using namespace __gnu_test;
-using std::tr1::weak_ptr;
-template class weak_ptr<int>;
-template class weak_ptr<void>;
-template class weak_ptr<ClassType>;
-template class weak_ptr<IncompleteClass>;
+template class std::tr1::weak_ptr<int>;
+template class std::tr1::weak_ptr<void>;
+template class std::tr1::weak_ptr<ClassType>;
+template class std::tr1::weak_ptr<IncompleteClass>;
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/2.cc
index 672e637d5f7..31617c9152c 100644
--- a/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/2.cc
+++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/weak_ptr/requirements/explicit_instantiation/2.cc
@@ -26,9 +26,8 @@
// library this checks the templates can be instantiated for non-default
// lock policy, for a single-threaded lib this is redundant but harmless.
using namespace __gnu_test;
-using std::tr1::__weak_ptr;
using std::tr1::_S_single;
-template class __weak_ptr<int, _S_single>;
-template class __weak_ptr<void, _S_single>;
-template class __weak_ptr<ClassType, _S_single>;
-template class __weak_ptr<IncompleteClass, _S_single>;
+template class std::tr1::__weak_ptr<int, _S_single>;
+template class std::tr1::__weak_ptr<void, _S_single>;
+template class std::tr1::__weak_ptr<ClassType, _S_single>;
+template class std::tr1::__weak_ptr<IncompleteClass, _S_single>;
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/hash/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/hash/requirements/explicit_instantiation.cc
index aba574d66dd..5f017c70461 100644
--- a/libstdc++-v3/testsuite/tr1/6_containers/hash/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/tr1/6_containers/hash/requirements/explicit_instantiation.cc
@@ -24,27 +24,25 @@
#include <string>
#include <tr1/functional>
-using namespace std::tr1;
-
// Verify that we can instantiate hash for every required type.
-template class hash<bool>;
-template class hash<char>;
-template class hash<signed char>;
-template class hash<unsigned char>;
-template class hash<short>;
-template class hash<int>;
-template class hash<long>;
-template class hash<unsigned short>;
-template class hash<unsigned int>;
-template class hash<unsigned long>;
-template class hash<float>;
-template class hash<double>;
-template class hash<long double>;
-template class hash<void*>;
-template class hash<std::string>;
+template class std::tr1::hash<bool>;
+template class std::tr1::hash<char>;
+template class std::tr1::hash<signed char>;
+template class std::tr1::hash<unsigned char>;
+template class std::tr1::hash<short>;
+template class std::tr1::hash<int>;
+template class std::tr1::hash<long>;
+template class std::tr1::hash<unsigned short>;
+template class std::tr1::hash<unsigned int>;
+template class std::tr1::hash<unsigned long>;
+template class std::tr1::hash<float>;
+template class std::tr1::hash<double>;
+template class std::tr1::hash<long double>;
+template class std::tr1::hash<void*>;
+template class std::tr1::hash<std::string>;
#ifdef _GLIBCXX_USE_WCHAR_T
-template class hash<wchar_t>;
-template class hash<std::wstring>;
+template class std::tr1::hash<wchar_t>;
+template class std::tr1::hash<std::wstring>;
#endif
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc
index f659817d72f..60ac8a5bef1 100644
--- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc
@@ -30,13 +30,13 @@ using std::allocator;
using std::pair;
using std::equal_to;
-template class unordered_map<string, float>;
-template class unordered_map<string, int,
+template class std::tr1::unordered_map<string, float>;
+template class std::tr1::unordered_map<string, int,
hash<string>, equal_to<string>,
allocator<pair<const string, int> > >;
-template class unordered_map<string, float,
+template class std::tr1::unordered_map<string, float,
hash<string>, equal_to<string>,
allocator<char> >;
-template class __unordered_map<string, int,
+template class std::tr1::__unordered_map<string, int,
hash<string>, equal_to<string>,
allocator<pair<const string, int> >, true>;
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc
index 5b72ae9b8eb..e92da828ff5 100644
--- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc
@@ -30,13 +30,13 @@ using std::equal_to;
using std::allocator;
using std::pair;
-template class unordered_multimap<string, float>;
-template class unordered_multimap<string, int,
+template class std::tr1::unordered_multimap<string, float>;
+template class std::tr1::unordered_multimap<string, int,
hash<string>, equal_to<string>,
allocator<pair<const string, int> > >;
-template class unordered_multimap<string, float,
+template class std::tr1::unordered_multimap<string, float,
hash<string>, equal_to<string>,
allocator<char> >;
-template class __unordered_multimap<string, int,
+template class std::tr1::__unordered_multimap<string, int,
hash<string>, equal_to<string>,
allocator<pair<const string, int> >, true>;
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc
index a1605266c8c..662184beed6 100644
--- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc
@@ -27,10 +27,10 @@ using namespace std::tr1;
using std::equal_to;
using std::allocator;
-template class unordered_multiset<int>;
-template class unordered_multiset<float, hash<float>, equal_to<float>,
+template class std::tr1::unordered_multiset<int>;
+template class std::tr1::unordered_multiset<float, hash<float>, equal_to<float>,
allocator<float> >;
-template class unordered_multiset<int, hash<int>, equal_to<int>,
+template class std::tr1::unordered_multiset<int, hash<int>, equal_to<int>,
allocator<char> >;
-template class __unordered_multiset<float, hash<float>, equal_to<float>,
+template class std::tr1::__unordered_multiset<float, hash<float>, equal_to<float>,
allocator<float>, true>;
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc
index 15679e1e629..5d4d83d743e 100644
--- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc
@@ -27,10 +27,10 @@ using namespace std::tr1;
using std::equal_to;
using std::allocator;
-template class unordered_set<int>;
-template class unordered_set<float, hash<float>, equal_to<float>,
- allocator<float> >;
-template class unordered_set<int, hash<int>, equal_to<int>,
- allocator<char> >;
-template class __unordered_set<float, hash<float>, equal_to<float>,
- allocator<float>, true>;
+template class std::tr1::unordered_set<int>;
+template class std::tr1::unordered_set<float, hash<float>, equal_to<float>,
+ allocator<float> >;
+template class std::tr1::unordered_set<int, hash<int>, equal_to<int>,
+ allocator<char> >;
+template class std::tr1::__unordered_set<float, hash<float>, equal_to<float>,
+ allocator<float>, true>;