BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches

Namespaces

namespace  detail
namespace  files
namespace  math
namespace  memory
namespace  strings

Classes

struct  Visitor

Concepts

concept  ChronoDuration

Typedefs

template<ChronoDuration Duration, std::floating_point F = float>
using FractionalDuration = std::chrono::duration<F, typename Duration::period>

Functions

void enable_utf8_console_output ()
auto get_environment_variable (std::string_view name) -> std::optional< std::string >
void progressive_backoff (std::function< bool()> pred)
auto start_file_logger (const std::filesystem::path &logFile) -> std::expected< void, std::string >

Detailed Description

This namespace contains generic utilities.

This namespace provides general utilities not specific to chess.

Typedef Documentation

◆ FractionalDuration

template<ChronoDuration Duration, std::floating_point F = float>
using util::FractionalDuration = std::chrono::duration<F, typename Duration::period>

This typedef allows converting a chrono duration to one with the same period, but with a floating-point tick type.

Example usage:

PartialSeconds secs { 1.5f };
std::chrono::duration< F, typename Duration::period > FractionalDuration
Definition Chrono.hpp:53

Definition at line 53 of file Chrono.hpp.

Function Documentation

◆ get_environment_variable()

auto util::get_environment_variable ( std::string_view name) -> std::optional< std::string >
nodiscard

Returns the value of the environment variable with the given name. If the variable is not set, or there is an error querying the environment, nullopt is returned. If the variable is set to an empty string, an optional holding an empty string is returned.

Note
This function is needed because all compilers warn about std::getenv() being deprecated and/or thread-unsafe. This function abstracts platform-specific thread-safe versions of std::getenv().