mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 20:29:39 +08:00
Summary:
Currently libc++ implements some operations on valarray by using the
resize method. This method has a parameter with a default value.
Because of this, valarray may spuriously construct and destruct
objects of valarray's element type.
This patch fixes this issue and adds corresponding test cases.
Reviewers: EricWF, mclow.lists
Reviewed By: mclow.lists
Subscribers: rogfer01, cfe-commits
Differential Revision: https://reviews.llvm.org/D41992
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324596 91177308-0d34-0410-b5e6-96231b3b80d8
50 lines
1007 B
C++
50 lines
1007 B
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <valarray>
|
|
|
|
// template<class T> class valarray;
|
|
|
|
// valarray();
|
|
|
|
#include <valarray>
|
|
#include <cassert>
|
|
|
|
struct S {
|
|
S() { ctor_called = true; }
|
|
static bool ctor_called;
|
|
};
|
|
|
|
bool S::ctor_called = false;
|
|
|
|
int main()
|
|
{
|
|
{
|
|
std::valarray<int> v;
|
|
assert(v.size() == 0);
|
|
}
|
|
{
|
|
std::valarray<float> v;
|
|
assert(v.size() == 0);
|
|
}
|
|
{
|
|
std::valarray<double> v;
|
|
assert(v.size() == 0);
|
|
}
|
|
{
|
|
std::valarray<std::valarray<double> > v;
|
|
assert(v.size() == 0);
|
|
}
|
|
{
|
|
std::valarray<S> v;
|
|
assert(v.size() == 0);
|
|
assert(!S::ctor_called);
|
|
}
|
|
}
|