diff options
author | Louis Dionne <ldionne@apple.com> | 2019-09-05 13:50:18 +0000 |
---|---|---|
committer | Louis Dionne <ldionne@apple.com> | 2019-09-05 13:50:18 +0000 |
commit | f1b4eba66fb60dc3c6058041a0149883a02383ae (patch) | |
tree | 60c7f4a2870837e0eafda69b267eef64eae069eb /libcxx/test | |
parent | 3dac214273ee354ca7139c8b4f0ff70bd4d122e3 (diff) | |
download | bcm5719-llvm-f1b4eba66fb60dc3c6058041a0149883a02383ae.tar.gz bcm5719-llvm-f1b4eba66fb60dc3c6058041a0149883a02383ae.zip |
[libc++] Add a test for resizing of a vector with copy-only elements
See https://reviews.llvm.org/D62228#1658620
llvm-svn: 371067
Diffstat (limited to 'libcxx/test')
-rw-r--r-- | libcxx/test/std/containers/sequences/vector/vector.modifiers/resize.copy_only.pass.sh.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize.copy_only.pass.sh.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize.copy_only.pass.sh.cpp new file mode 100644 index 00000000000..b24736e22b6 --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize.copy_only.pass.sh.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// RUN: %build -fno-exceptions +// RUN: %run + +// RUN: %build +// RUN: %run + +// UNSUPPORTED: c++98, c++03 + +// <vector> + +// Test that vector won't try to call the move constructor when resizing if +// the class has a deleted move constructor (but a working copy constructor). + +#include <vector> + +class CopyOnly { +public: + CopyOnly() { } + + CopyOnly(CopyOnly&&) = delete; + CopyOnly& operator=(CopyOnly&&) = delete; + + CopyOnly(const CopyOnly&) = default; + CopyOnly& operator=(const CopyOnly&) = default; +}; + +int main() { + std::vector<CopyOnly> x; + x.emplace_back(); + + CopyOnly c; + x.push_back(c); + + return 0; +} |