Commit 8b649cd3 by Jonathan Wakely Committed by Jonathan Wakely

Fix naming, qualification and broken test for propagate_const

	* include/experimental/propagate_const (propagate_const::__t): Rename
	to _M_t and remove comment. Qualify std::move and std::forward.
	* testsuite/experimental/propagate_const/cons/default.cc: Fix test.

From-SVN: r238611
parent 509b778f
2016-07-21 Jonathan Wakely <jwakely@redhat.com> 2016-07-21 Jonathan Wakely <jwakely@redhat.com>
* include/experimental/propagate_const (propagate_const::__t): Rename
to _M_t and remove comment. Qualify std::move and std::forward.
* testsuite/experimental/propagate_const/cons/default.cc: Fix test.
* testsuite/23_containers/vector/zero_sized_allocations.cc: * testsuite/23_containers/vector/zero_sized_allocations.cc:
Define sized deallocation function. Define sized deallocation function.
* testsuite/util/testsuite_new_operators.h: * testsuite/util/testsuite_new_operators.h:
......
...@@ -116,14 +116,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -116,14 +116,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
is_convertible<_Up&&, _Tp>>::value, bool is_convertible<_Up&&, _Tp>>::value, bool
>::type=true> >::type=true>
constexpr propagate_const(propagate_const<_Up>&& __pu) constexpr propagate_const(propagate_const<_Up>&& __pu)
: __t(move(get_underlying(__pu))) : _M_t(std::move(get_underlying(__pu)))
{} {}
template <typename _Up, typename template <typename _Up, typename
enable_if<__and_<is_constructible<_Tp, _Up&&>, enable_if<__and_<is_constructible<_Tp, _Up&&>,
__not_<is_convertible<_Up&&, _Tp>>>::value, __not_<is_convertible<_Up&&, _Tp>>>::value,
bool>::type=false> bool>::type=false>
constexpr explicit propagate_const(propagate_const<_Up>&& __pu) constexpr explicit propagate_const(propagate_const<_Up>&& __pu)
: __t(move(get_underlying(__pu))) : _M_t(std::move(get_underlying(__pu)))
{} {}
template <typename _Up, typename template <typename _Up, typename
enable_if<__and_<is_constructible<_Tp, _Up&&>, enable_if<__and_<is_constructible<_Tp, _Up&&>,
...@@ -132,7 +132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -132,7 +132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename decay<_Up>::type>> typename decay<_Up>::type>>
>::value, bool>::type=true> >::value, bool>::type=true>
constexpr propagate_const(_Up&& __u) constexpr propagate_const(_Up&& __u)
: __t(forward<_Up>(__u)) : _M_t(std::forward<_Up>(__u))
{} {}
template <typename _Up, typename template <typename _Up, typename
enable_if<__and_<is_constructible<_Tp, _Up&&>, enable_if<__and_<is_constructible<_Tp, _Up&&>,
...@@ -141,7 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -141,7 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename decay<_Up>::type>> typename decay<_Up>::type>>
>::value, bool>::type=false> >::value, bool>::type=false>
constexpr explicit propagate_const(_Up&& __u) constexpr explicit propagate_const(_Up&& __u)
: __t(forward<_Up>(__u)) : _M_t(std::forward<_Up>(__u))
{} {}
// [propagate_const.assignment], assignment // [propagate_const.assignment], assignment
...@@ -152,7 +152,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -152,7 +152,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename enable_if<is_convertible<_Up&&, _Tp>::value>::type> typename enable_if<is_convertible<_Up&&, _Tp>::value>::type>
constexpr propagate_const& operator=(propagate_const<_Up>&& __pu) constexpr propagate_const& operator=(propagate_const<_Up>&& __pu)
{ {
__t = move(get_underlying(__pu)); _M_t = std::move(get_underlying(__pu));
} }
template <typename _Up, typename = template <typename _Up, typename =
...@@ -162,13 +162,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -162,13 +162,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>::value>::type> >::value>::type>
constexpr propagate_const& operator=(_Up&& __u) constexpr propagate_const& operator=(_Up&& __u)
{ {
__t = forward<_Up>(__u); _M_t = std::forward<_Up>(__u);
} }
// [propagate_const.const_observers], const observers // [propagate_const.const_observers], const observers
explicit constexpr operator bool() const explicit constexpr operator bool() const
{ {
return bool(__t); return bool(_M_t);
} }
constexpr const element_type* operator->() const constexpr const element_type* operator->() const
...@@ -193,7 +193,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -193,7 +193,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr const element_type* get() const constexpr const element_type* get() const
{ {
return __to_raw_pointer(__t); return __to_raw_pointer(_M_t);
} }
// [propagate_const.non_const_observers], non-const observers // [propagate_const.non_const_observers], non-const observers
...@@ -219,7 +219,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -219,7 +219,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr element_type* get() constexpr element_type* get()
{ {
return __to_raw_pointer(__t); return __to_raw_pointer(_M_t);
} }
// [propagate_const.modifiers], modifiers // [propagate_const.modifiers], modifiers
...@@ -227,11 +227,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -227,11 +227,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
swap(propagate_const& __pt) noexcept(__is_nothrow_swappable<_Tp>::value) swap(propagate_const& __pt) noexcept(__is_nothrow_swappable<_Tp>::value)
{ {
using std::swap; using std::swap;
swap(__t, get_underlying(__pt)); swap(_M_t, get_underlying(__pt));
} }
private: private:
_Tp __t; //exposition only _Tp _M_t;
}; };
// [propagate_const.relational], relational operators // [propagate_const.relational], relational operators
...@@ -408,14 +408,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -408,14 +408,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr const _Tp& constexpr const _Tp&
get_underlying(const propagate_const<_Tp>& __pt) noexcept get_underlying(const propagate_const<_Tp>& __pt) noexcept
{ {
return __pt.__t; return __pt._M_t;
} }
template <typename _Tp> template <typename _Tp>
constexpr _Tp& constexpr _Tp&
get_underlying(propagate_const<_Tp>& __pt) noexcept get_underlying(propagate_const<_Tp>& __pt) noexcept
{ {
return __pt.__t; return __pt._M_t;
} }
// @} group propagate_const // @} group propagate_const
......
...@@ -27,6 +27,7 @@ int main() ...@@ -27,6 +27,7 @@ int main()
{ {
constexpr propagate_const<int*> test1{}; constexpr propagate_const<int*> test1{};
static_assert(!test1.get(), ""); static_assert(!test1.get(), "");
propagate_const<int*> test2; propagate_const<int*> test2; // wrapped pointer is not initialized
VERIFY(!test2.get()); propagate_const<int*> test3{};
VERIFY(!test3.get());
} }
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