1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <map>
namespace inventory {
template<class,class>
class inventory;
template<class>
struct item;
template<class Item, class Size>
struct item<inventory<Item,Size>>
{ using type =Item; }
template<class>
struct size;
template<class Item, class Size>
struct size<inventory<Item,Size>>
{ using type =Size; }
template <class Item, class Size>
class inventory {
private:
using item_type =typename item<inventory>::type;
using size_type =typename size<inventory>::type;
using internals_type =std::map<item_type,size_type>;
internals_type internals;
size_type full_size;
public:
using const_iterator =typename internals_type::const_iterator; //Je laisse celui-ci dedans pour raison de compatibilité
public:
inventory();
size_type add(item_size const& that, size_type count);
bool remove(item_size const& that, size_type count);
size_type size() const;
size_type distinct() const;
size_type count(item_size const& that) const;
const_iterator begin() const;
const_iterator end() const;
};
} |
Partager