mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 23:40:57 +01:00
ircd::fs: Add boolean operators for fd.
This commit is contained in:
parent
6b6106499f
commit
c0e92eb2a1
1 changed files with 24 additions and 4 deletions
|
@ -29,10 +29,9 @@ struct ircd::fs::fd
|
|||
int fdno{-1};
|
||||
|
||||
public:
|
||||
operator const int &() const
|
||||
{
|
||||
return fdno;
|
||||
}
|
||||
operator const int &() const;
|
||||
operator bool() const;
|
||||
bool operator!() const;
|
||||
|
||||
fd(const string_view &path, const opts &);
|
||||
fd(const string_view &path);
|
||||
|
@ -69,3 +68,24 @@ struct ircd::fs::fd::opts
|
|||
opts(const std::ios::openmode &);
|
||||
opts() = default;
|
||||
};
|
||||
|
||||
inline bool
|
||||
ircd::fs::fd::operator!()
|
||||
const
|
||||
{
|
||||
return !bool(*this);
|
||||
}
|
||||
|
||||
inline ircd::fs::fd::operator
|
||||
bool()
|
||||
const
|
||||
{
|
||||
return int(*this) >= 0;
|
||||
}
|
||||
|
||||
inline ircd::fs::fd::operator
|
||||
const int &()
|
||||
const
|
||||
{
|
||||
return fdno;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue