PMT Renovated main
Partition Manager Tool is a fast, reliable, and feature-rich CLI application for Android devices that enables advanced partition operations such as backup, flashing, erasing, information retrieval, and more.
Loading...
Searching...
No Matches
Helper::IsFullCloser Concept Reference

Checks if the input class can close the needed thing, either as a operator() and using the close() function. More...

#include <management.hpp>

Concept definition

template<typename Class, typename Type>
concept Helper::IsFullCloser = requires(Class c, Type t) {
{ c(t) } -> std::same_as<void>;
{ c.close(t) } -> std::same_as<void>;
}
Checks if the input class can close the needed thing, either as a operator() and using the close() fu...
Definition management.hpp:359
T forward(T... args)

Detailed Description

Checks if the input class can close the needed thing, either as a operator() and using the close() function.

// A example valid class structure.
class Closer {
template <typename>
static constexpr bool always_false = false;
public:
template <typename T>
void close(T &var) const noexcept {
if constexpr (std::is_same_v<std::decay_t<T>, int>) {
if (static_cast<int>(var) >= 0) ::close(static_cast<int>(var));
} else if constexpr (std::is_same_v<std::decay_t<T>, FILE*>) {
if (var != nullptr) fclose(var);
} else if constexpr (std::is_same_v<std::decay_t<T>, DIR*>) {
if (var != nullptr) closedir(var);
} else {
static_assert(always_false<T>, "Unsupported input type. Closer is only supports int, FILE* and DIR*");
}
}
template <typename T>
void operator()(T &var) const noexcept {
close(var);
}
};
// To see how this concept is used, check out Helper::BasicUniqueFD or Helper::BasicUniqueFP.
Template Parameters
ClassClass.
TypeNeeded type.
See also
Helper::BasicUniqueFD
Helper::BasicUniqueFP
Note
The return type of the desired close() function and operator() must be void.