Re: portable uuid generator - seed

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: portable uuid generator - seed

Oliver.Kowalke-2
Hi Andy,
as you mentioned in t he source std::time(0) is not a good truly-random
seed.
Maybe you could use
boost::posix_time::microsec_clock::universal_time().time_of_day().total_
nanoseconds() ?

Regards,
Oliver

>hi andy,
>
>On Fri, 2006-03-03 at 14:26 +0000, Andy Tompkins wrote:
>> I am currently working on a guid class.  It is not quite done yet,
but
>> is quite
>> functional.  It does have a portable function to create guids.  I
have
>> put it
>> in the boost vault (guid.zip) in the hopes that it may one day be a
>> boost
>> library.
>
>well, the api looks really good (very similar to my libuuid wrapper)
...
>but i'm a bit lost building it ...
>i guess i have to run bjam, but how do i have to use it? up to now i
was
>just using emerging boost, but i have to experience in building it :-/
>
>thanks ... tim
>
>--
>[hidden email]    ICQ: 96771783
>http://www.mokabar.tk
>
>Linux is like a wigwam: no windows, no gates, apache inside, stable.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

FlySwapper crash w/ vector<bool>

Ed Fisher
Using Boost 1_33_1 and Visual Studio 8.  Any and all help appreciated.....
 
Working with  "The FlySwapper" example in the "C++ Template Metaprogramming" book. Pages 22-24.   It crashes when I do this:
     
           std::vector<bool>::iterator i1;
           std::vector<bool>::iterator i2;
           use_swap( &i1, &i2 )  // crash here
 
All other types I try work fine.  But doing <bool> crashes on this line:
 
  iter_swap_impl<use_swap>::do_it(*i1,*i2);  // ouch!!!
 
Debug looks like it stopped somewere within vector debug  during boost::apply processing.
 
// Fly Swapper code .....
 
<snip>
 
template <bool use_swap> struct iter_swap_impl;
template < class ForwardIterator1, class ForwardIterator2 >
void iter_swap(ForwardIterator1 i1, ForwardIterator2 i2 )
{
  typedef std::iterator_traits< ForwardIterator1 > traits1;
  typedef typename traits1::value_type v1;
  typedef typename traits1::reference  r1;
 
  typedef std::iterator_traits< ForwardIterator2 > traits2;
  typedef typename traits2::value_type v2;
  typedef typename traits2::reference  r2;
  bool const use_swap = boost::is_same<v1, v2>::value
    && boost::is_reference<r1>::value
    && boost::is_reference<r2>::value;
  iter_swap_impl<use_swap>::do_it(*i1,*i2);  //*****  CRASH CRASH here
}
template <>
struct iter_swap_impl<true> // fast one
{
  template < class ForwardIterator1, class ForwardIterator2 >
  static void do_it( ForwardIterator1 i1, ForwardIterator2 i2 )
  {
    std::cout << "use_swap is TRUE" << std::endl;
  }
};
template<>
struct iter_swap_impl<false>
{
  template < class ForwardIterator1, class ForwardIterator2 >
  static void do_it( ForwardIterator1 i1, ForwardIterator2 i2 )
  {
    std::cout << "use_swap is FALSE" << std::endl;
  }
};
</snip>

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

winmail.dat (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: FlySwapper crash w/ vector<bool>

David Abrahams

Please start a new thread when starting a new subject, rather than
replying to another thread and changing the subject line.

http://www.boost.org/more/discussion_policy.htm#effective

"Ed Fisher" <[hidden email]> writes:

> Using Boost 1_33_1 and Visual Studio 8.  Any and all help appreciated.....
>  
> Working with "The FlySwapper" example in the "C++ Template
> Metaprogramming" book. Pages 22-24.  It crashes when I do this:
>      
>            std::vector<bool>::iterator i1;
>            std::vector<bool>::iterator i2;
>            use_swap( &i1, &i2 )  // crash here

No such line of code exists in the book.

> All other types I try work fine.  But doing <bool> crashes on this
> line:
>  
>   iter_swap_impl<use_swap>::do_it(*i1,*i2);  // ouch!!!

Sorry, this is an erratum that has since been corrected in more recent
printings:

  http://boost-consulting.com/mplbook/errata.html#id2


HTH,

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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