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-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // <random> |
10 | |
11 | // template<class IntType = int> |
12 | // class poisson_distribution |
13 | |
14 | // explicit poisson_distribution(double mean = 1.0); // before C++20 |
15 | // poisson_distribution() : poisson_distribution(1.0) {} // C++20 |
16 | // explicit poisson_distribution(double mean); // C++20 |
17 | |
18 | #include <random> |
19 | #include <cassert> |
20 | |
21 | #include "test_macros.h" |
22 | #if TEST_STD_VER >= 11 |
23 | #include "make_implicit.h" |
24 | #include "test_convertible.h" |
25 | #endif |
26 | |
27 | template <class T> |
28 | void test_implicit() { |
29 | #if TEST_STD_VER >= 11 |
30 | typedef std::poisson_distribution<T> D; |
31 | static_assert(test_convertible<D>(), "" ); |
32 | assert(D(1) == make_implicit<D>()); |
33 | static_assert(!test_convertible<D, double>(), "" ); |
34 | #endif |
35 | } |
36 | |
37 | int main(int, char**) |
38 | { |
39 | { |
40 | typedef std::poisson_distribution<> D; |
41 | D d; |
42 | assert(d.mean() == 1); |
43 | } |
44 | { |
45 | typedef std::poisson_distribution<> D; |
46 | D d(3.5); |
47 | assert(d.mean() == 3.5); |
48 | } |
49 | |
50 | test_implicit<int>(); |
51 | test_implicit<long>(); |
52 | |
53 | return 0; |
54 | } |
55 | |