diff --git a/libcxx/include/memory b/libcxx/include/memory --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -2199,6 +2199,12 @@ __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {} #endif + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + __compressed_pair_elem(__compressed_pair_elem &&) = default; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + __compressed_pair_elem(__compressed_pair_elem const&) = default; + _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; } _LIBCPP_INLINE_VISIBILITY const_reference __get() const _NOEXCEPT { return __value_; } @@ -2238,6 +2244,12 @@ : __value_type(std::forward<_ParamT>(__p)) {} #endif + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + __compressed_pair_elem(__compressed_pair_elem &&) = default; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + __compressed_pair_elem(__compressed_pair_elem const&) = default; + _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; } _LIBCPP_INLINE_VISIBILITY const_reference __get() const _NOEXCEPT { return *this; } @@ -2314,6 +2326,12 @@ : _Base1(_VSTD::forward<_T1>(__t1)), _Base2(_VSTD::forward<_T2>(__t2)) {} #endif + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + __compressed_pair(__compressed_pair &&) = default; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + __compressed_pair(__compressed_pair const&) = default; + _LIBCPP_INLINE_VISIBILITY typename _Base1::reference first() _NOEXCEPT { return static_cast<_Base1&>(*this).__get(); diff --git a/libcxx/test/libcxx/utilities/compressed_pair/move_const.pass.cpp b/libcxx/test/libcxx/utilities/compressed_pair/move_const.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/utilities/compressed_pair/move_const.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +#include + +#include "test_macros.h" + +struct NoCopy { + NoCopy(NoCopy const&) = delete; + NoCopy() = delete; + explicit NoCopy(int) {} + + NoCopy(NoCopy &&) = default; +}; + +template +struct Foo { + std::__compressed_pair, int> x; + Foo(T t, int i) : x(std::__compressed_pair(std::move(t), i), 0) {} +}; + +int main(int, char**) +{ + Foo f(NoCopy(0), 1); + + return 0; +} \ No newline at end of file