Boost logo

Boost Users :

Subject: [Boost-users] Using boost::uuids::uuid as a map index
From: Tim Burgess (tim_at_[hidden])
Date: 2011-12-10 11:22:23


Hi,

I'm new to using boost and have hit a problem using UUID. I have a set of
classes that have UUID variables to provide unique identifiers. I wish to
achieve two things:

1 - Allow objects to reference each other based on their UUID values
(imagine the usual databasing student/teacher/course models);

2 - Maintain std::map collections of objects of the same class.

Initially, I made the mistake of creating a class instance containing my
UUID then inserting it into a map:

Std::map <boost::uuid::uid, myClass> myMap;

The index of the entry was set as follows:

Std::pair <boost::uuids::uuid, myClass> myPair;
myPair = std::make_pair( myClassInstance.UUIDField, myClassInstance);
myMap.insert( myPair);

All look-ups within the map based on the UUID then fail, as adding the
object to the map is essentially a copy operation and UUID is non-copyable,
so new unique identifiers were generated. I then tried:

Std::map <boost::uuids::uuid *, myClass*> myMap;

I thought that this should work as the actual UUID value would only ever be
held in a single instance of myClass and the relationships between objects
could be maintained by following the pointers. Unfortunately, look-ups
using this scheme also fail and I can't see where I'm going wrong. Can
anybody advise, please?

Best wishes.

Tim Burgess
Raised Bar Ltd
Phone: +44 (0)1827 719822

Don't forget to vote for improved access to music and music technology at

http://www.raisedbar.net/petition.htm
 

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Cromwell Enage
Sent: 10 December 2011 05:42
To: boost-users_at_[hidden]
Subject: [Boost-users] [boost-users][container] associative placement
insertion

Hi, all!

I'm wondering how placement insertion works for pair-associative
Boost.Container types.

For example, given:

//[ex_code
struct D {
D(char,char) {}
// Insert Boost.Move awareness here...
};

boost::container::map<int,D> my_map;
//]

Will my_map.emplace(0, 't', 'p') call D('t', 'p') and move the object into
the map?

Will Boost.Unordered work the same way?

TIA!
Cromwell D. Enage

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net