Boost logo

Boost :

From: William E. Kempf (wekempf_at_[hidden])
Date: 2003-01-09 12:20:56


> From: Rene Rivera <grafik666_at_[hidden]>
> [2003-01-09] William E. Kempf wrote:
>
> >> From: Rene Rivera <grafik666_at_[hidden]>
> >> The one place I would like to have such a thing it would have to be id().
> >>
> >> I have one, very overused, place in my code where I have to iterate on a
> >> list of objects, which have thread pointers to find the object given the
> >> current thread. It would somewhat cleaner and easier to understand if I
> >> could have a std::map<thread::ID,object*> instead.
> >
> >That doesn't necessarily speak for an ID type in addition to boost::thread.
> It only
> >adds another requirement that could be met by boost::thread itself. Either
> an
> >operator<(), knowing that the ordering is arbitrary, or follow the same
> route as
> >std::type_info and include a before(). Thoughts?
>
> Having an operator<() would work, but not be as convenient as an ID. In my
> simple thread.ID -> object* sample I would have to change it to thread* ->
> object* and add the dereference ops accordingly. So I would still prefer the
> ID, it's just cleaner and easier to understand.

I don't follow this. First, why are you using a thread* in the first place? Why not just a thread? (Remember that the new thread design is Copyable and Assignable.) Seems the map should just be:

typedef std::map<boost::thread, Object*> my_map;

which works if we make thread LessThanComparable.

>
> -- grafik - Don't Assume Anything
> -- rrivera_at_[hidden] - grafik_at_[hidden]
> -- 102708583_at_icq
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>

William E. Kempf
wekempf_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk