typedef typename remove_reference<_T1>::type& _T1_reference;
typedef typename remove_reference<_T2>::type& _T2_reference;
- typedef const typename remove_reference<_T1>::type& _T1_const_reference;
- typedef const typename remove_reference<_T2>::type& _T2_const_reference;
+ typedef typename remove_reference<typename add_const<_T1>::type>::type& _T1_const_reference;
+ typedef typename remove_reference<typename add_const<_T2>::type>::type& _T2_const_reference;
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_(), __second_() {}
_LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
typedef typename remove_reference<_T2>::type& _T2_reference;
typedef const _T1& _T1_const_reference;
- typedef const typename remove_reference<_T2>::type& _T2_const_reference;
+ typedef typename remove_reference<typename add_const<_T2>::type>::type&
+ _T2_const_reference;
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __second_() {}
_LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
typedef typename remove_reference<_T1>::type& _T1_reference;
typedef _T2& _T2_reference;
- typedef const typename remove_reference<_T1>::type& _T1_const_reference;
+ typedef typename remove_reference<typename add_const<_T1>::type>::type&
+ _T1_const_reference;
typedef const _T2& _T2_const_reference;
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_() {}
struct __nat {int __for_bool_;};
- typedef typename remove_reference<deleter_type>::type& _Dp_reference;
- typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference;
+ typedef typename remove_reference<deleter_type>::type& _Dp_reference;
+ typedef typename remove_reference<typename add_const<deleter_type>::type>::type&
+ _Dp_const_reference;
public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT
: __ptr_(pointer())
struct __nat {int __for_bool_;};
- typedef typename remove_reference<deleter_type>::type& _Dp_reference;
- typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference;
+ typedef typename remove_reference<deleter_type>::type& _Dp_reference;
+ typedef typename remove_reference<typename add_const<deleter_type>::type>::type&
+ _Dp_const_reference;
public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT
: __ptr_(pointer())
#include <memory>
#include <cassert>
+#include "test_macros.h"
-struct Deleter
-{
- void operator()(void*) {}
+struct Deleter {
+ void operator()(void*) const {}
- int test() {return 5;}
- int test() const {return 6;}
+ int test() { return 5; }
+ int test() const { return 6; }
};
-int main()
-{
- {
+int main() {
+ {
std::unique_ptr<int[], Deleter> p;
assert(p.get_deleter().test() == 5);
- }
- {
+ }
+ {
const std::unique_ptr<int[], Deleter> p;
assert(p.get_deleter().test() == 6);
- }
+ }
+ {
+ typedef std::unique_ptr<int[], const Deleter&> UPtr;
+ const Deleter d;
+ UPtr p(nullptr, d);
+ const UPtr& cp = p;
+ ASSERT_SAME_TYPE(decltype(p.get_deleter()), const Deleter&);
+ ASSERT_SAME_TYPE(decltype(cp.get_deleter()), const Deleter&);
+ assert(p.get_deleter().test() == 6);
+ assert(cp.get_deleter().test() == 6);
+ }
+ {
+ typedef std::unique_ptr<int[], Deleter&> UPtr;
+ Deleter d;
+ UPtr p(nullptr, d);
+ const UPtr& cp = p;
+ ASSERT_SAME_TYPE(decltype(p.get_deleter()), Deleter&);
+ ASSERT_SAME_TYPE(decltype(cp.get_deleter()), Deleter&);
+ assert(p.get_deleter().test() == 5);
+ assert(cp.get_deleter().test() == 5);
+ }
}
#include <memory>
#include <cassert>
+#include "test_macros.h"
-struct Deleter
-{
- void operator()(void*) {}
+struct Deleter {
+ void operator()(void*) const {}
- int test() {return 5;}
- int test() const {return 6;}
+ int test() { return 5; }
+ int test() const { return 6; }
};
-int main()
-{
- {
+int main() {
+ {
std::unique_ptr<int, Deleter> p;
assert(p.get_deleter().test() == 5);
- }
- {
+ }
+ {
const std::unique_ptr<int, Deleter> p;
assert(p.get_deleter().test() == 6);
- }
+ }
+ {
+ typedef std::unique_ptr<int, const Deleter&> UPtr;
+ const Deleter d;
+ UPtr p(nullptr, d);
+ const UPtr& cp = p;
+ ASSERT_SAME_TYPE(decltype(p.get_deleter()), const Deleter&);
+ ASSERT_SAME_TYPE(decltype(cp.get_deleter()), const Deleter&);
+ assert(p.get_deleter().test() == 6);
+ assert(cp.get_deleter().test() == 6);
+ }
+ {
+ typedef std::unique_ptr<int, Deleter&> UPtr;
+ Deleter d;
+ UPtr p(nullptr, d);
+ const UPtr& cp = p;
+ ASSERT_SAME_TYPE(decltype(p.get_deleter()), Deleter&);
+ ASSERT_SAME_TYPE(decltype(cp.get_deleter()), Deleter&);
+ assert(p.get_deleter().test() == 5);
+ assert(cp.get_deleter().test() == 5);
+ }
}
} // namespace test_macros_detail
#define ASSERT_SAME_TYPE(...) \
- static_assert(test_macros_detail::is_same<__VA_ARGS__>::value, \
+ static_assert((test_macros_detail::is_same<__VA_ARGS__>::value), \
"Types differ uexpectedly")
#ifndef TEST_HAS_NO_EXCEPTIONS