]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/poly_collection/example/basic_base.cpp
1 /* Copyright 2016-2017 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/poly_collection for library home page.
9 /* basic usage of boost::base_collection */
12 #include <boost/poly_collection/base_collection.hpp>
14 #include "rolegame.hpp"
19 //= #include <boost/poly_collection/base_collection.hpp>
22 boost::base_collection
<sprite
> c
;
24 std::mt19937 gen
{92748}; // some arbitrary random seed
25 std::discrete_distribution
<> rnd
{{1,1,1}};
26 for(int i
=0;i
<8;++i
){ // assign each type with 1/3 probability
28 case 0: c
.insert(warrior
{i
});break;
29 case 1: c
.insert(juggernaut
{i
});break;
30 case 2: c
.insert(goblin
{i
});break;
38 for(const sprite
& s
:c
){
54 // find element with id==7 and remove it
55 auto it
=std::find_if(c
.begin(),c
.end(),[](const sprite
& s
){return s
.id
==7;});