|
Boost : |
Subject: Re: [boost] std::map<> - like structure for other than std::pair<>?
From: Olaf van der Spek (ml_at_[hidden])
Date: 2015-04-14 07:48:43
On Tue, Apr 14, 2015 at 1:37 PM, M.A. van den Berg <thijs_at_[hidden]> wrote:
> You can store your objects in a std::set instead of a map and then provide a custom compare function that compared your objects given your key in them. E.g.
>
> struct my_compare {
> bool operator() (const MyObj& lhs, const MyObj& rhs) const{
> return lhs.name < rhs.name;
> }
> };
>
>
> std::set<MyObj, my_compare> s;
set entries are const so this isn't usable in all cases.
-- Olaf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk