mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 03:32:35 +08:00
Mark LWG 2716 as complete - shuffle and sample disallows lvalue URNGs.
Libc++'s implementation of shuffle and sample already support lvalue and rvalue RNG's. This patch adds tests for both categories and marks the issue as complete. This patch also contains drive-by change for std::experimental::sample which improves the diagnostics produced when the correct iterator categories are not supplied. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279947 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -32,5 +32,8 @@ template <class PopulationIterator, class SampleIterator> void test() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
// expected-error@experimental/algorithm:* {{static_assert failed "SampleIterator must meet the requirements of RandomAccessIterator"}}
|
||||
// expected-error@experimental/algorithm:* 2 {{does not provide a subscript operator}}
|
||||
// expected-error@experimental/algorithm:* {{invalid operands}}
|
||||
test<input_iterator<int *>, output_iterator<int *> >();
|
||||
}
|
||||
|
@@ -46,8 +46,8 @@ template <>
|
||||
struct TestExpectations<std::input_iterator_tag>
|
||||
: public ReservoirSampleExpectations {};
|
||||
|
||||
template <template<class> class PopulationIteratorType, class PopulationItem,
|
||||
template<class> class SampleIteratorType, class SampleItem>
|
||||
template <template<class...> class PopulationIteratorType, class PopulationItem,
|
||||
template<class...> class SampleIteratorType, class SampleItem>
|
||||
void test() {
|
||||
typedef PopulationIteratorType<PopulationItem *> PopulationIterator;
|
||||
typedef SampleIteratorType<SampleItem *> SampleIterator;
|
||||
@@ -68,13 +68,13 @@ void test() {
|
||||
assert(std::equal(oa, oa + os, oa1));
|
||||
end = std::experimental::sample(PopulationIterator(ia),
|
||||
PopulationIterator(ia + is),
|
||||
SampleIterator(oa), os, g);
|
||||
SampleIterator(oa), os, std::move(g));
|
||||
assert(end.base() - oa == std::min(os, is));
|
||||
assert(std::equal(oa, oa + os, oa2));
|
||||
}
|
||||
|
||||
template <template<class> class PopulationIteratorType, class PopulationItem,
|
||||
template<class> class SampleIteratorType, class SampleItem>
|
||||
template <template<class...> class PopulationIteratorType, class PopulationItem,
|
||||
template<class...> class SampleIteratorType, class SampleItem>
|
||||
void test_empty_population() {
|
||||
typedef PopulationIteratorType<PopulationItem *> PopulationIterator;
|
||||
typedef SampleIteratorType<SampleItem *> SampleIterator;
|
||||
@@ -88,8 +88,8 @@ void test_empty_population() {
|
||||
assert(end.base() == oa);
|
||||
}
|
||||
|
||||
template <template<class> class PopulationIteratorType, class PopulationItem,
|
||||
template<class> class SampleIteratorType, class SampleItem>
|
||||
template <template<class...> class PopulationIteratorType, class PopulationItem,
|
||||
template<class...> class SampleIteratorType, class SampleItem>
|
||||
void test_empty_sample() {
|
||||
typedef PopulationIteratorType<PopulationItem *> PopulationIterator;
|
||||
typedef SampleIteratorType<SampleItem *> SampleIterator;
|
||||
@@ -103,8 +103,8 @@ void test_empty_sample() {
|
||||
assert(end.base() == oa);
|
||||
}
|
||||
|
||||
template <template<class> class PopulationIteratorType, class PopulationItem,
|
||||
template<class> class SampleIteratorType, class SampleItem>
|
||||
template <template<class...> class PopulationIteratorType, class PopulationItem,
|
||||
template<class...> class SampleIteratorType, class SampleItem>
|
||||
void test_small_population() {
|
||||
// The population size is less than the sample size.
|
||||
typedef PopulationIteratorType<PopulationItem *> PopulationIterator;
|
||||
|
Reference in New Issue
Block a user