mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-12 14:54:10 +00:00
fix libs/random/example/array.cpp
This commit is contained in:
parent
9d938bd747
commit
a5b7eda260
5 changed files with 205 additions and 207 deletions
|
@ -1,36 +1,34 @@
|
|||
//
|
||||
// Sprout C++ Library
|
||||
//
|
||||
// Copyright (c) 2013
|
||||
// bolero-MURAKAMI : http://d.hatena.ne.jp/boleros/
|
||||
// osyo-manga : http://d.hatena.ne.jp/osyo-manga/
|
||||
//
|
||||
// Readme:
|
||||
// https://github.com/bolero-MURAKAMI/Sprout/blob/master/README
|
||||
//
|
||||
// License:
|
||||
// Boost Software License - Version 1.0
|
||||
// <http://www.boost.org/LICENSE_1_0.txt>
|
||||
//
|
||||
#include <sprout/random.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/algorithm.hpp>
|
||||
|
||||
int
|
||||
main(){
|
||||
static constexpr sprout::default_random_engine engine;
|
||||
static constexpr sprout::uniform_smallint<int> dist(1, 6);
|
||||
|
||||
static constexpr sprout::array<int, 10> result = sprout::generate(
|
||||
// Result type
|
||||
sprout::array<int, 10>{},
|
||||
// Random generator
|
||||
sprout::random::combine(engine, dist)
|
||||
);
|
||||
|
||||
static_assert(
|
||||
result == sprout::make_array<int>(1, 1, 5, 2, 4, 2, 6, 2, 5, 1),
|
||||
"");
|
||||
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Sprout C++ Library
|
||||
//
|
||||
// Copyright (c) 2013
|
||||
// bolero-MURAKAMI : http://d.hatena.ne.jp/boleros/
|
||||
// osyo-manga : http://d.hatena.ne.jp/osyo-manga/
|
||||
//
|
||||
// Readme:
|
||||
// https://github.com/bolero-MURAKAMI/Sprout/blob/master/README
|
||||
//
|
||||
// License:
|
||||
// Boost Software License - Version 1.0
|
||||
// <http://www.boost.org/LICENSE_1_0.txt>
|
||||
//
|
||||
#include <sprout/random.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/algorithm.hpp>
|
||||
|
||||
int
|
||||
main(){
|
||||
static constexpr sprout::default_random_engine engine;
|
||||
static constexpr sprout::uniform_smallint<int> dist(1, 6);
|
||||
|
||||
static constexpr auto result = sprout::generate
|
||||
<sprout::array<int, 10> /* Result type */>
|
||||
(sprout::random::combine(engine, dist) /*Random generator*/)
|
||||
;
|
||||
|
||||
static_assert(
|
||||
result == sprout::make_array<int>(1, 1, 5, 2, 4, 2, 6, 2, 5, 1),
|
||||
"");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue