template<typename Class, typename Type>
} || requires(Class c, Type t) {
}
Checks if the input class can close the needed thing, either as a operator() or using the close() fun...
Definition management.hpp:314
Checks if the input class can close the needed thing, either as a operator() or using the close() function.
class CloserWithFunction {
template <typename>
static constexpr bool always_false = false;
public:
template <typename T>
void close(T &var) const noexcept {
if (static_cast<int>(var) >= 0) ::close(static_cast<int>(var));
if (var != nullptr) fclose(var);
if (var != nullptr) closedir(var);
} else {
static_assert(always_false<T>, "Unsupported input type. Closer is only supports int, FILE* and DIR*");
}
}
};
class CloserWithOperator {
template <typename>
static constexpr bool always_false = false;
public:
template <typename T>
void operator()(T &var) const noexcept {
if (static_cast<int>(var) >= 0) ::close(static_cast<int>(var));
if (var !=
nullptr)
fclose(var);
if (var != nullptr) closedir(var);
} else {
static_assert(always_false<T>, "Unsupported input type. Closer is only supports int, FILE* and DIR*");
}
}
};
- Template Parameters
-
| Class | Class. |
| Type | Needed type. |
- See also
- Helper::BasicUniqueFD
-
Helper::BasicUniqueFP
- Note
- The return type of the desired
close() function/operator() must be void.