diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-08-01 17:29:28 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-08-01 17:29:28 +0000 |
commit | 0f242bea1097ab7a49dccf851c36f76194977ddb (patch) | |
tree | b032bada83dfcc989317036b501bf5544cf94ade /libcxx/test/algorithms/alg.modifying.operations | |
parent | 62f0ffd733102a260e326cfb191f733a1b4569d1 (diff) | |
download | bcm5719-llvm-0f242bea1097ab7a49dccf851c36f76194977ddb.tar.gz bcm5719-llvm-0f242bea1097ab7a49dccf851c36f76194977ddb.zip |
Taking another swing at correctly optimizing fill_n.
llvm-svn: 187587
Diffstat (limited to 'libcxx/test/algorithms/alg.modifying.operations')
-rw-r--r-- | libcxx/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libcxx/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp b/libcxx/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp index 68bea690348..bffcf1b63cb 100644 --- a/libcxx/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp +++ b/libcxx/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp @@ -94,6 +94,44 @@ test_struct_array() assert(test1a[3].c == 11); } +class A +{ + char a_; +public: + A() {} + explicit A(char a) : a_(a) {} + operator unsigned char() const {return 'b';} + + friend bool operator==(const A& x, const A& y) + {return x.a_ == y.a_;} +}; + +void +test5() +{ + A a[3]; + assert(std::fill_n(&a[0], 3, A('a')) == a+3); + assert(a[0] == A('a')); + assert(a[1] == A('a')); + assert(a[2] == A('a')); +} + +struct Storage +{ + union + { + unsigned char a; + unsigned char b; + }; +}; + +void test6() +{ + Storage foo[5]; + std::fill_n(&foo[0], 5, Storage()); +} + + int main() { test_char<forward_iterator<char*> >(); @@ -109,4 +147,7 @@ int main() test_int_array(); test_int_array_struct_source(); test_struct_array(); + + test5(); + test6(); } |