Questions tagged [boost-uuid]

Boost.Uuid is a C++ library that provides an implementation of Universally Unique Identifiers.

Boost.Uuid is a C++ library that provides an implementation of Universally Unique Identifiers.

29 questions
104
votes
2 answers

Example of UUID generation using Boost in C++

I want to generate just random UUID's, as it is just important for instances in my program to have unique identifiers. I looked into Boost UUID, but I can't manage to generate the UUID because I don't understand which class and method to use. I…
Nikola
  • 1,406
  • 2
  • 16
  • 20
14
votes
1 answer

boost::uuids::uuid as a key in std::unordered_map?

I'm using clang (CXX='clang++ -std=c++11 -stdlib=libc++') on Mac OS X, with boost 1.53.0. I want to use uuid as keys in unordered_map, but getting the following errors: /usr/bin/../lib/c++/v1/type_traits:748:38: error: implicit instantiation of…
rincewind
  • 1,103
  • 8
  • 29
9
votes
1 answer

boost::uuids::random_generator and uniqueness with multiple threads

When I generate the random number with single thread, no duplicate in 4M uuids generated but if I generate with two threads each 1M, I see roughly 16-20 duplicates. What could be the reason? class TestUuid { public: std::string GenerateUUid(){ …
rjoshi
  • 1,645
  • 1
  • 20
  • 31
8
votes
3 answers

Check if std::string is a valid uuid using boost

I want to check if a given string is a valid UUID using boost. This is what I have come up with by looking at the documentation on the boost website: void validate_uuid(const std::string& value) { try { …
ksl
  • 4,519
  • 11
  • 65
  • 106
7
votes
1 answer

string to boost::uuid conversion

I've just started using boost in c++ and I just wanted to ask a couple of questions relating to uuids. I am loading in a file which requires I know the uuids so I can link some objects together. For this reason, I'm trying to write my own uuids but…
user3353807
  • 83
  • 1
  • 1
  • 5
6
votes
2 answers

Is boost::uuids::random_generator thread safe?

Consider this function compiling with g++ -std=c++11 (GCC 4.7.2): boost::uuids::uuid getID() { static boost::uuids::random_generator generator; return generator(); } Is it safe to call getID from multiple threads? As it is mentioned here…
Vahagn
  • 4,670
  • 9
  • 43
  • 72
5
votes
2 answers

Boost compile error on converting UUID to string using boost::lexical_cast

I have this code which is based on several posts in SO: boost::uuids::uuid uuid = boost::uuids::random_generator()(); auto uuidString= boost::lexical_cast(uuid); but when I am compiling this code, I am getting this error: Source type…
mans
  • 17,104
  • 45
  • 172
  • 321
5
votes
1 answer

Why do I get uninitialized-value warnings from Valgrind when I use Boost UUID?

I have a class with members: std::string mName; boost::uuids::uuid mId; In the constructor I wrote: mName = boost::lexical_cast(mId); Valgrind writes: ==30714== Use of uninitialised value of size 8 ==30714== at 0x69E92FC: ??? (in…
Max Frai
  • 61,946
  • 78
  • 197
  • 306
3
votes
1 answer

How to compile specific Boost libraries to a DLL

I am trying to embed the boost uuid package in my project. For ease we would like to just include some DLLs, as we do with most libraries we use. I can't figure out how to get just the DLLs for the uuid package (and any necessary dependencies). I…
zaknotzach
  • 977
  • 1
  • 9
  • 18
3
votes
1 answer

Analysis of Valgrind log for boost::uuid

I am using boost::uuid in order to generate unique ids: string UUid() { boost::uuids::uuid uuid = boost::uuids::random_generator()(); return boost::lexical_cast(uuid); } When I use valgrind in order to analyse my code i get…
Hani Goc
  • 2,371
  • 5
  • 45
  • 89
3
votes
2 answers

How to serialize a boost::uuid with cereal

Trying to serialize this simple class: class Data { public: Data(); Data(boost::uuids::uuid id); Data(const Data&) = delete; Data& operator=(const Data&) = delete; inline boost::uuids::uuid getGuid() { return guid; } …
kittikun
  • 1,829
  • 1
  • 25
  • 33
3
votes
3 answers

Is it safe to assume boost::uuid won't return a duplicate?

I'm using boost uuid to generate session ids. std::string SessionGenerator::generate() { boost::uuids::uuid id = m_rgen(); m_ss.clear(); m_ss.str(""); m_ss << id; return m_ss.str(); } Is it safe to assume that I'm never going…
jmasterx
  • 52,639
  • 96
  • 311
  • 557
2
votes
2 answers

Are there any issues with making random_generator static here?

I need to generate large number of UUIDs. If I don't make rg static, it would take lot of time in default constructing it every time. Is there anything wrong if I make it static, would it hurt uniqueness of uuids in anyway? Is there any better way…
Strike
  • 21
  • 1
2
votes
1 answer

How to integrate Boost.uuid into my cross-platform code?

I am writing an application with cocos2d-x which is a C++ cross-platform game engine. In the game I need to generate UUID without any input. Just I want to call a function generateUuid and assign the value returned by that function to an…
Narek
  • 38,779
  • 79
  • 233
  • 389
2
votes
1 answer

Define a static const Universal Unique Identifier (UUID)

Context I oftenly use UUID implementation of Boost library to identify derived classes. To do so I usually use the following : In the declaration file : #include "ClassA.h" #include class SubClass1 : public ClassA { …
gleeen.gould
  • 599
  • 1
  • 5
  • 22
1
2