boost-uuid

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

≡放荡痞女 提交于 2020-01-03 13:35:10
问题 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<std::string>(uuid); but when I am compiling this code, I am getting this error: Source type is neither std::ostream`able nor std::wostream`able C:\Local\boost\boost\lexical_cast\detail\converter_lexical.hpp How can I fix this error? 回答1: You're missing the include, I guess: Live On Coliru #include <boost/lexical_cast.hpp> #include <boost

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

一个人想着一个人 提交于 2019-12-19 02:43:05
问题 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 undefined template 'std::__1::hash<boost::uuids::uuid>' : public integral_constant<bool, __is_empty(_Tp)> {}; ^ /usr/bin/../lib/c++/v1/unordered_map:327:54: note: in instantiation of template class 'std::__1::is_empty<std::__1::hash<boost::uuids::uuid>

string to boost::uuid conversion

♀尐吖头ヾ 提交于 2019-12-10 05:30:03
问题 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 I'm not sure if there's any special conditions for the strings etc as the strings I've been using (usually something basic) are not working. Can anyone point me in the right direction? I've tried using a string generator, but to no avail thus far

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

穿精又带淫゛_ 提交于 2019-12-08 01:55:12
问题 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 to get a duplicate or should I be doing checks against active sessions? Thanks 回答1: Well, it depends. When UUIDs are generated by one of the defined mechanisms, they are either guaranteed to be unique , different from all other generated UUIDs (that is, it has never been

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

匆匆过客 提交于 2019-12-04 19:48:18
问题 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(){ boost::uuids::uuid uid; { boost::mutex::scoped_lock(m_mRandomGen); uid = m_oRandomGen(); } std::stringstream ss; ss << uid; return ss.str(); } void TestUid(std::map<std::string, unsigned>& mUids, unsigned count){ for(unsigned i = 0; i < count; ++i) {

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

 ̄綄美尐妖づ 提交于 2019-12-03 12:59:18
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(){ boost::uuids::uuid uid; { boost::mutex::scoped_lock(m_mRandomGen); uid = m_oRandomGen(); } std::stringstream ss; ss << uid; return ss.str(); } void TestUid(std::map<std::string, unsigned>& mUids, unsigned count){ for(unsigned i = 0; i < count; ++i) { std::string sUid = GenerateUUid(); std::map<std::string, unsigned>::const_iterator it = mUids.find(sUid);

Analysis of Valgrind log for boost::uuid

浪子不回头ぞ 提交于 2019-12-02 07:11:20
问题 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<std::string>(uuid); } When I use valgrind in order to analyse my code i get the following remarks: Valgrind log ==47807== Conditional jump or move depends on uninitialised value(s) ==47807== at 0x441D19: void boost::random::mersenne_twister_engine<unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615u, 11ul, 4294967295u, 7ul, 2636928640u

Analysis of Valgrind log for boost::uuid

泄露秘密 提交于 2019-12-02 04:51:27
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<std::string>(uuid); } When I use valgrind in order to analyse my code i get the following remarks: Valgrind log ==47807== Conditional jump or move depends on uninitialised value(s) ==47807== at 0x441D19: void boost::random::mersenne_twister_engine<unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615u, 11ul, 4294967295u, 7ul, 2636928640u, 15ul, 4022730752u, 18ul, 1812433253u>::seed<boost::uuids::detail::generator_iterator<boost::uuids:

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

此生再无相见时 提交于 2019-11-30 19:43:57
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 undefined template 'std::__1::hash<boost::uuids::uuid>' : public integral_constant<bool, __is_empty(_Tp)> {}; ^ /usr/bin/../lib/c++/v1/unordered_map:327:54: note: in instantiation of template class 'std::__1::is_empty<std::__1::hash<boost::uuids::uuid> >' requested here template <class _Key, class _Tp, class _Hash, bool = is_empty<_Hash>::value ... /usr

Example of UUID generation using Boost in C++

。_饼干妹妹 提交于 2019-11-27 17:11:48
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 would appreciate if someone could give me any example of how to achieve this. A basic example: #include <boost/uuid/uuid.hpp> // uuid class #include <boost/uuid/uuid_generators.hpp> // generators #include <boost/uuid/uuid_io.hpp> // streaming operators etc. int main() { boost::uuids::uuid uuid = boost::uuids::random_generator()(); std::cout << uuid <<