[libcxx-commits] [PATCH] D69344: [libcxx] Add move constructor to compressed pair
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 24 09:34:46 PDT 2019
zoecarver updated this revision to Diff 226278.
zoecarver added a comment.
- use `= default` in move and copy constructors
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69344/new/
https://reviews.llvm.org/D69344
Files:
libcxx/include/memory
libcxx/test/libcxx/utilities/compressed_pair/move_const.pass.cpp
Index: libcxx/test/libcxx/utilities/compressed_pair/move_const.pass.cpp
===================================================================
--- /dev/null
+++ 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
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+#include <memory>
+
+#include "test_macros.h"
+
+struct NoCopy {
+ NoCopy(NoCopy const&) = delete;
+ NoCopy() = delete;
+ explicit NoCopy(int) {}
+
+ NoCopy(NoCopy &&) = default;
+};
+
+template<class T>
+struct Foo {
+ std::__compressed_pair<std::__compressed_pair<NoCopy, int>, int> x;
+ Foo(T t, int i) : x(std::__compressed_pair<NoCopy, int>(std::move(t), i), 0) {}
+};
+
+int main(int, char**)
+{
+ Foo<NoCopy> f(NoCopy(0), 1);
+
+ return 0;
+}
\ No newline at end of file
Index: libcxx/include/memory
===================================================================
--- libcxx/include/memory
+++ 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69344.226278.patch
Type: text/x-patch
Size: 2789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20191024/e9d1fdc6/attachment.bin>
More information about the libcxx-commits
mailing list