18 #include <boost/range/algorithm/copy.hpp>
25 #include <unordered_set>
30 namespace pa = paal::auctions;
33 using Item = std::string;
34 using Value =
unsigned int;
36 const std::vector<Bidder> bidders {
"Pooh Bear",
"Rabbit"};
38 const std::vector<Item> items {
"honey",
"baby carrot",
"carrot",
"jam"};
41 int operator()(Item item)
const
43 return item ==
"baby carrot" ? 2 : 1;
48 template <
class ItemSet>
49 Value operator()(
Bidder bidder,
const ItemSet& item_set)
const
51 if (bidder ==
"Pooh Bear")
52 return item_set.count(
"honey") > 0 ? 10 : 0;
53 assert(bidder ==
"Rabbit");
55 for (Item item: item_set)
56 if (item.find(
"carrot") != std::string::npos) ++res;
72 std::cout <<
"bidders: ";
74 auction.get<pa::bidders>(), std::ostream_iterator<Bidder>(std::cout,
", ")
76 std::cout << std::endl;
78 std::cout <<
"items with copies numbers: ";
79 for (
auto item: auction.get<pa::items>())
80 std::cout << item <<
" = " << auction.call<pa::get_copies_num>(item) <<
", ";
81 std::cout << std::endl;
83 std::cout <<
"pooh bear valuation: " <<
84 auction.call<pa::value_query>(
"Pooh Bear", std::set<Item>{
"jam",
"honey"}) <<
87 std::cout <<
"rabbit valuation: " <<
88 auction.call<pa::value_query>(
89 "Rabbit", std::unordered_set<Item>{
"carrot",
"baby carrot"}) <<
std::string Bidder
[Demand Query Auction Components Example]
auto make_value_query_auction_components(Args &&...args) -> decltype(value_query_components::make_components(std::forward< Args >(args)...))
make function for value query components
int main()
[Value Query Auction Components Example]