brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 926013b Raw
60 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <random>10 11// class seed_seq;12 13// template<class RandomAccessIterator>14//     void generate(RandomAccessIterator begin, RandomAccessIterator end);15 16// Check the following requirement: https://eel.is/c++draft/rand.util.seedseq#717//18//  Mandates: iterator_traits<RandomAccessIterator>::value_type is an unsigned integer19//            type capable of accommodating 32-bit quantities.20 21// UNSUPPORTED: c++0322// REQUIRES: stdlib=libc++23 24#include <random>25#include <climits>26#include <cstdint>27 28#include "test_macros.h"29 30void f() {31  std::seed_seq seq;32 33  // Not an integral type34  {35    double* p = nullptr;36    seq.generate(p, p); // expected-error-re@*:* {{static assertion failed{{.+}}: [rand.util.seedseq]/7 requires{{.+}}}}37    // expected-error@*:* 0+ {{invalid operands to}}38  }39 40  // Not an unsigned type41  {42    long long* p = nullptr;43    seq.generate(p, p); // expected-error-re@*:* {{static assertion failed{{.+}}: [rand.util.seedseq]/7 requires{{.+}}}}44  }45 46  // Not a 32-bit type47  {48#if UCHAR_MAX < UINT32_MAX49    unsigned char* p = nullptr;50    seq.generate(p, p); // expected-error-re@*:* {{static assertion failed{{.+}}: [rand.util.seedseq]/7 requires{{.+}}}}51#endif52  }53 54  // Everything satisfied55  {56    unsigned long* p = nullptr;57    seq.generate(p, p); // no diagnostic58  }59}60