diff options
author | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
commit | 3e519524c118651123eecf60c2bbc5d65ad9bac3 (patch) | |
tree | b2dd4168cfe448920a602cd7d2e40f95da187153 /libcxx/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp | |
parent | 9132c59d43b6c590c9bb33496eebf9f192d6857a (diff) | |
download | bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.tar.gz bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.zip |
libcxx initial import
llvm-svn: 103490
Diffstat (limited to 'libcxx/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp')
-rw-r--r-- | libcxx/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libcxx/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp b/libcxx/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp new file mode 100644 index 00000000000..3f1fb4d9408 --- /dev/null +++ b/libcxx/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <algorithm> + +// template <class InputIterator, class OutputIterator1, +// class OutputIterator2, class Predicate> +// pair<OutputIterator1, OutputIterator2> +// partition_copy(InputIterator first, InputIterator last, +// OutputIterator1 out_true, OutputIterator2 out_false, +// Predicate pred); + +#include <algorithm> +#include <cassert> + +#include "../../iterators.h" + +struct is_odd +{ + bool operator()(const int& i) const {return i & 1;} +}; + +int main() +{ + { + const int ia[] = {1, 2, 3, 4, 6, 8, 5, 7}; + int r1[10] = {0}; + int r2[10] = {0}; + typedef std::pair<output_iterator<int*>, int*> P; + P p = std::partition_copy(input_iterator<const int*>(std::begin(ia)), + input_iterator<const int*>(std::end(ia)), + output_iterator<int*>(r1), r2, is_odd()); + assert(p.first.base() == r1 + 4); + assert(r1[0] == 1); + assert(r1[1] == 3); + assert(r1[2] == 5); + assert(r1[3] == 7); + assert(p.second == r2 + 4); + assert(r2[0] == 2); + assert(r2[1] == 4); + assert(r2[2] == 6); + assert(r2[3] == 8); + } +} |