Files
clang-p2996/libcxx/test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.verify.cpp
Arthur O'Dwyer 8b29b84c99 [libc++] Fix LWG3422 "Issues of seed_seq's constructors"
https://cplusplus.github.io/LWG/issue3422

Also add a static_assert to check the "Mandates:" on the
iterator-pair constructor. Oddly, the `InputIterator` parameter
itself is merely preconditioned, not constrained, to satisfy the
input iterator requirements.

Also drive-by rename `init` to `__init`.

Differential Revision: https://reviews.llvm.org/D117962
2022-01-24 20:14:25 -05:00

31 lines
940 B
C++

//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// <random>
// class seed_seq;
// template<class InputIterator>
// seed_seq(InputIterator begin, InputIterator end);
// Mandates: iterator_traits<InputIterator>::value_type is an integer type.
#include <random>
void test()
{
{
bool a[2] = {true, false};
std::seed_seq s(a, a+2); // OK
}
{
double a[2] = {1, 2};
std::seed_seq s(a, a+2); // expected-error@*:* {{Mandates: iterator_traits<InputIterator>::value_type is an integer type}}
// expected-error@*:* {{invalid operands to binary expression ('double' and 'unsigned int')}}
}
}