]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/poly_collection/example/rolegame.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / poly_collection / example / rolegame.hpp
CommitLineData
b32b8144
FG
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)
5 *
6 * See http://www.boost.org/libs/poly_collection for library home page.
7 */
8
9#ifndef BOOST_POLY_COLLECTION_EXAMPLE_ROLEGAME_HPP
10#define BOOST_POLY_COLLECTION_EXAMPLE_ROLEGAME_HPP
11
12#if defined(_MSC_VER)
13#pragma once
14#endif
15
16/* entities of a purported role game used in the examples */
17
18#include <iostream>
19#include <string>
20#include <utility>
21
22//[rolegame_1
23struct sprite
24{
25 sprite(int id):id{id}{}
26 virtual ~sprite()=default;
27 virtual void render(std::ostream& os)const=0;
28
29 int id;
30};
31//]
32
33//[rolegame_2
34struct warrior:sprite
35{
36 using sprite::sprite;
37 warrior(std::string rank,int id):sprite{id},rank{std::move(rank)}{}
38
39 void render(std::ostream& os)const override{os<<rank<<" "<<id;}
40
41 std::string rank="warrior";
42};
43
44struct juggernaut:warrior
45{
46 juggernaut(int id):warrior{"juggernaut",id}{}
47};
48
49struct goblin:sprite
50{
51 using sprite::sprite;
52 void render(std::ostream& os)const override{os<<"goblin "<<id;}
53};
54//]
55
56//[rolegame_3
57struct window
58{
59 window(std::string caption):caption{std::move(caption)}{}
60
61 void display(std::ostream& os)const{os<<"["<<caption<<"]";}
62
63 std::string caption;
64};
65//]
66
67//[rolegame_4
68struct elf:sprite
69{
70 using sprite::sprite;
71 elf(const elf&)=delete; // not copyable
72 elf(elf&&)=default; // but moveable
73 void render(std::ostream& os)const override{os<<"elf "<<id;}
74};
75//]
76
77
78#endif