HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
seed.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
8#pragma once
9
10#include "../assert.hpp"
11#include "../rapid/numeric_array.hpp"
12#include <random>
13#include <concepts>
14#include <type_traits>
15#include <bit>
16
17namespace hi::inline v1 {
18
25void generate_seed(void *ptr, size_t size);
26
34template<typename T>
35struct seed {
36 [[nodiscard]] T operator()() const
37 {
38 hi_not_implemented();
39 }
40
41 [[nodiscard]] T operator()() const requires(std::has_unique_object_representations_v<T> and not std::is_pointer_v<T>)
42 {
43 auto buffer = std::array<uint8_t, sizeof(T)>{};
44 generate_seed(buffer.data(), buffer.size());
45 return std::bit_cast<T>(buffer);
46 }
47};
48
49} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:15
void generate_seed(void *ptr, size_t size)
Load a random seed.
Randomly generate an object.
Definition seed.hpp:35