Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API for Random numbers (OS-dependent) (#14) #15

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

leha-bot
Copy link
Contributor

Closes #14 .

@leha-bot leha-bot marked this pull request as ready for review September 13, 2024 20:37
@leha-bot leha-bot changed the base branch from master to dev September 13, 2024 20:37
@leha-bot leha-bot changed the title Feat/os random Add API for Random numbers (OS-dependent) (#14) Sep 13, 2024
@leha-bot leha-bot marked this pull request as draft September 13, 2024 20:38
Currently POSIX-only.
@@ -0,0 +1,16 @@
#include "FlameIDE/Common/PrimitiveTypes.hpp"
Copy link
Member

@kachsheev kachsheev Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use <>. And I think this string can be removed.

{


flame_ide::primitive_types::ssize_t RandomRange(void *buf, flame_ide::primitive_types::size_t size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use flame_ide::Types from Numbers.hpp

return RandomRange(&result, sizeof(T)) == sizeof(T) ? result : 0;
}

}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment to the end of namespaces

return getrandom(buf, size, 0);
}

}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment to the end of namespaces

{namespace os
{

flame_ide::primitive_types::ssize_t RandomRange(void *buf, flame_ide::primitive_types::size_t size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

randomRange()

/// It fills all bytes of returned value.
/// @tparam T Integral type used for returned value (default is int).
template <typename T = flame_ide::primitive_types::int_t>
typename EnableType<IsIntegralValue<T>, T>::Type Random()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Os/[Windows/Posix]/Random.hpp
2 participants