util: thanks msvc for accepting invalid code

This commit is contained in:
Michele Caini 2024-10-23 08:56:13 +02:00
parent 3c57dd9a98
commit e4bb43bce7

View File

@ -310,7 +310,7 @@ struct utilities {
* *
* @return The current process id. * @return The current process id.
*/ */
static [[nodiscard]] pid_type pid() noexcept; [[nodiscard]] static pid_type pid() noexcept;
/** /**
* @brief Returns the parent process id. * @brief Returns the parent process id.
@ -321,7 +321,7 @@ struct utilities {
* *
* @return The parent process id. * @return The parent process id.
*/ */
static [[nodiscard]] pid_type ppid() noexcept; [[nodiscard]] static pid_type ppid() noexcept;
/** /**
* @brief Gets the current user's home directory. * @brief Gets the current user's home directory.
@ -333,7 +333,7 @@ struct utilities {
* @return The current user's home directory, an empty string in case of * @return The current user's home directory, an empty string in case of
* errors. * errors.
*/ */
static [[nodiscard]] std::string homedir() noexcept; [[nodiscard]] static std::string homedir() noexcept;
/** /**
* @brief Gets the temp directory. * @brief Gets the temp directory.
@ -344,7 +344,7 @@ struct utilities {
* *
* @return The temp directory, an empty string in case of errors. * @return The temp directory, an empty string in case of errors.
*/ */
static [[nodiscard]] std::string tmpdir() noexcept; [[nodiscard]] static std::string tmpdir() noexcept;
/** /**
* @brief Retrieves an environment variable. * @brief Retrieves an environment variable.
@ -352,7 +352,7 @@ struct utilities {
* @return The value of the environment variable, an empty string in * @return The value of the environment variable, an empty string in
* case of errors. * case of errors.
*/ */
static [[nodiscard]] std::string env(const std::string &name) noexcept; [[nodiscard]] static std::string env(const std::string &name) noexcept;
/** /**
* @brief Creates, updates or deletes an environment variable. * @brief Creates, updates or deletes an environment variable.
@ -377,7 +377,7 @@ struct utilities {
* @return True in case of success, false otherwise. * @return True in case of success, false otherwise.
*/ */
template<typename Func> template<typename Func>
static [[nodiscard]] std::enable_if_t<std::is_invocable_v<Func, std::string_view, std::string_view>, bool> [[nodiscard]] static std::enable_if_t<std::is_invocable_v<Func, std::string_view, std::string_view>, bool>
env(Func func) noexcept { env(Func func) noexcept {
uv_env_item_t *items = nullptr; uv_env_item_t *items = nullptr;
int count{}; int count{};
@ -399,7 +399,7 @@ struct utilities {
* @brief Returns the hostname. * @brief Returns the hostname.
* @return The hostname, an empty string in case of errors. * @return The hostname, an empty string in case of errors.
*/ */
static [[nodiscard]] std::string hostname() noexcept; [[nodiscard]] static std::string hostname() noexcept;
/** /**
* @brief Gets name and information about the current kernel. * @brief Gets name and information about the current kernel.
@ -410,7 +410,7 @@ struct utilities {
* *
* @return Name and information about the current kernel. * @return Name and information about the current kernel.
*/ */
static [[nodiscard]] uts_name uname() noexcept; [[nodiscard]] static uts_name uname() noexcept;
/** /**
* @brief Gets a subset of the password file entry. * @brief Gets a subset of the password file entry.
@ -424,7 +424,7 @@ struct utilities {
* *
* @return The accessible subset of the password file entry. * @return The accessible subset of the password file entry.
*/ */
static [[nodiscard]] passwd_info passwd(); [[nodiscard]] static passwd_info passwd();
/** /**
* @brief Retrieves the scheduling priority of a process. * @brief Retrieves the scheduling priority of a process.
@ -464,7 +464,7 @@ struct utilities {
* @param category A properly initialized handle category. * @param category A properly initialized handle category.
* @return The actual type of the handle as defined by handle_type * @return The actual type of the handle as defined by handle_type
*/ */
static [[nodiscard]] handle_type guess_handle(handle_category category) noexcept; [[nodiscard]] static handle_type guess_handle(handle_category category) noexcept;
/** /**
* @brief Gets the type of the stream to be used with the given descriptor. * @brief Gets the type of the stream to be used with the given descriptor.
@ -484,7 +484,7 @@ struct utilities {
* * `handle_type::UDP` * * `handle_type::UDP`
* * `handle_type::FILE` * * `handle_type::FILE`
*/ */
static [[nodiscard]] handle_type guess_handle(file_handle file) noexcept; [[nodiscard]] static handle_type guess_handle(file_handle file) noexcept;
/** @brief Gets information about the CPUs on the system. /** @brief Gets information about the CPUs on the system.
* *
@ -493,7 +493,7 @@ struct utilities {
* *
* @return A set of descriptors of all the available CPUs. * @return A set of descriptors of all the available CPUs.
*/ */
static [[nodiscard]] std::vector<cpu_info> cpu() noexcept; [[nodiscard]] static std::vector<cpu_info> cpu() noexcept;
/** /**
* @brief Gets a set of descriptors of all the available interfaces. * @brief Gets a set of descriptors of all the available interfaces.
@ -503,7 +503,7 @@ struct utilities {
* *
* @return A set of descriptors of all the available interfaces. * @return A set of descriptors of all the available interfaces.
*/ */
static [[nodiscard]] std::vector<interface_address> interface_addresses() noexcept; [[nodiscard]] static std::vector<interface_address> interface_addresses() noexcept;
/** /**
* @brief IPv6-capable implementation of * @brief IPv6-capable implementation of
@ -518,7 +518,7 @@ struct utilities {
* @param index Network interface index. * @param index Network interface index.
* @return Network interface name. * @return Network interface name.
*/ */
static [[nodiscard]] std::string index_to_name(unsigned int index) noexcept; [[nodiscard]] static std::string index_to_name(unsigned int index) noexcept;
/** /**
* @brief Retrieves a network interface identifier. * @brief Retrieves a network interface identifier.
@ -530,7 +530,7 @@ struct utilities {
* @param index Network interface index. * @param index Network interface index.
* @return Network interface identifier. * @return Network interface identifier.
*/ */
static [[nodiscard]] std::string index_to_iid(unsigned int index) noexcept; [[nodiscard]] static std::string index_to_iid(unsigned int index) noexcept;
/** /**
* @brief Override the use of some standard librarys functions. * @brief Override the use of some standard librarys functions.
@ -561,7 +561,7 @@ struct utilities {
* @brief Gets the load average. * @brief Gets the load average.
* @return `[0,0,0]` on Windows (not available), the load average otherwise. * @return `[0,0,0]` on Windows (not available), the load average otherwise.
*/ */
static [[nodiscard]] std::array<double, 3> load_average() noexcept; [[nodiscard]] static std::array<double, 3> load_average() noexcept;
/** /**
* @brief Store the program arguments. * @brief Store the program arguments.
@ -576,7 +576,7 @@ struct utilities {
* @brief Gets the title of the current process. * @brief Gets the title of the current process.
* @return The process title. * @return The process title.
*/ */
static [[nodiscard]] std::string process_title(); [[nodiscard]] static std::string process_title();
/** /**
* @brief Sets the current process title. * @brief Sets the current process title.
@ -589,7 +589,7 @@ struct utilities {
* @brief Gets memory information (in bytes). * @brief Gets memory information (in bytes).
* @return Memory information. * @return Memory information.
*/ */
static [[nodiscard]] uint64_t total_memory() noexcept; [[nodiscard]] static uint64_t total_memory() noexcept;
/** /**
* @brief Gets the amount of memory available to the process (in bytes). * @brief Gets the amount of memory available to the process (in bytes).
@ -602,39 +602,39 @@ struct utilities {
* *
* @return Amount of memory available to the process. * @return Amount of memory available to the process.
*/ */
static [[nodiscard]] uint64_t constrained_memory() noexcept; [[nodiscard]] static uint64_t constrained_memory() noexcept;
/** /**
* @brief Gets the amount of free memory still available to the process. * @brief Gets the amount of free memory still available to the process.
* @return Amount of free memory still available to the process (in bytes). * @return Amount of free memory still available to the process (in bytes).
*/ */
static [[nodiscard]] uint64_t available_memory() noexcept; [[nodiscard]] static uint64_t available_memory() noexcept;
/** /**
* @brief Gets the resident set size (RSS) for the current process. * @brief Gets the resident set size (RSS) for the current process.
* @return The resident set size (RSS) for the current process or a negative * @return The resident set size (RSS) for the current process or a negative
* value in case of errors. * value in case of errors.
*/ */
static [[nodiscard]] int64_t resident_set_memory() noexcept; [[nodiscard]] static int64_t resident_set_memory() noexcept;
/** /**
* @brief Gets the current system uptime. * @brief Gets the current system uptime.
* @return The current system uptime or 0 in case of errors. * @return The current system uptime or 0 in case of errors.
*/ */
static [[nodiscard]] double uptime() noexcept; [[nodiscard]] static double uptime() noexcept;
/** /**
* @brief Gets the resource usage measures for the current process. * @brief Gets the resource usage measures for the current process.
* @return Resource usage measures, zeroes-filled object in case of errors. * @return Resource usage measures, zeroes-filled object in case of errors.
*/ */
static [[nodiscard]] resource_usage rusage() noexcept; [[nodiscard]] static resource_usage rusage() noexcept;
/** /**
* @brief Gets the current system time from a high-resolution clock source. * @brief Gets the current system time from a high-resolution clock source.
* @param source Clock source, either real-time or monotonic. * @param source Clock source, either real-time or monotonic.
* @return Current system time from the given high-resolution clock source. * @return Current system time from the given high-resolution clock source.
*/ */
static [[nodiscard]] timespec64 gettime(clock_id source) noexcept; [[nodiscard]] static timespec64 gettime(clock_id source) noexcept;
/** /**
* @brief Gets the current high-resolution real time. * @brief Gets the current high-resolution real time.
@ -646,7 +646,7 @@ struct utilities {
* *
* @return The current high-resolution real time. * @return The current high-resolution real time.
*/ */
static [[nodiscard]] uint64_t hrtime() noexcept; [[nodiscard]] static uint64_t hrtime() noexcept;
/** /**
* @brief Gets the executable path. * @brief Gets the executable path.
@ -658,7 +658,7 @@ struct utilities {
* @brief Gets the current working directory. * @brief Gets the current working directory.
* @return The current working directory, an empty string in case of errors. * @return The current working directory, an empty string in case of errors.
*/ */
static [[nodiscard]] std::string cwd() noexcept; [[nodiscard]] static std::string cwd() noexcept;
/** /**
* @brief Changes the current working directory. * @brief Changes the current working directory.
@ -672,7 +672,7 @@ struct utilities {
* [`gettimeofday`](https://linux.die.net/man/2/gettimeofday) * [`gettimeofday`](https://linux.die.net/man/2/gettimeofday)
* @return The current time. * @return The current time.
*/ */
static [[nodiscard]] timeval64 time_of_day() noexcept; [[nodiscard]] static timeval64 time_of_day() noexcept;
/** /**
* @brief Causes the calling thread to sleep for a while. * @brief Causes the calling thread to sleep for a while.
@ -685,7 +685,7 @@ struct utilities {
* use (always a non-zero value). * use (always a non-zero value).
* @return Estimate of the amount of parallelism a program should use. * @return Estimate of the amount of parallelism a program should use.
*/ */
static [[nodiscard]] unsigned int available_parallelism() noexcept; [[nodiscard]] static unsigned int available_parallelism() noexcept;
}; };
/** /**