38 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// template<class IntType = int>12// class discrete_distribution13 14// result_type max() const;15 16#include <random>17#include <cassert>18 19#include "test_macros.h"20 21int main(int, char**)22{23 {24 typedef std::discrete_distribution<> D;25 double p0[] = {.3, .1, .6};26 D d(p0, p0+3);27 assert(d.max() == 2);28 }29 {30 typedef std::discrete_distribution<> D;31 double p0[] = {.3, .1, .6, .2};32 D d(p0, p0+4);33 assert(d.max() == 3);34 }35 36 return 0;37}38