1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <random> 11 12// template<class RealType = double> 13// class piecewise_linear_distribution 14 15// template <class charT, class traits> 16// basic_ostream<charT, traits>& 17// operator<<(basic_ostream<charT, traits>& os, 18// const piecewise_linear_distribution& x); 19// 20// template <class charT, class traits> 21// basic_istream<charT, traits>& 22// operator>>(basic_istream<charT, traits>& is, 23// piecewise_linear_distribution& x); 24 25#include <random> 26#include <sstream> 27#include <cassert> 28 29int main() 30{ 31 { 32 typedef std::piecewise_linear_distribution<> D; 33 double b[] = {10, 14, 16, 17}; 34 double p[] = {25, 62.5, 12.5, 25}; 35 const size_t Np = sizeof(p) / sizeof(p[0]); 36 D d1(b, b+Np, p); 37 std::ostringstream os; 38 os << d1; 39 std::istringstream is(os.str()); 40 D d2; 41 is >> d2; 42 assert(d1 == d2); 43 } 44} 45