Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-03 08:32:07

0001 #ifndef BOOST_UUID_DETAIL_RANDOM_PROVIDER_HPP_INCLUDED
0002 #define BOOST_UUID_DETAIL_RANDOM_PROVIDER_HPP_INCLUDED
0003 
0004 // Copyright (c) 2017 James E. King III
0005 // Copyright (c) 2024 Peter Dimov
0006 // Distributed under the Boost Software License, Version 1.0.
0007 // https://www.boost.org/LICENSE_1_0.txt
0008 
0009 #include <boost/uuid/detail/random_device.hpp>
0010 #include <random>
0011 #include <cstdint>
0012 
0013 namespace boost {
0014 namespace uuids {
0015 namespace detail {
0016 
0017 class random_provider
0018 {
0019 private:
0020 
0021     detail::random_device dev_;
0022 
0023 public:
0024 
0025     using result_type = std::uint32_t;
0026 
0027     random_provider() = default;
0028 
0029     // Leverage the provider as a SeedSeq for
0030     // PseudoRandomNumberGeneration seeding.
0031 
0032     template<class Iter>
0033     void generate(Iter first, Iter last)
0034     {
0035         std::uniform_int_distribution<std::uint32_t> dist;
0036 
0037         for( ; first != last; ++first )
0038         {
0039             *first = dist( dev_ );
0040         }
0041     }
0042 
0043     const char * name() const
0044     {
0045         return "std::random_device";
0046     }
0047 };
0048 
0049 } // detail
0050 } // uuids
0051 } // boost
0052 
0053 #endif // BOOST_UUID_DETAIL_RANDOM_PROVIDER_HPP_INCLUDED